Index Exceeds Matrix Dimensions

Hi,

I am currently trying to work on an optimal Ramsey policy for the model in Dynare. I tried using Taylor rule for the same model and the results looked fine with no residuals. The problem now is that when I try to find the optimal Ramsey policy with single instrument(Inflation), I get the following error:

Index exceeds matrix dimensions.

Error in btl_old_ramsey_static (line 168)
residual(1) =
params(43)T11T27^(1-params(12))-params(52)T34params(43)*getPowerDeriv(params(43)*y(1),1+params(11),1)+params(43)y(61)+y(45)(-(params(23)*params(43)*y(11)))+y(43)T54+T54y(40);

Error in evaluate_static_model (line 63)
residuals = feval(fh_static,ys,exo_ss,params);

Error in evaluate_steady_state_file (line 133)
[residuals, check] = evaluate_static_model(ys, exo_ss, params, M, options);

Error in evaluate_steady_state (line 59)
[ys,params,info] = evaluate_steady_state_file(ys_init,exo_ss,M, …

Error in resol (line 104)
[dr.ys,M.params,info] =
evaluate_steady_state(oo.steady_state,M,options,oo,~options.steadystate.nocheck);

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

Error in ramsey_policy (line 42)
info = stoch_simul(var_list);

Error in btl_old_ramsey (line 720)
ramsey_policy(var_list_);

Error in dynare (line 223)
evalin(‘base’,fname) ;

As I already have a steady state file from the Taylor rule, I tried using the same steady state file which didn’t work and also the second alternative-
I tried giving the numerical guess values of all the endogenous variables in the initial block and I got the same error. Can anyone please explain which matrix it refers to when it shows “Index exceeds matrix dimension”?

Thank you
Ruthvik

Are you using Dynare 4.5?

Dear Professor,

Thank you for your prompt reply. I am using Dynare 4.5.3 build.

Regards,
Ruthvik

Then I would need to see the files.

Dear Professor,

Sorry for a late reply, I want to make sure everything is good and rechecked it.

Please find the attached steady sate files and .mod file.

btl_old_ramsey_steadystate.m (3.3 KB)
BTL_I_NSS.m (2.0 KB)
btl_old_ramsey.mod (7.8 KB)

Regards,
Ruthvik

Your steady state file is wrong. It does not return a properly sized vector. The reason is that you have a strange conditioning that

if isfield(M_,'orig_endo_nbr') == 1
NumberOfEndogenousVariables = M_.orig_endo_nbr;
else
NumberOfEndogenousVariables = M_.endo_nbr;
end

But ys should always have length M_.endo_nbr

Dear Johannes,

Thank you for a reply, I used the standard steady state file from Dynare forum to get the vector and it worked fine with Taylor rule, Now I tried to change the vector from where the ys are taken, A new error prompted stating

Error using print_info (line 156)
Ramsey: The maximum number of iterations has been reached. Try increasing maxit.

Error in stoch_simul (line 100)
print_info(info, options_.noprint, options_);

Error in ramsey_policy (line 42)
info = stoch_simul(var_list);

Error in btl_old_ramsey (line 720)
ramsey_policy(var_list_);

Error in dynare (line 223)
evalin(‘base’,fname) ;

Can you please explain the cause of the error and is there any problem with the conditional stead state file?

Thanks and Regards,
Ruthvik

I would need to see the file

Dear Johannes,

Please find the attached files, Also I chose the case of NumberOfEndogenousVariables = M_.orig_endo_nbr; where auxiliary variables are set automatically as I have a different error while I set the NumberOfEndogenousVariables = M_.endo_nbr

Error using eval
Undefined function or variable ‘MULT_1’.

Error in btl_old_ramsey_steadystate (line 163)
eval([‘ys(’ int2str(ii) ') = ’ varname ‘;’]);

Error in evaluate_steady_state_file (line 52)
[ys,check] = h_steadystate(ys_init, exo_ss);

Error in evaluate_steady_state (line 59)
[ys,params,info] = evaluate_steady_state_file(ys_init,exo_ss,M, …

Error in resol (line 104)
[dr.ys,M.params,info] =
evaluate_steady_state(oo.steady_state,M,options,oo,~options.steadystate.nocheck);

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

Error in ramsey_policy (line 42)
info = stoch_simul(var_list);

Error in btl_old_ramsey (line 720)
ramsey_policy(var_list_);

Error in dynare (line 223)
evalin(‘base’,fname) ;

btl_old_ramsey_steadystate.m (3.1 KB)
btl_old_ramsey.mod (7.8 KB)
BTL_I_NSS.m (2.0 KB)
Check_old_ramsey.m (7.5 KB)

Hi,
I am attaching a corrected steady state file. The problem is that even with your correct conditional steady state file the steady state for the Ramsey problem cannot be found. Are you sure a steady state exists?

btl_old_ramsey_steadystate.m (3.2 KB)