### Statistics 6871 - Time Series

### Lab Two

### Simulated data from ARIMA models.

###########################################################################################

# Simulated data example: AR(1)

par(mfrow=c(2,3))

ar.sim.pos <- rts(arima.sim(list(order=c(1,0,0), ar = 0.7), n=200))

ts.plot(ar.sim.pos, main="AR(1) phi(1) = 0.7")

acf(ar.sim.pos)

acf(ar.sim.pos, type = "partial")

ar.sim.neg <- rts(arima.sim(list(order=c(1,0,0), ar = -0.7), n=200))

ts.plot(ar.sim.neg, main="AR(1) phi(1) = -0.7")

acf(ar.sim.neg)

acf(ar.sim.neg, type = "partial")

###########################################################################################

# Simulated data example: MA(1)

# Note: Splus define the Moving Average model as X_t = Z_t - theta*Z_{t-1}

# The difference is that there is a minus sign in their definition.

par(mfrow=c(2,3))

ma.sim.pos <- rts(arima.sim(list(order=c(0,0,1), ma = -0.9), n=200))

ts.plot(ma.sim.pos, main="MA(1) theta(1) = 0.9")

acf(ma.sim.pos)

acf(ma.sim.pos, type = "partial")

ma.sim.neg <- rts(arima.sim(list(order=c(0,0,1), ma = 0.9), n=200))

ts.plot(ma.sim.neg, main="MA(1) theta(1) = -0.9")

acf(ma.sim.neg)

acf(ma.sim.neg, type = "partial")

###########################################################################################

# Simulated data example: ARMA(1,1)

par(mfrow=c(2,3))

arma.sim <- rts(arima.sim(list(order=c(1,0,1), ar = 0.7, ma = -0.5), n=200))

ts.plot(arma.sim, main="ARMA(1,1) phi(1) = 0.7 theta(1) = -0.5")

acf(arma.sim)

acf(arma.sim, type = "partial")

###########################################################################################