Subscripted assignment dimension mismatch

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?

Hi,
could you please post the model file?

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.
System06_16_10.m (1.32 KB)
Loop06_16_10.m (1.15 KB)
Attempt06_16_10.mod (2.38 KB)

The reason is that for D>0.66 the Blanchard-Kahn conditions are not satisfied. To see this, put a

immediately behind the

command.

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

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?

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.

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

For anyone interested, I ran it using empirical moments instead of theoretical moments and–tentatively-- have got no errors.

Hi,
I am sorry, but with D=.64, exponent=-2, and order=1 I get the following message:

[quote]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 [/quote]

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

[quote]??? Error using ==> rdivide
Matrix dimensions must agree.

Error in ==> th_autocovariances at 162
Gamma_y{nar+2}(stationary_vars,i) = Gamma_y{nar+ …[/quote]

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.

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.

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

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?

It isn’t an interest rate, just a storage without depreciation. It is a closed economy.

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?

There is a fixed stock of 1 unit of money in the economy, which may be held by either firms or consumers. Introducing depreciation would move the steady state to a point of 0 money stock.

Probably you should take a look into Schmitt-Grohe/Uribes “Closing small open economy models” (econ.duke.edu/~grohe/research/closing_jie.pdf). The problem of non-stationarity of asset holdings in small open economies seems to be related to your problem. They show different modeling options to close the model and render it stationary.

Thanks for your suggestions. I ended up getting rid of the unit root by putting a 10^-4 tax on money, rebating it lump sum to agents. I compared the resulting theoretical moments with the simulated moments in the model without the tax (and hence with the unit root) and found they were almost identical. I think this may be a case in which the simulated moments are in fact correct. For now I’m sticking with the theoretical moments because they take significantly less CPU time.

The remaining question is about the 3rd order expansion. It isn’t working on my Mac. When I specify order 3 I get this message

ERROR: When using option ‘k_order_solver’ (which is implicit if order >= 3), you must specify option ‘use_dll’ on the ‘model’ block

when I change “model;” to “model(use_dll);” I get

/Applications/MATLAB_R2009b.app/bin/mex: line 1107: gcc-4.0: command not found
/Applications/MATLAB_R2009b.app/bin/mex: line 997: gcc-4.0: command not found

Any guesses what’s going on?

Good morning Mr Jpfeifer .First I would like to wish you happy new year , then I would like to ask you about an error in dynare that I meet …I read many messages in dynare that are like this problem but I could not solve the issue .Here is my mod file and my data.Can you help me?
Sorry for disturbing you again Mr jpfeifer .

??? Subscripted assignment dimension mismatch.

Error in ==> read_variables at 79
dyn_data_01(:,dyn_i_01) = dyn_tmp_01;

Error in ==> initialize_dataset at 32
rawdata = read_variables(datafile,varobs,],xls.sheet,xls.range);

Error in ==> dynare_estimation_init at 477
dataset_ = initialize_dataset(options_.datafile,options_.varobs,options_.first_obs,options_.nobs,transformation,options_.prefilter,xls);

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

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

Error in ==> article4 at 365
dynare_estimation(var_list_);

Error in ==> dynare at 174
evalin(‘base’,fname) ;
data2.m (10.3 KB)
article4.mod (5.45 KB)

Your datafile erroneously uses a comma as the decimal separator for some variables. When you execute your data file, some variables have dimension N by 2 instead of N by 1 because of this.