SIMULATION OF AUTOREGRESSIVE PROCESS AR(1) IN R
Here is the code in R for AR(1):
set.seed(20190)
n=10000
phi = .6
Z = rnorm(n,0,1)
X=NULL
X[1] = Z[1]
for (t in 2:n) {
X[t] = Z[t] + phi*X[t-1]
}
X.ts = ts(X)
par(mfrow=c(2,1))
plot(X.ts,main="AR(1) Time Series on White Noise, phi=.6")
X.acf = acf(X.ts, main="AR(1) Time Series on White Noise, phi=.6")


Comments
Post a Comment