Reputation: 111
This is mostly a question of whether I am coding this correctly. I need to create the following time series in order to answer questions about it: Simulate an AR(2) process with μ= 2,φ1= 1.2, and φ2=−0.6 having error terms that are normally distributed white noise with mean 0 and variance 9. In order to generate this process, use the random number generation seed 2172 and a sample size of n= 200.
The homework questions ask me things about this process and are easy, but I want to make sure my code is actually simulating what it's supposed to before I move forward.
Here's what I did:
set.seed(2172)
arima.sim(n=200, list(ar=c(1.2, -.6)), innov = rnorm(200, 0, 3)) + 2
Upvotes: 0
Views: 53
Reputation: 1714
You are asking a good question and I found few good answer. In the R documentation of the function it is not explicit. But I give you my result which are based on this answer of Rolf Turner. It convinced me :
http://r.789695.n4.nabble.com/AR-1-with-an-error-term-arima-sim-parameter-question-td4700642.html
The solution is :
error.model = function(n){rnorm(n, sd=3)}
x = arima.sim(model = list(ar=c(1.2, -0.6)), n = 200, rand.gen = error.model) + 2
To check the order, you can use pacf
, the question is how to correctly chek the noise because you have an AR. Maybe you can check it with a small sample, for instance t = 1, 2, 3, 4, and check your result.
Good luck.
Upvotes: 1