I want to simulate an AR(1) model x_t = rho * x_(t-1) + e_t, where rho=1, n=1050, so I tried the following code in R.
y <- arima.sim(list(order = c(1,0,0), ar = 1), n = 1050)
But R returns the following message: Error: 'ar' part of model is not stationary. How can I simulate this AR(a) model in this case?
An easy way to do this is
y <- cumsum(rnorm(1050, 0, 1))
(assuming your e_t terms are normal with mean 0 and variance 1)
Your AR
coefficient of one is essentially just adding a differencing term, so your model is an ARIMA(0,1,0)
model. (Since this is non-stationary, R
does not like you trying to put it into the AR
part.) The code to simulate from this model is:
y <- arima.sim(list(order = c(0,1,0)), n = 1050)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.