# Error using assignin

**URL:** <https://forum.dynare.org/t/error-using-assignin/11975>\
**Category:** Dynare help (legacy posts)\
**Created:** [12 June 2018 14:15 UTC](https://forum.dynare.org/t/error-using-assignin/11975 "2018-06-12T14:15:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fabiover](https://forum.dynare.org/letter_avatar_proxy/v4/letter/f/90db22/32.png) [@fabiover](https://forum.dynare.org/u/fabiover)\
**Post date:** [12 June 2018 14:15 UTC](https://forum.dynare.org/t/error-using-assignin/11975/1 "2018-06-12T14:15:49Z")

</div>

Hi,

I want to simulate some time series from an estimated model. I am using Matlab 2015b and dynare 4.5.4.

So first I run the Bayesian estimation of the model using the usual “estimation” command

estimation(nograph,nodisplay,datafile=dataGswMpe,nobs=95,order=1,mh\_replic=10000,mh\_nblocks=2,mh\_jscale=0.30,mh\_drop=0.25,plot\_priors=0);

The estimation part works well.

After that, I simulate the time series using

stoch\_simul(periods=200,simul\_replic=5,nograph);

However I got the following error:

**Error using assignin**  
**ASSIGNIN cannot assign to variables with the same name as a**  
**MATLAB keyword**

**Error in dyn2vec (line 49)**  
\*\* assignin(‘base’,deblank(M\_.endo\_names(i,:)),oo\_.endo\_simul(i,k)’);\*\*

* * *

**Error in stoch\_simul (line 168)**  
\*\* dyn2vec;\*\*

**Error in modelGsw (line 779)**  
**info = stoch\_simul(var\_list\_);**

**Error in dynare (line 223)**  
**evalin(‘base’,fname) ;**

Any clue where the problem can be?

Thanks

Fabio

---

<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:** [14 June 2018 10:09 UTC](https://forum.dynare.org/t/error-using-assignin/11975/2 "2018-06-14T10:09:38Z")

</div>

As the message

> [@fabiover](#):
>
> **ASSIGNIN cannot assign to variables with the same name as a**  
> **MATLAB keyword**

says, you have a variable that has a name that is not allowed by Matlab. Please provide the names of the endogenous variables

---

<div class="post-metadata">

**Author:** ![fabiover](https://forum.dynare.org/letter_avatar_proxy/v4/letter/f/90db22/32.png) [@fabiover](https://forum.dynare.org/u/fabiover)\
**Post date:** [14 June 2018 11:10 UTC](https://forum.dynare.org/t/error-using-assignin/11975/3 "2018-06-14T11:10:43Z")

</div>

Hi Johannes,

here they are:  
lam c pk i ups rk R pip piw w k n l u z muw un s y g4y g4p gy xhp  
dY\_obs dC\_obs dI\_obs U\_obs dN\_obs dW\_obs dP\_obs R\_obs r ra  
lamf cf pkf if upsf rkf rf wf kf nf zf yf raf x

I guess variables “i” and/or “if” are the culprit ones

But I do not have any problem if I run stoch\_simul(order=1);

Thanks

---

<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:** [14 June 2018 11:17 UTC](https://forum.dynare.org/t/error-using-assignin/11975/4 "2018-06-14T11:17:06Z")

</div>

The culprit should be `if`. The reason the problem appears is that you used the `periods` option.
