I am having problem with calling fsolve command in the steady-state file using Dynare. My model is a New-Keynesian model for calculating fiscal-multiplier. First, I have written a matlab file for calibrating the model (calibration_test.m ). In that file I use fsolve command (associated file consumption_trial.m), which works fine. Then I have written a mod file (kenynesian_fiscal_mult.mod) and the associated steady state file. In the steady state file, I try to use fsolve command (associated file consumption.m which is the same as consumption_trial.m). However, I get following error message
Preprocessing completed.

Error using ^
Incorrect dimensions for raising a matrix to a power. Check that the matrix is square and the power is a scalar. To perform
elementwise matrix powers, use ‘.^’.

Error in consumption (line 4)
cnrhat = x(2).^((eepsilon-1)/eepsilon)+ oomega*cgbar^((eepsilon-1)/eepsilon);

Error in fsolve (line 242)
fuser = feval(funfcn{3},x,varargin{:});

Thanks for the quick reply. I tried the solution suggested by you, but ran into another problem. When I run my mod file, I get following error message:
resid: The initial values for the steady state of the following variables are complex:
y
yf
ystar
nx
f1
f2
ln_y
ln_ip

which I find strange. I do not have the same problem when I run my matlab file for calibration (calibration_test.m) along with consumption_test.m although I am using the same syntax.

Sorry to bother you again. I am trying to calculate fiscal multipliers similar to Sims and Wolff (2017), IER and Leeper et. al. (2017), AER. I am using my own steady state file. In the steady state file,
I allow for the fact that if the steady state does not exist or steady state values are unreasonable, then
it should return without updating steady states as suggested in your new Keynesian model code : https://github.com/JohannesPfeifer/dynare/blob/1b5641575f0f3e6f22c5d62f386446bdc774b491/examples/NK_baseline_steadystate.m. When I run my code, for some of the parameter values, steady state does not exist. In that case, my model stops running and does not move to new set of parameter values and I get following message:

Preprocessing completed.

Residuals of the static equations:

Equation number 1 : 0
Equation number 2 : 0
Equation number 3 : -0.25908
Equation number 4 : -0.25908
Equation number 5 : 0
Equation number 6 : 0
Equation number 7 : -1
Equation number 8 : 0.112
Equation number 9 : 0.03
Equation number 10 : 0.09305
Equation number 11 : 0.097043
Equation number 12 : 0.97159
Equation number 13 : -0.935
Equation number 14 : -0.054606
Equation number 15 : -1
Equation number 16 : 1.15
Equation number 17 : 1.5
Equation number 18 : 0
Equation number 19 : 0.435
Equation number 20 : 0.7
Equation number 21 : 1.865
Equation number 22 : 0
Equation number 23 : -0.32
Equation number 24 : -1
Equation number 25 : -0.22206
Equation number 26 : -0.22206
Equation number 27 : 0
Equation number 28 : -1
Equation number 29 : -0.25923
Equation number 30 : -0.25923
Equation number 31 : 0
Equation number 32 : -0.935
Equation number 33 : 0.097043
Equation number 34 : 0.97159
Equation number 35 : 0
Equation number 36 : -0.001874
Equation number 37 : 0
Equation number 38 : 0
Equation number 39 : 0
Equation number 40 : 0
Equation number 41 : 0
Equation number 42 : 0
Equation number 43 : -0.65
Equation number 44 : -2.65
Equation number 45 : 0
Equation number 46 : 0
Equation number 47 : 0.325
Equation number 48 : -2.35
Equation number 49 : 0
Equation number 50 : 0
Equation number 51 : 0.65
Equation number 52 : -1.8571
Equation number 53 : 0
Equation number 54 : 0
Equation number 55 : 0
Equation number 56 : 0.00741
Equation number 57 : 1.5798
Equation number 58 : -0.10748
Equation number 59 : 0.98503
Equation number 60 : 0.84204
Equation number 61 : 2.1231
Equation number 62 : 0.99938
Equation number 63 : 1.8585
Equation number 64 : 0.90029
Equation number 65 : 0.76968
Equation number 66 : 0
Equation number 67 : 0.65
Equation number 68 : 0.65
Equation number 69 : -1.35

Error using print_info (line 76)
The steadystate file did not compute the steady state

Error in steady (line 104)
print_info(info,options_.noprint, options_);

I have attached the relevant files. Any help will be great.

You are not running a loop the way you are supposed to run it. By looping over all of Dynare, you cannot easily control the error codes returned, e.g. when the steady state file signals an error. You can either use a try-catch-statement or use the noprint-option and read out the info-code returned.

The mod-file was not uploaded correctly, but from what I can see, the problems are that oo_.steady_state is not the correct field. oo_.dr.ys and that gdp_eps_cg may have to be replaced by oo_.irfs.gdp_eps_cg or something like that.

Thanks for reply. keynes_multiplier.mod (6.4 KB) I made the suggested changes. Problem remains the same. The model runs 500 times, but uses parameter values given in the mod file. It does not do any updating of parameters.

I have attached the relevant files. Thanks again for your patience.