Page 1 of 1

k_order_perturbation error

PostPosted: Sun Mar 23, 2014 5:00 pm
by magonfru
Hi guys, I am trying to replicate the paper "Risk Matters: The Real Effects of Volatility Shocks" by Fernandez-Villaverde et al. I get following message:
dynare:k_order_perturbation: Caught Kord exception: NaN or Inf asserted in first order derivatives in FirstOrder::solve
Error using print_info (line 68)
k_order_pert was unable to compute the solution
Error in stoch_simul (line 98)
print_info(info, options_.noprint, options_);
Error in dsge_risks2 (line 275)
info = stoch_simul(var_list_);
Error in dynare (line 180)
evalin('base',fname) ;
I don't know what it meas nor where to start looking on how to solve it
any help would be deeply appreciated

Re: k_order_perturbation error

PostPosted: Fri Apr 11, 2014 12:36 pm
by joff
I have the same problem. Was you able to solve it at the end?

Re: k_order_perturbation error

PostPosted: Fri Apr 11, 2014 12:48 pm
by jpfeifer
Make sure it runs at order=1. For the posted file, model_diagnostics says:
MODEL_DIAGNOSTICS: The Jacobian of the static model is singular
MODEL_DIAGNOSTICS: there is 1 colinear relationships between the variables and the equations
Colinear variables:
d
k
i
Colinear equations
3 4 6

MODEL_DIAGNOSTICS: The presence of a singularity problem typically indicates that there is one
MODEL_DIAGNOSTICS: redundant equation entered in the model block, while another non-redundant equation
MODEL_DIAGNOSTICS: is missing. The problem often derives from Walras Law.

Re: k_order_perturbation error

PostPosted: Tue May 06, 2014 3:26 pm
by jpfeifer
Replicating the paper is hard. See the comment at http://www.dynare.org/wp-repo/dynarewp039.pdf. A rudimentary form of the model can be found at https://github.com/DynareTeam/dynare/blob/master/tests/decision_rules/third_order/FV2011.mod
Note that the particular IRF generation and pruning used in the original paper is not supported by Dynare.

Re: k_order_perturbation error

PostPosted: Sat Jul 19, 2014 12:57 am
by slucyp
jpfeifer wrote:Replicating the paper is hard. See the comment at http://www.dynare.org/wp-repo/dynarewp039.pdf. A rudimentary form of the model can be found at https://github.com/DynareTeam/dynare/blob/master/tests/decision_rules/third_order/FV2011.mod
Note that the particular IRF generation and pruning used in the original paper is not supported by Dynare.


Hi, I also what to find how to get the IFRs using the third-order perturbation method, that's why I tried the code of FV2011.mod,

But I got the error message in the dynare..:
"
Attempt to execute SCRIPT k_order_perturbation as a function:
C:\dynare\4.4.2\matlab\k_order_perturbation.m

Error in k_order_pert (line 57)
[err, g_0, g_1, g_2, g_3, derivs] = k_order_perturbation(dr, ...

Error in stochastic_solvers (line 74)
[dr,info] = k_order_pert(dr,M_,options_);

Error in resol (line 137)
[dr,info] = stochastic_solvers(dr,check_flag,M,options,oo);

Error in stoch_simul (line 88)
[oo_.dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);

Error in FV2011 (line 285)
info = stoch_simul(var_list_);

Error in dynare (line 180)
evalin('base',fname) ;
"

could you tell me what is wrong here??

Thank u...!!

Re: k_order_perturbation error

PostPosted: Sun Jul 20, 2014 7:02 am
by jpfeifer
There is a problem in finding the mex-files. Check if your paths are set correctly. You may also want to try reinstalling Dynare. Also check whether you followed all instructions regarding the mex-files if you are not using a system with precompiled mex-files. If nothing works, please report back with the operating system version and your Matlab/Octave version.

Re: k_order_perturbation error

PostPosted: Mon Jul 21, 2014 1:32 pm
by slucyp
jpfeifer wrote:There is a problem in finding the mex-files. Check if your paths are set correctly. You may also want to try reinstalling Dynare. Also check whether you followed all instructions regarding the mex-files if you are not using a system with precompiled mex-files. If nothing works, please report back with the operating system version and your Matlab/Octave version.


Thank you very much!!!
Now it works.. but the result seems limited, and the IRFs didn't show up... so what if I want to know the IRFs of each variable, especially for the volatility shock??

Or is my result like the way it should be??

The final reported result is like this:
Residuals of the static equations:

Equation number 1 : 0
Equation number 2 : 0
Equation number 3 : 0
Equation number 4 : 0
Equation number 5 : 0
Equation number 6 : 0
Equation number 7 : 0
Equation number 8 : 0
Equation number 9 : 0
Equation number 10 : 0
Equation number 11 : 0
Equation number 12 : 0
Equation number 13 : 0
Equation number 14 : 0



STEADY-STATE RESULTS:

sigma_r -5.71
sigma_tb -8.06
eps_r 0
eps_tb 0
X 0
D 4
K 3.29328
lambda -4.38974
C 0.877949
H -0.00372037
Y 1.05132
I -0.975418
phi -4.38974
r -3.91202

EIGENVALUES:
Modulus Real Imaginary

0.94 0.94 0
0.94 0.94 0
0.95 0.95 0
0.95 0.95 0
0.9698 0.9693 0.0331
0.9698 0.9693 -0.0331
0.97 0.97 0
0.9921 0.9921 0
1.028 1.028 0
1.052 1.051 0.0359
1.052 1.051 -0.0359
2.901e+16 2.901e+16 0


There are 4 eigenvalue(s) larger than 1 in modulus
for 4 forward-looking variable(s)

The rank condition is verified.


MODEL SUMMARY

Number of variables: 14
Number of stochastic shocks: 5
Number of state variables: 8
Number of jumpers: 4
Number of static variables: 3


MATRIX OF COVARIANCE OF EXOGENOUS SHOCKS

Variables u_sigma_r u_sigma_tb u_r u_tb u_x
u_sigma_r 1.000000 0.000000 0.000000 0.000000 0.000000
u_sigma_tb 0.000000 1.000000 0.000000 0.000000 0.000000
u_r 0.000000 0.000000 1.000000 0.000000 0.000000
u_tb 0.000000 0.000000 0.000000 1.000000 0.000000
u_x 0.000000 0.000000 0.000000 0.000000 1.000000


ans =

2.8304e-10

Total computing time : 0h00m04s

Is it reasonable??

Thank you so much!!

Re: k_order_perturbation error

PostPosted: Wed Jul 23, 2014 8:36 am
by jpfeifer
If you set
Code: Select all
irf=0

in stoch_simul, you are suppressing the IRFs. You need to set it higher. Also note that Dynare does not support the IRFs from the EMAS, but only GIRFS. You will need to increase the replications.

Re: k_order_perturbation error

PostPosted: Fri Jul 25, 2014 6:52 am
by slucyp
jpfeifer wrote:If you set
Code: Select all
irf=0

in stoch_simul, you are suppressing the IRFs. You need to set it higher. Also note that Dynare does not support the IRFs from the EMAS, but only GIRFS. You will need to increase the replications.


Thank you! Jpfeifer! It helps a lot!^^

Re: k_order_perturbation error

PostPosted: Sat Aug 02, 2014 3:43 am
by J.Höffler
There is a page about this study in the ReplicationWiki, could you contribute to it?
http://replication.uni-goettingen.de/wiki/index.php/Risk_Matters:_The_Real_Effects_of_Volatility_Shocks_(AER_2011)

Re: k_order_perturbation error

PostPosted: Sat Sep 13, 2014 10:42 am
by jpfeifer
We added the study to the replication wiki. Moreover, replication code is now available at my homepage: https://sites.google.com/site/pfeiferecon/research

Re: k_order_perturbation error

PostPosted: Tue Oct 28, 2014 11:33 pm
by hewei2004
I have a similar question, why does the replication of this paper by Villaverde would create a colinear equation?
I also want to replicate some similar international paper with order 2, and I get the same error with colinear equation.
Is it a bug in mod file or limitation of dynare?

Re: k_order_perturbation error

PostPosted: Wed Oct 29, 2014 9:57 am
by jpfeifer
As I said, the mod-file of the original poster is wrong. The correct one available in the replication files to Born/Pfeifer (2014): "Risk Matters: A comment" at https://sites.google.com/site/pfeiferecon/20140525_replication_codes.zip?attredirects=0 does not have a collinearity issue.