# [R] arima.sim: innov querry

Andy Bunn Andy.Bunn at wwu.edu
Tue Nov 22 19:33:33 CET 2011

```> On 22/11/11 13:04, Andy Bunn wrote:
> > Apologies for thickness - I'm sure that this operates as documented
> and with good reason. However...
> >
> > My understanding of arima.sim() is obviously imperfect. In the
> example below I assume that x1 and x2 are similar white noise processes
> with a mean of 5 and a standard deviation of 1. I thought x3 should be
> an AR1 process but still have a mean of 5 and a sd of 1. Why does x3
> have a mean of ~7? Obviously I'm missing something fundamental about
> the burn in or the innovations.
> >
> > x1<- rnorm(1e3,mean=5,sd=1)
> > summary(x1)
> > x2<- arima.sim(list(order=c(0,0,0)),n=1e3,mean=5,sd=1)
> > summary(x2)
> > x3<- arima.sim(list(order=c(1,0,0),ar=0.3),n=1e3,mean=5,sd=1)
> > summary(x3) # why does x3 have a mean of ~7?
>
>      X_t = 0.3 * X_{t-1} + E_t
>
> where E_t ~ N(5,1).
>
> So E(X_t) = 0.3*E(X_{t-1}) + E(E_t), i.e
>
>      mu = 0.3*mu + 5, whence
>
>      mu = 5/0.7 = 7.1429 approx. = 7

Of course, stupid of me. I should not send r-help requests out at the end of the day. But now I do have a more nuanced question. I'm trying to simulate an ARMA(1,1) process where the underlying distribution is log normal. At the end of the process, can I use arima.sim in conjunction with rlnorm with the parameters below? Thanks in advance for advice. -A

mu <- -0.935338
sigma <- 0.4762476
# the dist'n I want but with white noise
x1 <- rlnorm(1e5,meanlog=mu,sdlog=sigma)
# how can I add these arima coefs to a log-normal distn yet keep parameters mu and sigma?
ar1 <- 0.6621
ma1 <- -0.1473
# This is not it:
x2 <- arima.sim(list(order=c(1,0,1),ar=ar1,ma=ma1),
n = 1e3, rand.gen=rlnorm, meanlog=mu, sdlog=sigma)

>
> So all is in harmony.  OMMMMMMMMMMMMMMMMMM! :-)
>
>      cheers,
>
>          Rolf Turner
>
> P. S. If you want the population mean of x3 to be 5, add 5 *after*
> generating
> x3 from innovations with mean 0.
>
>          R. T.

```