Solution to Time Series Analysis Problems (with R Implementation)
A time series is stationary if its mean, variance, and autocovariance do not depend on time.
Thus, \(X_t\) is not stationary due to the presence of a time-dependent mean.
\(Y_t = (2 + 3t + W_t) - (2 + 3(t-1) + W_{t-1})\)
Thus, \(Y_t\) is stationary.
\(V_t = \frac{1}{q} \sum_{j=1}^{q} X_{t-j}\)
Show that ******************\(| \rho_X(1) | \leq 1/2\)******************** for any ********************\(\theta\)********************.**
If \(X_t\) is an AR(p) model with intercept \(\phi_0 \neq 0\), let \(Y_t = X_t - \mu\), where \(\mu\) is the mean of \(X_t\). Then \(Y_t\) follows an AR(p) model without an intercept.
\(X_t = \phi_0 + \sum_{i=1}^{p} \phi_i X_{t-i} + W_t\) Taking expectations and subtracting \(\mu\), we get the transformed equation for \(Y_t\) as an AR(p) model without an intercept.
set.seed(123)
T <- 5000
theta <- c(0.5, 2)
wt <- rnorm(T, mean = 0, sd = 1)
xt <- wt
for (t in 3:T) {
xt[t] <- wt[t] + theta[1] * wt[t-1] + theta[2] * wt[t-2]
}
# ACF Plot
acf(xt, main="ACF of Simulated MA(2) Process")
# Repeat with smaller sample size
T_small <- 100
xt_small <- xt[1:T_small]
acf(xt_small, main="ACF of Smaller Sample (T=100)")
# Load required libraries
library(quantmod)
library(tseries)
library(forecast)
# Get VIX data
getSymbols("^VIX", from="2012-01-01", to="2017-02-01", src="yahoo")
#> [1] "VIX"
vix_returns <- monthlyReturn(Cl(VIX))
# (1) Identify AR model
ar_model <- ar(vix_returns)
print(ar_model)
#>
#> Call:
#> ar(x = vix_returns)
#>
#> Coefficients:
#> 1 2
#> -0.4645 -0.2006
#>
#> Order selected 2 sigma^2 estimated as 0.05987
# (2) Fit MA model based on ACF plot
acf(vix_returns, main="ACF of VIX Returns")
ma_model <- arima(vix_returns, order=c(0,0,1))
print(ma_model)
#>
#> Call:
#> arima(x = vix_returns, order = c(0, 0, 1))
#>
#> Coefficients:
#> ma1 intercept
#> -0.5266 0.0216
#> s.e. 0.1145 0.0146
#>
#> sigma^2 estimated as 0.0554: log likelihood = 1.52, aic = 2.96
# (3) Fit AR model based on PACF plot
pacf(vix_returns, main="PACF of VIX Returns")
ar_model <- arima(vix_returns, order=c(1,0,0))
print(ar_model)
#>
#> Call:
#> arima(x = vix_returns, order = c(1, 0, 0))
#>
#> Coefficients:
#> ar1 intercept
#> -0.3859 0.0195
#> s.e. 0.1175 0.0226
#>
#> sigma^2 estimated as 0.05917: log likelihood = -0.4, aic = 6.8
# (4) Compare AIC values
cat("MA Model AIC:", AIC(ma_model), "\n")
#> MA Model AIC: 2.955273
cat("AR Model AIC:", AIC(ar_model), "\n")
#> AR Model AIC: 6.800648
if (AIC(ma_model) < AIC(ar_model)) {
cat("MA model is better based on AIC.\n")
} else {
cat("AR model is better based on AIC.\n")
}
#> MA model is better based on AIC.