I want to generate a time series length 400. I used the following code
beta1=0
e=rnorm(1)
out=matrix(NA,400,1)
for (i in 1:400){
beta1[i+1]=((exp(0.3*beta1[i]+e)-1)/(1+exp(0.3*beta1[i]+e)))
out[i]=beta1[i]
}
beta1=out
beta1=ts(beta1)
but the series that is returned shows no variation. need some help on this.
First, using
=is not a nice practice. Use<-instead (orassign()).Then format your script properly so as to look pretty: using spaces helps!
Also, having exponential and 'e' named variables can be confusing.
Using non-vectorized
forloops is also not a good practice, since they are slow.To answer the question, you do not have enough variance because the series is converging, because of its functional form, which is
$$ x_{t+1} = \dfrac{e^{0.3 \cdot x_t + \epsilon} - 1}{e^{0.3 \cdot x_t + \epsilon} + 1 }, \qquad x_0 = 0$$
Try this: