Page 1 of 2
Subscripted assignment dimension mismatch
Posted:
Tue Jun 22, 2010 3:43 pm
by mktlkez
I'm trying to use stoch_simul to solve a model, getting a bevy of error messages (which message I get depends on whether I use first or second order approximation).
1st order errors:
After calculating policy functions, it displays theoretical moments, most of which are NaN, then a variance decomposition for one variable, then the following error messages:
??? Subscripted assignment dimension mismatch.
Error in ==> disp_th_moments at 105
z(:,i) = diag(oo_.gamma_y{i+1}(i1,i1));
Error in ==> stoch_simul at 73
disp_th_moments(oo_.dr,var_list);
For second order, I get to the same point in the process but instead get the following errors:
??? Error using ==> rdivide
Matrix dimensions must agree.
Error in ==> th_autocovariances at 162
Gamma_y{nar+2}(stationary_vars,i) = Gamma_y{nar+ ...
Error in ==> disp_th_moments at 37
[oo_.gamma_y,stationary_vars] = th_autocovariances(dr,ivar,M_,options_);
Error in ==> stoch_simul at 73
disp_th_moments(oo_.dr,var_list);
Any ideas what's going on or how to fix it?
Re: Subscripted assignment dimension mismatch
Posted:
Wed Jun 23, 2010 8:01 am
by jpfeifer
Hi,
could you please post the model file?
Re: Subscripted assignment dimension mismatch
Posted:
Wed Jun 23, 2010 8:41 am
by mktlkez
Attached are three files: the Dynare code, the system I use to solve for the initial conditions, and a loop file I use to call the whole thing using various parameters. Ideally I'd like exponent=-2, but things seem to work better with -1. When I set D=.66 everything works, but I get errors when I try D=.67 or above.
Thanks.
Re: Subscripted assignment dimension mismatch
Posted:
Thu Jun 24, 2010 5:14 am
by jpfeifer
The reason is that for D>0.66 the Blanchard-Kahn conditions are not satisfied. To see this, put a
- Code: Select all
check;
immediately behind the
- Code: Select all
steady;
command.
Re: Subscripted assignment dimension mismatch
Posted:
Thu Jun 24, 2010 6:53 pm
by mktlkez
When I use "check" with D=.67 (or .33 for that matter), it tells me:
"There are 5 eigenvalue(s) larger than 1 in modulus
for 5 forward-looking variable(s)
The rank condition is verified."
then below still gives:
"??? Error using ==> rdivide
Matrix dimensions must agree.
Error in ==> th_autocovariances at 162
Gamma_y{nar+2}(stationary_vars,i) = Gamma_y{nar+ ...
Error in ==> disp_th_moments at 37
[oo_.gamma_y,stationary_vars] = th_autocovariances(dr,ivar,M_,options_);
Error in ==> stoch_simul at 73
disp_th_moments(oo_.dr,var_list);"
Re: Subscripted assignment dimension mismatch
Posted:
Mon Jun 28, 2010 7:15 am
by mktlkez
I've upgraded to 4.1.2 and still get the same set of errors. There are some parameter values for which the BK conditions are not satisfied, but many for which they are and I just get what appear to be runtime errors. Any other ideas?
Re: Subscripted assignment dimension mismatch
Posted:
Mon Jun 28, 2010 8:10 am
by jpfeifer
Hi, could it be that your model is not stationary? Apparently, sometimes one eigenvalue is exactly 1. If this happens, I get the error messages you describe, too. The resulting error is natural as the second moments you are trying to compute are not finite. You can see this as the variances are NaN.
Re: Subscripted assignment dimension mismatch
Posted:
Mon Jun 28, 2010 9:14 am
by mktlkez
The model should be stationary for epsilon>0. The rdivide error is coming up before any moments are calculated/displayed. With D=.64, exponent=-2, and order=1, it stops immediately after displaying the transition function:
??? Error using ==> rdivide
Matrix dimensions must agree.
Error in ==> th_autocovariances at 162
Gamma_y{nar+2}(stationary_vars,i) = Gamma_y{nar+ ...
Error in ==> disp_th_moments at 37
[oo_.gamma_y,stationary_vars] = th_autocovariances(dr,ivar,M_,options_);
Error in ==> stoch_simul at 73
disp_th_moments(oo_.dr,var_list);
Re: Subscripted assignment dimension mismatch
Posted:
Mon Jun 28, 2010 9:55 pm
by mktlkez
For anyone interested, I ran it using empirical moments instead of theoretical moments and--tentatively-- have got no errors.
Re: Subscripted assignment dimension mismatch
Posted:
Tue Jun 29, 2010 7:57 am
by jpfeifer
Hi,
I am sorry, but with D=.64, exponent=-2, and order=1 I get the following message:
There are 5 eigenvalue(s) larger than 1 in modulus
for 5 forward-looking variable(s)
The rank condition is verified.
??? Error using ==> print_info at 39
Blanchard Kahn conditions are not satisfied: no stable equilibrium
Error in ==> stoch_simul at 46
print_info(info, options_.noprint);
Error in ==> Attempt06_16_10 at 231
info = stoch_simul(var_list_);
Error in ==> dynare at 132
evalin('base',fname) ;
Error in ==> Loop06_16_10 at 64
dynare Attempt06_16_10.mod
This indicates that the check-command succeeds but the BK-conditions are not satisfied in the stoch_simul-command.
Moreover, I checked other cases and the problem really seems to be that the model is not stationary. At least, internally the vector "stationary_vars" is empty when the error
??? Error using ==> rdivide
Matrix dimensions must agree.
Error in ==> th_autocovariances at 162
Gamma_y{nar+2}(stationary_vars,i) = Gamma_y{nar+ ...
occurs. Try removing the unit root as there clearly is one eigenvalue exactly equal to 1. Note also that if the model is not stationary, the theoretical second moments do not exist. If you then use simulated moments based on a finite sample, the results will be wrong.
Re: Subscripted assignment dimension mismatch
Posted:
Tue Jun 29, 2010 2:55 pm
by mktlkez
Thanks. I'm not getting the same BK problem you're getting, but I do see where the unit root comes form (I think the m(+1)=m+... equation). I'll see if I can rewrite the model to get rid of that unit root. I appreciate the help.
Re: Subscripted assignment dimension mismatch
Posted:
Thu Jul 01, 2010 7:37 am
by mktlkez
As far as I can tell, the unit root is coming from the savings equation for m(+1) (with nominal interest rate 1, wealth tomorrow equals wealth today plus earnings minus spending), which is pretty standard in the literature. Is there a standard way of dealing with this? If I'm wrong about what is inducing the unit root, is there a way of figuring out which equation is producing the unitary eigenvalue?
I simulated the model for 50k periods and eyeballed each data series. According to the thoroughly scientific eyeball test, many of them are skewed and a few heavy-tailed, but none are explosive. Are there conditions under which Dynare will spuriously conclude the second moments don't exist?
Also just for fun I tried the new 3rd order expansion and got the following error (I'm on a Mac, and line 127 is in the initval specification section)
??? Error using ==> mex at 221
Unable to complete successfully.
Error in ==> Attempt06_16_10 at 127
eval('mex -O LDFLAGS=''-Wl,-twolevel_namespace -undefined error -arch \$ARCHS
-Wl,-syslibroot,\$SDKROOT -mmacosx-version-min=\$MACOSX_DEPLOYMENT_TARGET -bundle''
Inventories06_16_10_dynamic.c')
Error in ==> dynare at 132
evalin('base',fname) ;
>>
Re: Subscripted assignment dimension mismatch
Posted:
Thu Jul 01, 2010 10:56 am
by jpfeifer
Hi,
why should the gross nominal exchange rate be 1? With inflation, your real exchange rate would always be negative. One more question: is this your model a closed economy?
Re: Subscripted assignment dimension mismatch
Posted:
Thu Jul 01, 2010 11:07 am
by mktlkez
It isn't an interest rate, just a storage without depreciation. It is a closed economy.
Re: Subscripted assignment dimension mismatch
Posted:
Thu Jul 01, 2010 11:21 am
by jpfeifer
But as in cases without depreciation of physical capital, this seems to introduce a unit root into the model. What happens if you make storage minimally costly?