Error message that says a variable R has been declared twice

My code displays this:

Configuring Dynare …
[mex] Generalized QZ.
[mex] Sylvester equation solution.
[mex] Kronecker products.
[mex] Sparse kronecker products.
[mex] Local state space iteration (second order).
[mex] Bytecode evaluation.
[mex] k-order perturbation solver.
[mex] k-order solution simulation.
[mex] Quasi Monte-Carlo sequence (Sobol).
[mex] Markov Switching SBVAR.

Starting Dynare (version 4.4.3).
Starting preprocessing of the model file …
ERROR: CS.mod: line 55, cols 12-129: Symbol R declared twice with different types!

Error using dynare (line 174)
DYNARE: preprocessing failed

I tried a bunch of things but I do not know what I am doing wrong.
CS.mod (3.47 KB)

Just had a brief look but it looks like you have declared R both as an endogenous variable and a parameter.

//modin

It would be wrong to have R and R_hat as endogenous variable also (at the same time), right? So I have to eliminate either of them or is there a solution where I can keep both in my program.

It’s unusual, but you did not tell use what R and R_hat are and what you are trying to achieve. So it is hard to tell what is going on.

Oh I am sorry, I forgot to mention that. R_hat is the deviation of R from it’s steady state.

So r_hat = (R-R_ss)/R_ss

Then that definition goes into the model as an equation and both R and r_hat are variables.

I have already tried that. I still gives the same error for some weird reason.

That means you have still defined R as a parameter and a variable. Delete it from the list of parameters.

I already deleted it. I updated the code.

No, you did not:

[quote]% Parameters:
parameters s_c … sigma_tilda R rho_pi n_ch sigma_c sigma_h n_hc alpha;
[/quote]

I am sorry I sent you the old file. I changed everything and tried to run it but now it gives me some other error which isn’t related to my code. Can anyone interpret it?
KS.m (3.68 KB)

The error I get when running dynare KS.mod is:ERROR: KS.mod: line 122, col 35: Unknown symbol: m The message is rather clear: On line 122, column 35 the variable m is encountered yet it is unknown to the preprocessor. You must declare this variable first.

This is what Matlab gives me:

Reference to non-existent field ‘exo_nbr’.

Error in KS (line 322)

if M_.exo_nbr > 0;

Error in dynare (line 180)

evalin(‘base’,fname) ;

Thanks in advance.
KS.mod (3.7 KB)

Never put statements like

or

into a mod-file