OS.driver error

Hello,

I have modified Collateral Shock model which is based on CMR model. The model is structured into following files:

  1. Baseline model
  2. Parameters for the baseline model
  3. Steady State file
  4. Data for estimation
  5. Data for steady-state ratios

When I am running the model file, I am getting the following error messages:

Preprocessing completed.

Error using print_info
Parameters have been updated in the steadystate routine and some are NaNs or Inf.

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

Error in OS.driver (line 939)
[info, oo_, options_, M_] = stoch_simul(M_, options_, oo_, var_list_);

Error in dynare (line 281)
evalin(‘base’,[fname ‘.driver’]);

I need help to understand what are above errors and how to resolve them.

Many thanks for help.

Regards,
Umer Ameen

It means that there must be a problem in your steady state file in setting the parameters.

Hello,

Thanks for the reply. I have checked all the solved steady state equations and the steady state files including the parameters.

All the parameters are same as estimated and calibrated in the original model of the Collateral Shocks except the following parameters which are explained.

Sx_p; oil investment adjustment cost. Its value is assumed same as the capital adjustment cost parameter Sk_p
w_p; weightage of oil relative to capital. This parameter value is assumed as per paper “Oil price shocks and US economic activity” by Nathan et. Al
v_p; elasticity of substitution between oil and capital. Assumed as in the above referred paper.
rhoepsilo_p; AR(1) oil shock experienced by downstream oil firms similar to technology shock. Hence, the value is same as rhoepsil_p (AR(1) for technology shock
stdepsilo_p; Variance of oil shock which is assumed same as variance of technology shock
rhozetaio_p; AR(1) Marginal efficiency of oil investment shock experienced by upstream oil firms similar to AR(1) marginal efficiency of investment shock experienced by the capital producer.
stdzetaio_p; variance of marginal efficiency of oil investment shock which is assumed same as variance of marginal efficiency of investment shock experienced by the capital producer

The steady state file is structured in the following blocks:

  • Initialize (Global variables & solver)
  • Shocks set to 1 except lambdap, lambdaw and muz which are set eaul to their parameter values
  • Auxiliary expressions
  • Straight forward equations
  • Solver for rk (rental rate of capital)
  • Production equations
  • Oil producer equations
  • Entrepreneur equations
  • Prices and wages equations
  • Banks
  • Observed equations
  • Percent deviation from steady state
  • wrapup (evaluation of parameters
  • If error during trying
  • Solve for omega e : Small grid

Please let me know how to resolve the errors. Many thanks for kind help.

Regards,
UA

But which parameters are NaN or Inf coming out of the steady state file?

Hello,

I have tried to find out the parameters which are NaN or Inf but not sure how to do it. The easiest way I found is to print the workspace which shows the parameters with issues. Please find attached the workspace.
Workspace.pdf (240.4 KB)

Hello,

I solved the model steady state with the help of excel. Please find attached excel sheet in which I solved the model for the steady state and compare it with the original model steady state. While solving I calibrated the parameter v_p, elasticity of substitution between oil and capital from 0.09 to 0.012. I also found a mistake in the price equations Fp and Kp (1 - lambdap should not be in the denominator and to be removed), which I corrected.

Similarly, in the matlab file I added few missing equations.

I am no more getting Nan of Inf error message but other error messages in the steady state file. I am wondering since I know the steady state now, should I add the steady state in the main dynare file and bypass the original model matlab file? Following are the error messages:
Oil Shocks_ Steady State Solution.xlsx (18.6 KB)

File: OS_steadystate.m Line: 184 Column: 70
Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for
mismatched delimiters.

Error in evaluate_steady_state_file (line 49)
[ys,params1,check] = h_steadystate(ys_init, exo_ss,M,options);

Error in evaluate_steady_state (line 254)
[ys,params,info] = evaluate_steady_state_file(ys_init,exo_ss,M, options,steadystate_check_flag);

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

Error in stoch_simul (line 109)
[~,info,M_,oo_] = resol(0,M_,options_,oo_);

Error in OS.driver (line 939)
[info, oo_, options_, M_] = stoch_simul(M_, options_, oo_, var_list_);

Error in dynare (line 281)
evalin(‘base’,[fname ‘.driver’]);

Thanks for help.

Regards,
Umer Ameen

Hi again,

I have checked the steady state values of the model and the rental rate of upstream capital reserves seems to have an issue as it does not make sense. I need to correct the model to rerun it.

Thanks for help.

Regards,
Umer Ameen

For your error messages, it is impossible to tell what is going on without the codes.

Hello,

There was a conceptual issue with the model which I tried to resolve by adding an estimated steady state ratio, capital to oil (koratio_p), in the model. This parameter is only for solving the steady state. But now I am getting the following error messages. If required I can send the code files also. Can you please advise how to resolve this issue.

Unrecognized function or variable ‘k’.

Error in CS_steadystate (line 63)
ko_p = k / o;

Error in evaluate_steady_state_file (line 49)
[ys,params1,check] = h_steadystate(ys_init, exo_ss,M,options);

Error in evaluate_steady_state (line 254)
[ys,params,info] = evaluate_steady_state_file(ys_init,exo_ss,M, options,steadystate_check_flag);

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

Error in stoch_simul (line 109)
[~,info,M_,oo_] = resol(0,M_,options_,oo_);

Error in CS.driver (line 1267)
[info, oo_, options_, M_] = stoch_simul(M_, options_, oo_, var_list_);

Error in dynare (line 281)
evalin(‘base’,[fname ‘.driver’]);

Thanks for help.

Regards,
Umer Ameen

Further to above, please note that variable ‘k’ and parameter ‘koratio_p’ are also defined in the main model file.

Thanks
Umer Ameen

The file is indeed necessary.

CS.mod (31.4 KB)
CS_param.m (2.5 KB)
CS_steadystate.m (22.0 KB)
CSdataestim.m (12.2 KB)

Thanks. The files are attached.

But the variables on the right of ko_p = k / o; have not been set before.

Thanks. How can I set again the endogenous variables in the steady state matlab file? If there is any guidance on setting these variables please?

Thanks for the help.

I have searched and learnt that its by
initval;
ko_p = k / o;
end;
steady;
check;

If this is correct then presumably it should be in the main model file and not the matlab file.

Thanks for clarifying this.

initval and a steady state file are to distinct objects. What exactly are you trying to do?

I am trying to set the endogenous variables in the steady state matlab file to resolve the error. I am not clear how to do this?

You need to be able to sequentially execute the setting of steady state variables. In a nutshell, you need to be able to express all endogenous objects just as functions of the parameters.

Ok but what about the endogenous variable rk which is solved in the model by using matlab solver?

I don’t know what you are talking about.