0
votes

I'm trying to simulate a time serie in R

x = vector()
simul = rnorm(0,1,n=100)
for(t in (1:100))
{
    x[t] = t/5 + cos(2*t*pi/10)+simul[t]
}

plot(x)

ERROR :

Error in plot.window(...) : finite values required for 'ylim'

In addition: Warning messages:

1: In min(x) : no non-missing arguments to min; returning Inf

2: In max(x) : no non-missing arguments to max; returning -Inf

1
I cannot reproduce the error. - Sven Hohenstein
I cannot reproduce the error either. @Amine, could you put 'set.seed(123)' before creating the random numbers. Then we are on the same page, as it will create always the same numbers. - otwtm
It's working. I forgot to add specifty n in rnorm :p - Amine Messaoudi

1 Answers

0
votes

The code in the question does not generate an error when I run it. Note that to be reproducible you need to set the random seed. Also there is no need for a loop. It could be written more compactly like this:

set.seed(123)

t <- seq_len(100)
x <- t/5 + cos(2*t*pi/10) + rnorm(100)
plot(x)