How do I debug my code?..and make sense of this error msg.

This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location where you will have to reset your password.
Forum rules
This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location (https://forum.dynare.org) where you will have to reset your password.

How do I debug my code?..and make sense of this error msg.

Postby mknomics » Wed Oct 24, 2012 1:59 am

Does anyone know the best way to decipher error messages in dynare? Currently I am getting the message below and it's been tough to identify the problem.

***********************************************************************
NOTE:
The problem materializes in the "__static.m" file.

Through debugging in Matlab I have determined that the variable T166 is empty and being multiplied by y(24) which is a vector of zeros which gives an empty vector lhs. rhs is [1X1] NAN. Thus the error.

lhs =y(24)*T166;
rhs =T56*T159*y(30)*params(3);

Most residuals are NAN because a majority of "T" variables are NAN, Inf, zero or 1.

Does anyone know what this might mean?

*****************************************************************
ACTUAL ERROR MESSAGE


??? In an assignment A(I) = B, the number of elements in B and
I must be the same.

Error in ==> Full4_static at 97
residual(14)= lhs-rhs;

Error in ==> dynare_solve at 83
[fvec,fjac] = feval(func,x,varargin{:});

Error in ==> evaluate_steady_state at 66
[ys,check] = dynare_solve([M.fname '_static'],...

Error in ==> dynare_estimation_init at 341
oo_.steady_state =
evaluate_steady_state(oo_.steady_state,M,options_,oo_,steadystate_check_flag);

Error in ==> dynare_estimation_1 at 59
[dataset_,xparam1, M_, options_, oo_, estim_params_,bayestopt_] =
dynare_estimation_init(var_list_, dname, [], M_, options_, oo_,
estim_params_, bayestopt_);

Error in ==> dynare_estimation at 70
dynare_estimation_1(var_list,dname);

Error in ==> Full4 at 859
dynare_estimation(var_list_);

Error in ==> dynare at 120
evalin('base',fname) ;
mknomics
 
Posts: 10
Joined: Wed Aug 08, 2012 10:04 pm

Re: How do I debug my code?..and make sense of this error ms

Postby mknomics » Wed Oct 24, 2012 6:28 am

Also, I have been getting error messages that tell me that my numerical initial values are incompatible with equation #'s .... but I don't know how to make sense of the equation numbers in the steady state file. I can find the equations but they have some T and Y variables that I can't make sense of? How do I track down what y(#) is pointing toward?
mknomics
 
Posts: 10
Joined: Wed Aug 08, 2012 10:04 pm

Re: How do I debug my code?..and make sense of this error ms

Postby jpfeifer » Wed Oct 24, 2012 6:27 pm

The equation numbers refer to the equations in the model-block. Usually it means that in this equation you are dividing by 0. Are you using 4.3.1? If yes, please post the mod-file.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: How do I debug my code?..and make sense of this error ms

Postby mknomics » Thu Oct 25, 2012 2:38 am

Hi there,

I am using the current version of dynare. The files attached are written written for the paper Schmitt-Grohe and Uribe Econometrica 2012 "Whats News in Business Cycles".

Any help is greatly appreciated. Thanks again for reaching out.
Attachments
Economet.xls
Data set. values are in differences of logs.
(45 KiB) Downloaded 98 times
Full4.mod
To be run with Economet.xls
(6.86 KiB) Downloaded 110 times
mknomics
 
Posts: 10
Joined: Wed Aug 08, 2012 10:04 pm

Re: How do I debug my code?..and make sense of this error ms

Postby mknomics » Thu Oct 25, 2012 11:20 pm

I have made some changes and have attached current files.

What is the best systematic way for evaluating the mod file?

So far I have

1) Used the Matlab variable editor to discover NAN values in the bayestopt_

Then I looked up the names corresponding to the parameter number in order to identify problem parameters by name, which allowed me to find the line in the mod file which contained the error.

2) I repeated this process for M.params and noticed that estimated variables have NAN (I'm not sure if this is a problem?)

3) I noticed that J-scale has a full vector of NAN

Current unresolved questions:
1) estim_params_ contains two matrices that have scattered values of NAN and real numbers. I can't make a correspondence with this matrix and my model?

2) How can I fix this error, "Prior distribution for parameter RHOz has two modes!"

3) I don't understand how to resolve the problems listed in the error below. A systematic strategy would be greatly appreciated.

Thanks for helping me debug my first program.

The current error message that I am getting is the following

*********************************************************************************
STEADY: numerical initial values incompatible with the following equations
1 2 5 6 7 8 9 10 11 12 13 14 15 16 17 25 43
Please check for example
i) if all parameters occurring in these equations are defined
ii) that no division by an endogenous variable initialized to 0 occurs
??? Error using ==> dynare_solve at 98
exiting ...

Error in ==> evaluate_steady_state at 66
[ys,check] = dynare_solve([M.fname '_static'],...

Error in ==> dynare_estimation_init at 366
[oo_.steady_state, params] = evaluate_steady_state(oo_.steady_state,M,options_,oo_,steadystate_check_flag);

Error in ==> dynare_estimation_1 at 59
[dataset_,xparam1, M_, options_, oo_, estim_params_,bayestopt_] = dynare_estimation_init(var_list_, dname, [], M_, options_, oo_, estim_params_,
bayestopt_);

Error in ==> dynare_estimation at 70
dynare_estimation_1(var_list,dname);

Error in ==> Full4 at 858
dynare_estimation(var_list_);

Error in ==> dynare at 120
evalin('base',fname) ;
Attachments
Full4.mod
(7.91 KiB) Downloaded 93 times
Last edited by mknomics on Thu Oct 25, 2012 11:22 pm, edited 1 time in total.
mknomics
 
Posts: 10
Joined: Wed Aug 08, 2012 10:04 pm

Re: How do I debug my code?..and make sense of this error ms

Postby jpfeifer » Fri Oct 26, 2012 6:54 am

Before estimating, make sure, you can simulate your model. That means in particular: define all(!) parameters properly before the model-block. That includes the autoregressive parameters!
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: How do I debug my code?..and make sense of this error ms

Postby mknomics » Fri Oct 26, 2012 10:26 pm

Thanks for the direction.

My simulation didn't run. The error takes place in the cond.m file. Specifically, the scalar value A takes on a fraction between zero and one, before being bounced back and forth between cond.m and dynare_solve.m where after several loops, fjac suddenly blows up to inf causing A to go to inf.

The Jacobian is poorly conditioned from the begining (bad_cond_flag=1). I'm not sure if this is because of poor starting values or from something more structural?

The .mod file for the simulation is attached and the error code that it produces is pasted below.

********************************************************************
Error code:

STEADY: numerical initial values incompatible with the following equations
10
??? Error using ==> svd
Input to SVD must not contain NaN or Inf.

Error in ==> cond at 39
s = svd(A);

Error in ==> solve1 at 118
elseif bad_cond_flag && cond(fjac) > 1/sqrt(eps)

Error in ==> dynare_solve at 128
[x,info]=solve1(func,x,j1(r(i):r(i+1)-1),j2(r(i):r(i+1)-1),jacobian_flag,
bad_cond_flag, varargin{:});

Error in ==> evaluate_steady_state at 66
[ys,check] = dynare_solve([M.fname '_static'],...

Error in ==> resol at 108
[dr.ys,M.params,info] =
evaluate_steady_state(oo.steady_state,M,options,oo,0);

Error in ==> stoch_simul at 76
[oo_.dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);

Error in ==> sim1 at 1013
info = stoch_simul(var_list_);

Error in ==> dynare at 120
evalin('base',fname) ;
Attachments
sim1.MOD
Simulation File
(7.45 KiB) Downloaded 98 times
mknomics
 
Posts: 10
Joined: Wed Aug 08, 2012 10:04 pm

Re: How do I debug my code?..and make sense of this error ms

Postby jpfeifer » Mon Oct 29, 2012 8:16 am

This might be a bug. Could you try 4.2.5?
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: How do I debug my code?..and make sense of this error ms

Postby mknomics » Mon Oct 29, 2012 9:45 pm

I uninstalled the current version and installed 4.2.5. The error message is virtually the same. Any suggestions on what I should do next? Thanks again for giving me direction.
mknomics
 
Posts: 10
Joined: Wed Aug 08, 2012 10:04 pm

Re: How do I debug my code?..and make sense of this error ms

Postby jpfeifer » Tue Oct 30, 2012 7:43 am

I have only one suggestion: Compute the steady state with pen and paper. Also, put resid(1) before steady to see that your starting values are poor. You must get closer to the true values.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: How do I debug my code?..and make sense of this error ms

Postby MichelJuillard » Tue Oct 30, 2012 4:57 pm

The problem is that mua and mux are defined as zero mean autocorrelated processes, but then enter directly the non-linear equations where zero is not an acceptable value. You probably want exp(mua) and exp(mux) in the non-linear equations, but check carefully.

Best

Michel
MichelJuillard
 
Posts: 680
Joined: Thu Nov 18, 2004 10:51 am

Re: How do I debug my code?..and make sense of this error ms

Postby mknomics » Thu Nov 01, 2012 7:15 pm

Thank you for the thoughtful responses. I am taking a moment to pause and consider this model more carefully.

It is inspirational to be the beneficiary in this benevolent forum. Hopefully, I will be in a position in the future to contribute more than questions!
mknomics
 
Posts: 10
Joined: Wed Aug 08, 2012 10:04 pm


Return to Dynare help

Who is online

Users browsing this forum: No registered users and 5 guests