1. Simulate a MA(2) data with σ2 = 1, θ1 = 0.5 and θ2 = 2 with T =5,000. Make an ACF plot. Is this consistent with the model that you have simulated? Try generating a model with the same parameters but only 100 observations. Make an ACF. Repeat this a few times, what do you notice about the autocorrelations and the dotted blue lines?
MA_1 <- arima.sim(model = list(ma = 0.5), n = 5000)
MA_2 <- arima.sim(model = list(ma = 2), n = 5000)
summary(MA_1)
##      Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
## -4.767528 -0.730579  0.002830  0.006925  0.730732  4.766710
summary(MA_2)
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
## -9.91343 -1.55890 -0.05473 -0.04461  1.46214  8.19452
acf(MA_1)

acf(MA_2)

MA_3 <- arima.sim(model = list(ma = 0.5), n = 100)
MA_4 <- arima.sim(model = list(ma = 2), n = 100)
acf(MA_3)

acf(MA_4)

  1. Obtain the VIX index from 2012-01-01 to 2017-02-01. Focus on the series of the daily closing index. Compute the monthly log return rtof the VIX index. (you can use the function monthlyReturn).
require('xts')
## Loading required package: xts
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
require('quantmod')
## Loading required package: quantmod
## Warning: package 'quantmod' was built under R version 4.1.3
## Loading required package: TTR
## Registered S3 method overwritten by 'quantmod':
##   method            from
##   as.zoo.data.frame zoo
getSymbols("^VIX",from= as.Date('2012-01-01'),to= as.Date('2017-02-01'),src="yahoo")
## 'getSymbols' currently uses auto.assign=TRUE by default, but will
## use auto.assign=FALSE in 0.5-0. You will still be able to use
## 'loadSymbols' to automatically load data. getOption("getSymbols.env")
## and getOption("getSymbols.auto.assign") will still be checked for
## alternate defaults.
## 
## This message is shown once per session and may be disabled by setting 
## options("getSymbols.warning4.0"=FALSE). See ?getSymbols for details.
## [1] "^VIX"
close = VIX[, 'VIX.Close']
monthly = monthlyReturn(close, type = 'log')
  1. Using the command ar to identify an AR mdoel for rt. Perform estimation and write down the fitted model, including residual standard deviation.
ar_model = arima(close, order = c(1,0,0))
ar_model
## 
## Call:
## arima(x = close, order = c(1, 0, 0))
## 
## Coefficients:
##          ar1  intercept
##       0.9288    15.6970
## s.e.  0.0104     0.5077
## 
## sigma^2 estimated as 1.702:  log likelihood = -2154.3,  aic = 4314.61
  1. Make an ACF plot. Propose and fit an MA model based on the ACF plot. Perform estimation and write down the fitted model, including residual standard deviation. Are all the MA coefficient significant? Is the fitted model invertible? (check the roots of the MA polynomial) Make a tsdiag plot for the model. Judging from the plots, is the fitted model adequate?
ma_model = arima(close, order = c(0,0,1))
ma_model
## 
## Call:
## arima(x = close, order = c(0, 0, 1))
## 
## Coefficients:
##          ma1  intercept
##       0.7671    15.6743
## s.e.  0.0129     0.1104
## 
## sigma^2 estimated as 4.99:  log likelihood = -2840.96,  aic = 5687.92
  1. Make a PACF plot. Propose and fit an AR model based on the PACF plot. Perform estimation and write down the fitted model, including residual standard deviation. Are all the AR coefficient significant. Is the fitted model stationary? (check the roots of the AR polynomial) Make a tsdiag plot for the model. Judging from the plots, is the fitted model adequate?
pacf(close)

new_ar_model = arima(close, order = c(1,0,0))
new_ar_model
## 
## Call:
## arima(x = close, order = c(1, 0, 0))
## 
## Coefficients:
##          ar1  intercept
##       0.9288    15.6970
## s.e.  0.0104     0.5077
## 
## sigma^2 estimated as 1.702:  log likelihood = -2154.3,  aic = 4314.61
tsdiag(new_ar_model)

  1. Based only on the AIC values of the two models in (2) and (3), which model is better? Based on only the AIC values model in question 3 is better, given its lower AIC