Page 1 of 1

Steady state file- problem with fsolve

PostPosted: Tue Feb 28, 2017 11:05 am
by georam11
Dear Prof Pfeifer,

I have tried to incorporate the DMP framework to asset pricing model. Solving for the steady state is not possible analytically, hence i wrote a steady state.m file.

I have attached both the m file and mod file. Fsolve does not seem to solve my highly non linear equation to get theta_t. Please could you explain how to give the initial value under fsolve for the attached m file?

Looking forward to your reply.

Many Thanks
Ammu

Re: Steady state file- problem with fsolve

PostPosted: Tue Feb 28, 2017 11:49 am
by jpfeifer
What do you mean? You are already providing an initial value. In
Code: Select all
[theta_t,fval,exitflag]=fsolve(@(theta_t)(exp(m+dn)*((1-s)+(((exp(k_h1t)*(1+exp(iota*theta_t))^(1/iota))+exp(k_h2t))^(-1))*(((1-eta)*(1-epsitlon)*(1-alphat)*exp(alphat*(log((delta-1+exp(-m))/(((epsitlon*nu)^(epsitlon/(1-epsitlon)))*(1-epsitlon)*alphat*exp((a+log((1+s*(1+exp(-iota*theta_t))^(-1/iota))))*(1-alphat))))/(alphat-1)-log((1+s*(1+exp(-iota*theta_t))^(-1/iota)))))*exp((1-alphat)*a)*((epsitlon*nu)^(epsitlon/(1-epsitlon))))-eta*(exp(k_h1t+theta_t)+ (exp(k_h2t)/((1+exp(-iota*theta_t))^(1/iota))))-(1-eta)*exp(bt))))-1,log(2),options);

it's the
Code: Select all
log(2)

Re: Steady state file- problem with fsolve

PostPosted: Mon Mar 06, 2017 6:44 am
by georam11
Hello Prof Pfeifer,

Sorry if my question was not clear.

I tried giving some random initial values in the above code to see if I would be able to solve for a steady state value for theta_t.

However, I was unable to solve for theta_t. So I am asking if there is a methodology where I can give an initial value instead of log(2) to help me solve the equation?

Many Thanks
Ammu

Re: Steady state file- problem with fsolve

PostPosted: Tue Mar 07, 2017 12:15 pm
by jpfeifer
What you can always do is check for the
Code: Select all
exitflag

and add an if-clause that tries to solve the equation with a different starting value whenever the exitflag>0 (which should be the error codes.)