Subscripted assignment dimension mismatch

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.

Subscripted assignment dimension mismatch

Postby mktlkez » Tue Jun 22, 2010 3:43 pm

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?
mktlkez
 
Posts: 13
Joined: Tue Jun 22, 2010 3:35 pm

Re: Subscripted assignment dimension mismatch

Postby jpfeifer » Wed Jun 23, 2010 8:01 am

Hi,
could you please post the model 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: Subscripted assignment dimension mismatch

Postby mktlkez » Wed Jun 23, 2010 8:41 am

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.
Attachments
System06_16_10.m
(1.32 KiB) Downloaded 188 times
Loop06_16_10.m
(1.15 KiB) Downloaded 182 times
Attempt06_16_10.mod
(2.38 KiB) Downloaded 195 times
mktlkez
 
Posts: 13
Joined: Tue Jun 22, 2010 3:35 pm

Re: Subscripted assignment dimension mismatch

Postby jpfeifer » Thu Jun 24, 2010 5:14 am

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.
------------
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: Subscripted assignment dimension mismatch

Postby mktlkez » Thu Jun 24, 2010 6:53 pm

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);"
mktlkez
 
Posts: 13
Joined: Tue Jun 22, 2010 3:35 pm

Re: Subscripted assignment dimension mismatch

Postby mktlkez » Mon Jun 28, 2010 7:15 am

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?
mktlkez
 
Posts: 13
Joined: Tue Jun 22, 2010 3:35 pm

Re: Subscripted assignment dimension mismatch

Postby jpfeifer » Mon Jun 28, 2010 8:10 am

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.
------------
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: Subscripted assignment dimension mismatch

Postby mktlkez » Mon Jun 28, 2010 9:14 am

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);
mktlkez
 
Posts: 13
Joined: Tue Jun 22, 2010 3:35 pm

Re: Subscripted assignment dimension mismatch

Postby mktlkez » Mon Jun 28, 2010 9:55 pm

For anyone interested, I ran it using empirical moments instead of theoretical moments and--tentatively-- have got no errors.
mktlkez
 
Posts: 13
Joined: Tue Jun 22, 2010 3:35 pm

Re: Subscripted assignment dimension mismatch

Postby jpfeifer » Tue Jun 29, 2010 7:57 am

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.
------------
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: Subscripted assignment dimension mismatch

Postby mktlkez » Tue Jun 29, 2010 2:55 pm

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.
mktlkez
 
Posts: 13
Joined: Tue Jun 22, 2010 3:35 pm

Re: Subscripted assignment dimension mismatch

Postby mktlkez » Thu Jul 01, 2010 7:37 am

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) ;

>>
mktlkez
 
Posts: 13
Joined: Tue Jun 22, 2010 3:35 pm

Re: Subscripted assignment dimension mismatch

Postby jpfeifer » Thu Jul 01, 2010 10:56 am

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?
------------
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: Subscripted assignment dimension mismatch

Postby mktlkez » Thu Jul 01, 2010 11:07 am

It isn't an interest rate, just a storage without depreciation. It is a closed economy.
mktlkez
 
Posts: 13
Joined: Tue Jun 22, 2010 3:35 pm

Re: Subscripted assignment dimension mismatch

Postby jpfeifer » Thu Jul 01, 2010 11:21 am

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?
------------
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

Next

Return to Dynare help

Who is online

Users browsing this forum: No registered users and 13 guests