2
$\begingroup$

I am new to R. I wanted to create an ARIMA(1,0,0) model which simulates data with the coefficient been 0.1. I used the following code:

set.seed(456)
## list description for AR(1) model with small coef
AR.sm <- list(order=c(1,0,0), ar=0.1, sd=0.0001)

## simulate AR(1)
AR1.sm <- arima.sim(n=50, model=AR.sm)

## setup plot region
par(mfrow=c(1,2))
## get y-limits for common plots
ylm <- c(min(AR1.sm), max(AR1.sm))

## plot the ts
plot.ts(AR1.sm, ylim=ylm,
        ylab=expression(italic(x)[italic(t)]),
        main=expression(paste(phi," = 0.1")))

print(paste('Mean:',mean(AR1.sm)))
print(paste('Std:',sd(AR1.sm)))

The std and mean of the data is:

[1] "Mean: 0.202367015812633"
[1] "Std: 1.03631583857173"

The problem is, no matter what I assign to the sd parameter (0.1, 1, 10), the standard deviation that is computed in the last line is about 1.
Why is it like this?

$\endgroup$

1 Answer 1

2
$\begingroup$

It looks like sd is not part of model but needs to be specified separately. The following does what you want:

set.seed(456)
AR.sm <- list(order=c(1,0,0), ar=0.1)
AR1.sm <- arima.sim(n=50, model=AR.sm, sd=0.0001)
sd(AR1.sm)

I got this idea from the examples in the help file of arima.sim:

arima.sim(n = 63, list(ar = c(0.8897, -0.4858), ma = c(-0.2279, 0.2488)), sd = sqrt(0.1796))

As you can see, sd is outside of the parenthesis of the model part.

$\endgroup$
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.