Time Series Homework: Chapter 6 Lesson 2

Please_put_your_name_here

Data

gdp_ts <- rio::import("https://byuistats.github.io/timeseries/data/gdp_fred.csv") |>
  mutate(year_over_year = gdp_millions / lag(gdp_millions, 4)-1) |>
  mutate(quarter = yearquarter(mdy(quarter))) |>
  filter(quarter >= yearquarter(my("Jan 1990")) & quarter < yearquarter(my("Jan 2025"))) |>
  na.omit() |>
  mutate(t = 1:n()) |>
  mutate(std_t = (t - mean(t)) / sd(t)) |>
  as_tsibble(index = quarter)

Questions

Question 1 - Stationary Model Comparison (20 points)

We have worked with AR(p), MA(q), ARMA(p,q) stochastic processes. The theoretical ACF and PACF functions of each model can help us identify which of the three models would be a good fit for a particular time series. From the Time Series Notebook:

ACF and PACF of an \(AR(p)\) Process
AR(p) MA(q) ARMA(p,q)
ACF Tails off Cuts off after lag \(q\) Tails off
PACF Cuts off after lag \(p\) Tails off Tails off

In the pprevious assignment, you worked with a simulation of a AR(3) process and a MA(3) process. In this assignment you will be comparing your findings from that assignment to an ARMA(3,3) process.

ARMA(3,3) Simulation

n <- 10000  # Number of observations
ar_coeffs <- c(0.5, 0.3, 0.1)   # AR coefficients
ma_coeffs <- c(-0.7, -0.5, 0.2)  # MA coefficients

# Simulate the ARMA(3, 3) process
set.seed(123)  # For reproducibility
arma33_process <- arima.sim(n = n, model = list(ar = ar_coeffs, ma = ma_coeffs), sd = 1)

# Convert the simulated ARMA(3, 3) process to a tsibble
arma_33 <- as_tsibble(tibble(Time = 1:n, value = arma33_process), index = Time)
a) Plot the ACFs for the ARMA(3) simulation.
Answer
acf(arma_33)

b) Plot the PACFs for the ARMA(3) simulation.
Answer
pacf(arma_33)

Question 2 - ARMA(p,q): GDP Business Cycles (50 points)

Business cycles are the fluctuations in economic activity that an economy experiences over time, marked by phases of expansion, peak, contraction (or recession), and trough. During expansion, economic indicators such as GDP rise, reaching a peak where the economy operates at maximum capacity. Following the peak, the economy contracts, leading to a recession characterized by falling GDP, until it hits a trough, the lowest point, signaling the end of contraction and the start of recovery. The yearly percentage change in real GDP effectively captures the fluctuations of business cycles by quantifying the rate at which an economy’s total output of goods and services grows or shrinks from one year to the next. The yearly percentage change in real US GDP in decimals is the year_over_year variable in the gdp_ts tsibble.

a) Plot the yearly percentage change in US Real GDP
Answer
ggplot(gdp_ts, aes(x = quarter, y = year_over_year))+
  geom_line()

b) Plot the ACF and PACF of the series
Answer
acf(gdp_ts$year_over_year)

pacf(gdp_ts$year_over_year)

c) Based on the ACF and PACF, please speculate which stationary model will best fit the data.
Answer
d) Please fit an AR(p) model to the yearly percentage change in US Real GDP.
Answer
gdp_ar <- gdp_ts |>
  model(ar = ARIMA(year_over_year ~ 1 + pdq(4,0,0) + PDQ(0, 0, 0)))

tidy(gdp_ar)
# A tibble: 5 × 6
  .model term     estimate std.error statistic  p.value
  <chr>  <chr>       <dbl>     <dbl>     <dbl>    <dbl>
1 ar     ar1        0.695    0.0816      8.52  2.63e-14
2 ar     ar2        0.185    0.101       1.83  7.02e- 2
3 ar     ar3        0.0210   0.101       0.208 8.35e- 1
4 ar     ar4       -0.279    0.0814     -3.43  8.12e- 4
5 ar     constant   0.0181   0.00140    13.0   1.56e-25
e) Please fit an MA(q) model to the yearly percentage change in US Real GDP.
Answer
gdp_ma <- gdp_ts |>
  model(ma = ARIMA(year_over_year ~ 1 + pdq(0,0,4) + PDQ(0, 0, 0)))

tidy(gdp_ma)
# A tibble: 5 × 6
  .model term     estimate std.error statistic  p.value
  <chr>  <chr>       <dbl>     <dbl>     <dbl>    <dbl>
1 ma     ma1        0.927    0.0778     11.9   7.14e-23
2 ma     ma2        0.959    0.0836     11.5   9.80e-22
3 ma     ma3        0.908    0.0871     10.4   4.78e-19
4 ma     ma4       -0.0575   0.0789     -0.729 4.67e- 1
5 ma     constant   0.0479   0.00410    11.7   2.89e-22
f) Please fit an ARMA(p,q) model to the yearly percentage change in US Real GDP.
Answer
gdp_arma <- gdp_ts |>
  model(arma = ARIMA(year_over_year ~ 1 + pdq(4,0,4) + PDQ(0, 0, 0)))

tidy(gdp_arma)
# A tibble: 9 × 6
  .model term     estimate std.error statistic  p.value
  <chr>  <chr>       <dbl>     <dbl>     <dbl>    <dbl>
1 arma   ar1       -1.02     0.0886    -11.5   9.84e-22
2 arma   ar2        0.0215   0.122       0.176 8.60e- 1
3 arma   ar3        0.203    0.121       1.67  9.73e- 2
4 arma   ar4        0.0229   0.0908      0.252 8.01e- 1
5 arma   ma1        2.01     0.0542     37.2   4.02e-73
6 arma   ma2        2.05     0.0768     26.7   7.40e-56
7 arma   ma3        2.01     0.0863     23.3   2.04e-49
8 arma   ma4        1.00     0.0589     17.0   2.19e-35
9 arma   constant   0.0848   0.00837    10.1   2.56e-18
g) In a table, please compare the fit of each model. Which do you think is the best model for the series?
Answer
all_models <- gdp_ts |>
  model(
    ar = ARIMA(year_over_year ~ 1 + pdq(4,0,0) + PDQ(0, 0, 0)),
    ma = ARIMA(year_over_year ~ 1 + pdq(0,0,4) + PDQ(0, 0, 0)),
    arma = ARIMA(year_over_year ~ 1 + pdq(4,0,4) + PDQ(0, 0, 0))
  )

glance(all_models)
# A tibble: 3 × 8
  .model   sigma2 log_lik   AIC  AICc   BIC ar_roots  ma_roots 
  <chr>     <dbl>   <dbl> <dbl> <dbl> <dbl> <list>    <list>   
1 ar     0.000275    367. -721. -720. -704. <cpl [4]> <cpl [0]>
2 ma     0.000173    394. -775. -774. -758. <cpl [0]> <cpl [4]>
3 arma   0.000161    398. -777. -775. -747. <cpl [4]> <cpl [4]>

Rubric

Criteria
Mastery (5) Incomplete (0)
Question 1a: ACF Plots Students produce clear and well-labeled plots of the autocorrelation functions (ACFs) for the AR(2), MA(2), and ARMA(2,2) simulations. Submissions have low-quality visualizations or unclear labeling.
Mastery (5) Incomplete (0)
Question 1b: PACF Students produce clear and well-labeled plots of the partial autocorrelation functions (PACFs) for the AR(2), MA(2), and ARMA(2,2) simulations. Submissions have low-quality visualizations or unclear labeling.
Mastery (10) Incomplete (0)
Question 1c: Evaluation of Theoretical functions Students contrast the theoretical description provided in the question prompt and compare it with the plots they created from multiple simulations with different seeds. They accurately identify and explain any discrepancies or agreements between the theoretical description and the observed patterns in the plots. Their analysis demonstrates a clear understanding of sampling distributions and their representations on ACF and PACF plots. Students contrast doesn’t provide sufficient evidence of understanding of simulation procedures or the theoretical understanding of ACF and PACF. There is not enough content to evaluation whether students understand the sampling process and estimation of ACF and PACF.
Mastery (5) Incomplete (0)
Question 2a: Plot Students plot the yearly percentage change in US Real GDP, ensuring that the plot is clear, properly labeled, and accurately represents the data. They provide appropriate axis labels, a title, and a legend if necessary to enhance interpretability. Submissions have low-quality visualizations or unclear labeling.
Mastery (5) Incomplete (0)
Question 2b: ACF and PACF Students produce clear and well-labeled plots of the ACF and PACF Submissions have low-quality visualizations or unclear labeling.
Mastery (15) Incomplete (0)
Question 2c: Best fit speculation Students analyze the ACF and PACF plots to speculate on the best stationary model for the data. They provide clear reasoning supported by observations from the plots, identifying any significant autocorrelation or partial autocorrelation patterns that suggest a particular model. Their speculation demonstrates a solid understanding of time series analysis concepts and the relationship between ACF, PACF, and model selection. Students attempt to speculate on the best stationary model based on the ACF and PACF plots but may struggle to provide clear reasoning or insights. Their analysis lacks coherence or depth, with limited discussion of relevant autocorrelation or partial autocorrelation patterns. They may overlook significant features in the plots or misinterpret their implications for model selection.
Mastery (5) Incomplete (0)
Question 2d: AR(p) fitted Students proficiently fit an AR(p) model to the yearly percentage change in US Real GDP. They correctly select an appropriate lag order p based on the ACF and PACF analysis or other model selection criteria, estimate the model parameters using appropriate methods, and interpret the results effectively. They may have difficulty selecting an appropriate lag order
p, estimating the model parameters accurately, or interpreting the results effectively. Their interpretation may lack depth or clarity, indicating a limited understanding of the modeling process
Mastery (5) Incomplete (0)
Question 2e: MA(q) fitted Students proficiently fit an MA(q) model to the yearly percentage change in US Real GDP. They correctly select an appropriate lag order p based on the ACF and PACF analysis or other model selection criteria, estimate the model parameters using appropriate methods, and interpret the results effectively. They may have difficulty selecting an appropriate lag order p, estimating the model parameters accurately, or interpreting the results effectively. Their interpretation may lack depth or clarity, indicating a limited understanding of the modeling process
Mastery (5) Incomplete (0)
Question 2f: ARMA(p,q) fitted Students proficiently fit an ARMA(p,q) model to the yearly percentage change in US Real GDP. They appropriately select the orders p and q based on the ACF and PACF analysis or other model selection criteria, estimate the model parameters using appropriate methods, and interpret the results effectively. Their interpretation demonstrates a clear understanding of the the underlying dynamics of the data. They may have difficulty selecting an appropriate lag order p and q estimating the model parameters accurately, or interpreting the results effectively. Their interpretation may lack depth or clarity, indicating a limited understanding of the modeling process



Mastery (10) Incomplete (0)
Question 2g: Model selection Students effectively use AIC, AICc, and BIC to compare and evaluate models, presenting results in a clear table format similar to the one found in the Model Comparison section of the Time Series Notebook Ch5 Lesson 3. Their discussions on the nuance model selection evidences they understand the importance of considering the context and data generating process that is part of model specification. Students struggle to effectively use AIC, AICc, and BIC to compare and evaluate models, resulting in unclear or incomplete presentation of results or failure to address the dangers of relying solely on algorithms for model selection.




Total Points 70