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.
Dear Jpfeifer,
I think you missed the last term which does not involve cp. i am struggling to code this last term, i tried the following for k = 2 for which I know the steady state result. Still in a blind alley. I think the last loop term s computing m+mm(+1)+mm(+1)m(+2) while I want to compute mm(+1)*m(+2). I don’t know the syntax for it, I guess.
Sb=cp*m
@# for lead in 1:2
+cp
@#for prod_lead in 0:lead
*m(@{prod_lead})
@# for lead in 1:2
+ m
@#for prod_lead in 0:lead
*m(@{prod_lead})
@# endfor
@# endfor
@# endfor
;
@#define J=2
Sb=cp*m
@# for lead in 1:J
+cp
@#for prod_lead in 0:lead
*m(@{prod_lead})
@# endfor
@# endfor
+ m
@# for prod_lead in 1:J
*m(@{prod_lead})
@# endfor
;
Error using print_info (line 83)
Impossible to find the steady state. Either the model doesn’t have a steady state, there are an infinity of steady states, or the guess
values are too far from the solution
Error in check (line 76)
print_info(info, 0, options);
Error in gwloop (line 344)
oo_.dr.eigval = check(M_,options_,oo_);
Error in dynare (line 223)
evalin(‘base’,fname) ;
In this code I am trying to replicate the Putty-Clay non-linear model of Glichrist-Williams with zero-growth and first setting M=2.
This seems like a problem unrelated to the Macro-processor. Does the model work if you hardcode the equation for M=2, i.e. before moving to a generalizable code?
Yes the model works when I hardcode the equation for M=2. If I keep the same steady state system (as in the hardcode) and just generalize the model, I should still get the code running as long as M=2, correct? I seem to fail there, which makes me think that maybe I didn’t write the macro correctly…
Attached are my two models (hardcode and generalized)