# In this program we are going to generate some theoretical acf's and pacf's
# of some common Stationary/Non-seasonal models using the "ARMAacf" function
# We are also going so generate some simulated Box-Jenkins time series using
# the "arima.sim" function.
# First, let's generate some theoretical (population) acf's and pacf's
# for some common Stationary/Non-seasonal models using the "ARMAacf" fundtion
# This is a "mixed" ARMA model
# Note that both the ACF and PACF "damp out"
par(mfrow = c(1,2))
ARMAacf(ar = 0.5, ma = 0.6, lag.max = 24, pacf=FALSE)
ARMAacf(ar = 0.5, ma = 0.6, lag.max = 24, pacf=TRUE)
plot(ARMAacf(ar = 0.5, ma = 0.6, lag.max = 24, pacf=FALSE))
plot(ARMAacf(ar = 0.5, ma = 0.6, lag.max = 24, pacf=TRUE))
windows()
# This ia a "pure" AR model
# Note that the ACF "damps out" while the PACF has one spike
# in it and then "cuts" off
par(mfrow=c(1,2))
ARMAacf(ar = 0.5, ma = 0.0, lag.max = 24, pacf=FALSE)
ARMAacf(ar = 0.5, ma = 0.0, lag.max = 24, pacf=TRUE)
plot(ARMAacf(ar = 0.5, ma = 0.0, lag.max = 24, pacf=FALSE))
plot(ARMAacf(ar = 0.5, ma = 0.0, lag.max = 24, pacf=TRUE))
windows()
# This is a "pure" MA model
# Note that the ACF has one spike in it and then "cuts off"
# while the PACF "damps out"
par(mfrow = c(1,2))
ARMAacf(ar = 0.0, ma = 0.6, lag.max = 24, pacf=FALSE)
ARMAacf(ar = 0.0, ma = 0.6, lag.max = 24, pacf=TRUE)
plot(ARMAacf(ar = 0.0, ma = 0.6, lag.max = 24, pacf=FALSE))
plot(ARMAacf(ar = 0.0, ma = 0.6, lag.max = 24, pacf=TRUE))
# You can try a multitude of other models if you would like.
# You just have to be sure to choose ar and ma values
# that imply stationarity and invertiblilty of the models.
# For the AR(1) model you must have -1 < ar1 < 1
# For the MA(1) model you must have -1 < ma1 < 1
# For the AR(2) model you must have ar1 + ar2 < 1
# and ar2 - ar1 < 1 and abs(ar2) < 1
# For the MA(2) model you must have ma1 + ma2 < 1
# and ma2 - ma1 < 1 and abs(ma2) < 1
# For the ARMA(1,1) model you must have -1 < ar1 < 1 and
# -1 < ma1 < 1
# For the ARMA(1,1) model you must also be care not to choose
# ar1 = ma1 as this reeults in an unidentified model. Such
# have a so-called "common root".