R программ ашиглан хугацаан цуваа симуляци хийхэд arima.sim функцыг ашиглана. Доорхи процессуудаас 200 өгөгдөл үүсгэн, граф дээр үзүүлье. Автокорреляци болон автоковариац олоход acf функцыг ашиглана. Эдгээр функцыг хэрхэн ашиглах талаар заавар авахыг хүсвэл console дээр ?arima.sim, ?acf-г оруулна.
\[e_t\sim N(0, 1)\] \[x_t=0.5x_{t-1}+e_t\] \[y_t=0.9y_{t-1}+e_t\] \[z_t=0.99z_{t-1}+e_t\]
colors <- c("Orange", "Gray", "tomato2", "deepskyblue3")
# AR(1)
e <- rnorm(200)
x <- arima.sim(list(ar=c(0.5)), n=200, innov=e)
y <- arima.sim(list(ar=c(0.9)), n=200, innov=e)
z <- arima.sim(list(ar=c(0.99)), n=200, innov=e)
par(mfrow=c(2, 2))
plot(e, type="l", col=colors[1])
plot(x, type="l", col=colors[2])
plot(y, type="l", col=colors[3])
plot(z, type="l", col=colors[4])
par(mfrow=c(2,2))
acf(e); acf(x); acf(y); acf(z)
par(mfrow=c(2,2))
acf(e, type="correlation")
acf(x, type="correlation")
acf(y, type="correlation")
acf(z, type="correlation")
\[e_t\sim N(0, 1)\] \[x_t=e_t+e_{t-1};\] \[y_t=e_t+e_{t-1}-e_{t-2}\] \[r_t= e_t+\frac{1}{4}e_{t-1}+\frac{1}{4}e_{t-2}+\frac{1}{4}e_{t-3}+\frac{1}{4}e_{t-4}\]
e <- rnorm(200)
x <- arima.sim(list(ma=c(1)), n=200, innov=e)
y <- arima.sim(list(ma=c(1, -1)), n=200, innov=e)
z <- arima.sim(list(ma=c(1, 1, 1)), n=200, innov=e)
r <- arima.sim(list(ma=c(1/4, 1/4, 1/4, 1/4)), n=200, innov=e)
par(mfrow=c(2,2))
plot(x, type="l", col=colors[2])
plot(y, type="l", col=colors[3])
plot(z, type="l", col=colors[4])
plot(r, type="l", col=colors[1])
par(mfrow=c(2, 2))
acf(x); acf(y); acf(z); acf(r);