8
$\begingroup$

I need to simulate an AR(1) process with the following equation in R:

$$ X_{t} = 5 + 0.5X_{t-1}+Z_t $$

Where $Z_t$ ~ White Noise(0,1) and $T=500$.

I know I should be using the arima.sim function from the forecast package with parameters n = 500 and ar = c(0.5) but I do not know how to account for the $ \delta = 5$ or the fact that $Z_t$ is white noise with mean 0 and sd 1. I have been unable to find clear documentation on how to do this.

$\endgroup$
4
  • $\begingroup$ what is $\delta$? $\endgroup$
    – TPArrow
    Commented Sep 27, 2017 at 16:11
  • 1
    $\begingroup$ I vote to leave this question open, as the solution isn't totally programming-related. $\endgroup$
    – Taylor
    Commented Sep 27, 2017 at 16:34
  • $\begingroup$ It would help if you explained what $T$ is and where the $\delta$ comes from as otherwise it is unclear, at least to me, what you are asking. $\endgroup$
    – mdewey
    Commented Sep 27, 2017 at 17:32
  • $\begingroup$ $T$ is essentially the number of samples, $\delta$ is another component of the AR(1) process as specified in the equation as 5. $\endgroup$
    – sammyj
    Commented Sep 27, 2017 at 17:34

1 Answer 1

9
$\begingroup$

Notice that this is the same model as $$ X_t - 10 = .5(X_{t-1} - 10) + Z_t . $$ $10$ is the mean, while $5$ was the intercept. This means we can add ten to the mean zero series.

In other words, if you define $Y_t = X_t - 10$, then $$ Y_t = .5 Y_{t-1} + Z_t $$ and use arima.sim to simulate that. After you have $\{Y_t\}$, then add $10$ to each value.

Code would look like this:

yt <- arima.sim(list(order=c(1,0,0), ar=.5), n=500)
xt <- yt + 10   

Regarding the standard deviation issue, that is covered in the documentation.

$\endgroup$
1
  • $\begingroup$ Thank you! This is very helpful. I will have to relook into the documentation as I couldn't find where to adjust the mean and standard deviation of the white noise. $\endgroup$
    – sammyj
    Commented Sep 27, 2017 at 17:35

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