Hi, I am trying to write a bond pricing formula in dynare. Sb is the bond price and cp is coupon with one as the face value. m is the stochastic discount factor. I would like to write this formula for a maturity K. This requires writing a finite sum. I have done it manually up to 2 period. If I like to do this for 30 periods, how do I write it? Any help?
I write the formula below for your perusal. Thanks in advance for your help.
Sb= cp*m + cp*m*m(+1) + cp*m*m(+1)*m(+2) + m*m(+1)*m(+2);