Unexpected syntax error

This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location where you will have to reset your password.
Forum rules
This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location (https://forum.dynare.org) where you will have to reset your password.

Unexpected syntax error

Postby Ann » Thu May 29, 2014 9:58 am

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.

Thanks
Attachments
Arellano.mod
(4.34 KiB) Downloaded 66 times
Ann
 
Posts: 9
Joined: Thu May 29, 2014 9:50 am

Re: Unexpected syntax error

Postby jpfeifer » Thu May 29, 2014 1:25 pm

You cannot name variables Ln, because ln is the syntax for the natural logarithm. Please rename it.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Unexpected syntax error

Postby Ann » Fri May 30, 2014 5:05 pm

oh thank you :)

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
Ann
Attachments
Arellano.mod
(4.69 KiB) Downloaded 57 times
Ann
 
Posts: 9
Joined: Thu May 29, 2014 9:50 am

Re: Unexpected syntax error

Postby jpfeifer » Fri May 30, 2014 5:14 pm

Put
Code: Select all
resid(1);

before steady to see
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

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 http://www.dynare.org/phpBB3/viewtopic.php?f=1&t=5677 applies to your specification of
Code: Select all
x=X*exp(eps1) ;                                                              % Aid       
log(eps1)=psi11*log(eps1(-1)) + psi12*log(eps2(-1))+psi13*log(eps3(-1))+e1;   %Aid shock
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Unexpected syntax error

Postby Ann » Fri May 30, 2014 6:36 pm

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
Ann
 
Posts: 9
Joined: Thu May 29, 2014 9:50 am

Re: Unexpected syntax error

Postby Ann » Fri May 30, 2014 8:58 pm

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?
Ann
 
Posts: 9
Joined: Thu May 29, 2014 9:50 am

Re: Unexpected syntax error

Postby jpfeifer » Sat May 31, 2014 6:02 am

It is not about renaming. The issue is that if you use
Code: Select all
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: Select all
[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.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Unexpected syntax error

Postby Ann » Mon Jun 02, 2014 10:06 am

Hi, sorry for asking so many questions :) 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)*At*k(-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) + psi*exp(eps1(-1))+ e1;

or I just need to write it for eps1 ?


Thanks so many times
Ann
 
Posts: 9
Joined: Thu May 29, 2014 9:50 am

Re: Unexpected syntax error

Postby jpfeifer » Tue Jun 03, 2014 6:40 am

You need to enter it exactly the way I showed you. In the variable declaration, you have
[url]var ... eps1;[/url]
Also, you cannot use
Code: Select all
exp(eps1) =(1-psi)*exp(eps1_bar) + psi*exp(eps1(-1))+ e1;

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
Code: Select all
exp(eps1) =exp((1-psi)*(eps1_bar) + psi*eps1(-1)+ e1);
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Tradable and non-tradable sectors

Postby Ann » Tue Jun 10, 2014 9:23 pm

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*A*z1*(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);
A*z1*alpha*(kt/lt)^(alpha-1)= pn*An*z2*eta*(kn/l)^(eta-1) ; % The cost of capital
A*z1*(1-alpha)*(kt/lt)^alpha = pn*An*z2*(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*A*kt^alpha*(lt)^(1-alpha); % tradable production function
yn = z2*An*kn^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.

Regards
Ann
Ann
 
Posts: 9
Joined: Thu May 29, 2014 9:50 am

Re: Unexpected syntax error

Postby jpfeifer » Wed Jun 11, 2014 9:39 pm

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.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Unexpected syntax error

Postby Ann » Fri Jun 13, 2014 9:03 pm

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
Attachments
Experiment15.mod
(4.16 KiB) Downloaded 72 times
Experiment9.mod
(3.92 KiB) Downloaded 65 times
Ann
 
Posts: 9
Joined: Thu May 29, 2014 9:50 am

Re: Unexpected syntax error

Postby jpfeifer » Sun Jun 15, 2014 11:48 am

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.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Many periods

Postby Ann » Sat Jul 05, 2014 7:30 pm

Hi Thanks a lot for support :) 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
Ann
Attachments
Experiment33.mod
(4.64 KiB) Downloaded 78 times
Ann
 
Posts: 9
Joined: Thu May 29, 2014 9:50 am

Re: Unexpected syntax error

Postby Ann » Sun Jul 06, 2014 11:00 am

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.
Ann
 
Posts: 9
Joined: Thu May 29, 2014 9:50 am

Next

Return to Dynare help

Who is online

Users browsing this forum: No registered users and 5 guests