# Code giving me Parse Error

**URL:** <https://forum.dynare.org/t/code-giving-me-parse-error/26725>\
**Category:** Stochastic simulations\
**Created:** [10 November 2024 08:55 UTC](https://forum.dynare.org/t/code-giving-me-parse-error/26725 "2024-11-10T08:55:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nesma](https://forum.dynare.org/letter_avatar_proxy/v4/letter/n/898d66/32.png) [@nesma](https://forum.dynare.org/u/nesma)\
**Post date:** [10 November 2024 08:55 UTC](https://forum.dynare.org/t/code-giving-me-parse-error/26725/1 "2024-11-10T08:55:04Z")

</div>

I have the following code and I am receiving parse error at ‘=’ : usage might be invalid MATLAB syntax

Please help.

```auto
var c k y L z w r;
varexo e;
% Declare the parameters
%-----------------------
parameters beta1 alpha1 delta1 phi1 rho1 sigmae;
% Initialize the parameters: give them numerical values
%-----------------------------------------------------
beta1=0.9961;
alpha1=0.36;
delta1=0.0389;
phi1=2.0163;
rho1=0.66505;
sigmae=0.0182;

% Declare the model: write down the equations that characterize the solution of the model
%-----------------
model;
   phi1*exp(c)=(1-phi1)*(1-exp(L))*exp(z)*(1-alpha1)*(exp(k(-1)))^(alpha1))*(exp(L)^(-alpha1));
   exp(c(+1))=beta1*exp(c)*exp(z(+1))*alpha1*((exp(k))^(alpha1-1))*(exp(L(+1))^(1-alpha1))+1-delta1;
   exp(c)+exp(k)-(1-delta1)*exp(k(-1))=exp(y);
   exp(y)=exp(z)*((exp(k(-1)))^alpha1)*((exp(L))^(1-alpha1));
   exp(w)=(1-alpha1)*exp(z)*((exp(k(-1)))^(alpha1))*((exp(L))^(-alpha1));
   exp(r)=alpha1*exp(z)*((exp(k(-1)))^(alpha1-1))*(exp(L)^(1-alpha1));
   z=rho1*z(-1)+e;                                           
end;

% EXERCISE: Compute impulse responses to a productivity shock
%-----------------------------------------------------------
% Enter values of all variables in the deterministic steady state
initval;
   L=log(0.33); 
   k=log((exp(L))*(((1-alpha1)*(1/(beta1-1+delta1)))^(1/(alpha1-1))))
   y=log(exp(z)*exp(k)^alpha1*exp(L)^(1-alpha1));
   c=log(exp(y)-delta1*exp(k)); 
   w=log((1-alpha1)*(exp(k)^(alpha1))*(exp(L)^(-alpha1)));
   r=log(alpha1*(exp(k)^(alpha1-1))*(exp(L)^(1-alpha1)));
   z=log(1); 
end;
steady;
% difference between codes^ and below is the initval equations: 
   %L=log(0.33);
   %k=log(((1/beta1-1+delta1)/(alpha1*exp(L)^(1-alpha1)))^(1/(alpha1-1)));
   %y=log(exp(z)*exp(k)^alpha1*exp(L)^(1-alpha1));
   %c=log(exp(y)-delta1*exp(k));
   %r=log(alpha1*exp(k)^(alpha1-1)*exp(L)^(1-alpha1));
   %w=log((1-alpha1)*exp(k)^alpha1*exp(L)^(-alpha1));
   %z=log(1);
% Specify the variance of the shocks
shocks;
   var e; stderr sigmae;
end;

% Run the stochastic simulation
%-----------------------------
stoch_simul(irf=300, periods=2000);

```

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://forum.dynare.org/user_avatar/forum.dynare.org/jpfeifer/32/5044_2.png) [@jpfeifer](https://forum.dynare.org/u/jpfeifer)\
**Post date:** [10 November 2024 09:18 UTC](https://forum.dynare.org/t/code-giving-me-parse-error/26725/2 "2024-11-10T09:18:43Z")

</div>

There were various syntax errors. Try  
[test.mod](https://forum.dynare.org/uploads/short-url/zjNNhbOyBRll9YzvO8Yxikgy9z5.mod) (2.0 KB)  
Also see

> [@Nonzero residuals - static equations](https://forum.dynare.org/t/nonzero-residuals-static-equations/19839/4):
>
> That may well be. You should only do exp()-substitutions once the model works. Generally, I rather recommend appending logged values. See

---

<div class="post-metadata">

**Author:** ![nesma](https://forum.dynare.org/letter_avatar_proxy/v4/letter/n/898d66/32.png) [@nesma](https://forum.dynare.org/u/nesma)\
**Post date:** [16 November 2024 10:06 UTC](https://forum.dynare.org/t/code-giving-me-parse-error/26725/3 "2024-11-16T10:06:59Z")

</div>

Hello, thank you for your help. But, when I downloaded the file to test on my laptop, it did not work. It is giving me the same errors as I saw before.

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://forum.dynare.org/user_avatar/forum.dynare.org/jpfeifer/32/5044_2.png) [@jpfeifer](https://forum.dynare.org/u/jpfeifer)\
**Post date:** [17 November 2024 11:59 UTC](https://forum.dynare.org/t/code-giving-me-parse-error/26725/4 "2024-11-17T11:59:50Z")

</div>

Which error message are you getting? It should be a problem with the steady state. You need to check your equations. For example, the Eule equation does have wrong bracketing.
