Unexpected syntax error

Hi guys. I’m trying to run my code and the error is unexpected endogenous variable and also writes an error on the line (line 174) which I don’t have (I have till 140 lines). Please could you help me to find out from what is this?
ERROR: Arellano.mod: line 7, cols 33-34: syntax error, unexpected LN

Error using dynare (line 174)
DYNARE: preprocessing failed

I’m attaching my file. I would appreciate any help.

Arellano.mod (4.34 KB)

You cannot name variables Ln, because ln is the syntax for the natural logarithm. Please rename it.

oh thank you :slight_smile:

But now I have another problem. I’ll attach my file (which is changed a bit compared the other one) and I’m trying to run my code and the only thing that it says is

Error using print_info (line 74)
Impossible to find the steady state. Either the model doesn’t have a steady state, there are an
infinity of steady states, or the guess values are too far from the solution

I really don’'t understand the reason for this as I’ve checked my steady state equations like hundred times. Could you help me in this task as well.

Thanks in advance
Arellano.mod (4.69 KB)


before steady to see

[quote]Residuals of the static equations:

Equation number 1 : 27880249954411.24
Equation number 2 : 0.40032
Equation number 3 : 0
Equation number 4 : 0
Equation number 5 : -2.8557
Equation number 6 : 0.42472
Equation number 7 : 0
Equation number 8 : 0
Equation number 9 : 0
Equation number 10 : -2.7543
Equation number 11 : 0
Equation number 12 : -0.066184
Equation number 13 : 0
Equation number 14 : -2.2681
Equation number 15 : 0
Equation number 16 : 0
Equation number 17 : 0[/quote]

Given the extremely large residual in equation 1, I guess there is still a mistake in that equation. Moreover, your initial value of Ct is negative.

From what I can see, also my last post of [Jaimovich and Rebelo: News About the Future) applies to your specification of

x=X*exp(eps1) ;                                                              % Aid        
log(eps1)=psi11*log(eps1(-1)) + psi12*log(eps2(-1))+psi13*log(eps3(-1))+e1;   %Aid shock

ok, I’ll check my model one more time.
About eps, will it be possible to write epsn or epsx? Will dynare understand correctly?

Thanks for helping

oh ok, I’ve read your last post one more time, so I guess I can not call it epsx or epst. So i think the only thing is to rename eps=z. Will it be ok?

It is not about renaming. The issue is that if you use

x=X*exp(eps1) ; % Aid log(eps1)=psi11*log(eps1(-1)) + psi12*log(eps2(-1))+psi13*log(eps3(-1))+e1; %Aid shock
you defined eps1 to already be in logs. eps1 can be negative and is 0 in steady state. You cannot put it into logs again. You must use

[code]x=X*exp(eps1) ; % Aid eps1=psi11*eps1(-1) + psi12*eps2(-1)+psi13*eps3(-1)+e1; %Aid shock[/code]
and similarly for the other shocks.

Hi, sorry for asking so many questions :slight_smile: I’ve one more questions regarding shocks. The shock which is given in the model is exp(eps1). So for example my production function looks like this:
y = exp(eps1)Atk(-1)^alpha*l^(1-alpha);

My question is how should I represent my shock in the list of exogenous variables. Should I write it like exp(eps1) (or maybe I can write eps(1), and dynare will take exp afterwards).

Also in the model when I’m defining my shock, can I write it like:
exp(eps1) =(1-psi)exp(eps1_bar) + psiexp(eps1(-1))+ e1;

or I just need to write it for eps1 ?

Thanks so many times

You need to enter it exactly the way I showed you. In the variable declaration, you have
[var … eps1;](var … eps1;)
Also, you cannot use

To see this, imagine a large negative e1-shock. Then exp(eps1) on the left hand side will be negative, which is impossible.
What you are meaning to say is

Dear Dynare users,

I’m trying to calibrate a simple tradable and non-tradable economy in Dynare with shocks on tradable and non tradable sectors.
Even though I’ve calculated steady states, I’m not sure if I’m calculating initvals correct as my variables are agregated.
Here is my model:

% list of endogenous variables
var z1 z2 eps1 eps2 i kt kn k yt yn y ct cn c pn pc lt l r ;

% the following exogenous variables are shocked
varexo e1 e2 ;

parameters beta alpha delta omega eta mu nu sigma psi11 psi12 psi21 psi22 sigma1 sigma2 A An kyt klt kln knkt;

c^(-sigma)/pc^(1+mu) = beta*(c(+1)^(-sigma))/(pc(+1)^(1+mu))r(+1); % Euler eqution
r = alpha
Az1(kt/lt)^(alpha-1) + 1-delta; % return
pn = ((1-omega)/omega)(cn/ct)^(-(1+alpha)); % Substitutions between the consumption of tradable and non-tradable goods
pc = (omega^(1/(1+alpha))+((1-omega)^(1/(1+alpha)))pn^(alpha/(1+alpha)))^((1+alpha)/alpha);
alpha*(kt/lt)^(alpha-1)= pnAnz2eta(kn/l)^(eta-1) ; % The cost of capital
Az1(1-alpha)(kt/lt)^alpha = pnAnz2(1-eta)*(kn/l)^eta; % The cost of labor

ct+i =yt ; % aggregate resource constraint
cn = yn;
c = (omega*(ct)^(-mu)+ (1-omega)(cn)^(-mu))^(-1/mu); %overall capital
yt = z1
Akt^alpha(lt)^(1-alpha); % tradable production function
yn = z2Ankn^eta*(l)^(1-eta); % non-tradable sector production funstion
y= yt+pn*yn; % GDP
lt+l=1; % overall labor

k = i + (1-delta)*k(-1); % capital accumulation
k(-1) = (kt^(-nu)+kn^(-nu))^(-1/nu);
z1 = eps1; % Productivity shock in tradable sector
z2 = eps1; % Productivity schock in non-tradable sector

Even thought I have 18 variables and 18 equations, I’m not able to transfrom my variables into a parametric form.

My Problem: Even though it’s easy to calculate Kt/Yt or Kn/Yn (tradable capital/tradable output and non-tradable capita;/non-tradable output) I need ratios like K/Y where K is a non linear aggregate of Kt and Kn, and Y is a linear aggregate of Yt and Yn. Or I also need to calculate C/Y where C is a non linear function of Ct and Cn.

Because in all of those equations I was getting a ratio Kt/Kn, I decided to mark it as a parameter, however my model is not running still. And I don’t know if I’m allowed to do it.
Please let me know of someone has worked with this kind of aggregate variables and can help me in solving my problem.


I finally found some minutes to look at the Arellano et al. “The dynamics of foreign aid and its variability” paper. What you are talking about is a non-trivial issue. The original paper is non-linear and hence uses a moment matching with 7 parameters and 7 targets at the ergodic mean, not at the steady state. Because you are going for a linearized model, a lot of things might simplify in the steady state computations and it might be possible to do this analytically.

However, I am not sure you can fix the ratio of capital stocks as you do, because I am not sure it correctly maps into your targets. Rather, you should follow the approach set in the original paper and fix the targets they use at their numerical values and then compute the resulting required paramter values needed to achieve those targets.
Take a look at the RBC News shock model on my homepage. Here also some ratios are fixed and the required parameters computed, e.g. i/y is fixed and the required delta is computed.

In case this is not analytically possible, you should take a look at the NK_baseline.mod in the Dynare example folder. It uses a nonlinear solver to set the labor disutility parameter in order to have labor at 0.2. This approach can be extended to solve an equation system.

Dear Jpfeifer,

thanks for your help. However I did not very well understood why I need to calculate the parameters as they are already given in the paper (the paper uses already known parameters)?

I’ve finally figured out the part of tradable and non-tradable sectors (Experiment9) where I have fixed the ratio of non-tradable and tradable ouputes (pnyn/yt).
Now my task is to add an exogenuous shock which is described as x in my model (Experiment 15). x=X*z3 where X is a fixed value. Even though this exogenuous shock can be seen just in budget constraint or market clearing conditions, however my model gives some mistake, which I don’t know what is meaning.

Error using check_model (line 36)
The specified covariances for the structural errors are not consistent with the
variances as they imply a correlation larger than ±1

I don’t really know what from where this mistakes come from, as the x is just an exogenuous shock. Please, if it’s possible to check these 2 codes as well I’ll be very greatful.

Thanks in advance
Experiment15.mod (4.16 KB)
Experiment9.mod (3.92 KB)

You only specify a covariance for e3, but do not set its variance. The resulting 0 variance is inconsistent with a positive covariance.

You can just use the parameters of the paper if you want, but you will have different targets. The original paper uses the ergodic mean as from the nonlinear model as the target. In your linearized model, the ergodic mean is identical the steady state, but it is different from the ergodic mean as from the nonlinear model. People usually prefer to target the deterministic steady state in this case, but if you are fine with just using their parameters, you can do it. The steady state should then be uniquely determined (unless you a portfolio problem, but that is another story) and you don’t need to fix anything else.

Hi Thanks a lot for support :slight_smile: I finally was able to replicate the model and get the results. However the problem that I’m thinking about now is that in order my variables to converge their steady state I need to specify periods=400. If i don’t specify it, dynare does for 40 periods and when I look to their values , they don’t converge to their steady state with 40 periods. Taking into account that I have yearly observations (I’ve specified beta=0.95, delta=0.05) I’m suspicious about this. Do you maybe know if this is ok? Or there is still something needed to change?

Thanks in advance
Experiment33.mod (4.64 KB)

Also I’m getting strange impulse responses. For example when I have positive productivity shock in tradable sector (I’ve two sector economy), my tradale consumption and tradable output are increasing, however tradable capital and labor are decreasing? Isn’t this strange? I can not find why, as positive productivity shock should increase the tradable capital and tradable labor (it can be seen from equations as well). I’ve checked the steady state values, they seem positive. I can not find a mistake.

I cannot give much advice here as I don’t know the model. If you think the behavior is suspicious, there must be a mistake somewhere, either in the equations or the parameterization. Looking at the IRFs, I don’t find the persistence too problematic, particularly given the low delta. I rather find the erratic oscillating behavior of some IRFs in the beginning puzzling.