Time Series Homework: Chapter 5 Lesson 2

Please_put_your_name_here

Questions

Question 1 - Seasonal Harmonics: Quarterly Data (35 points)

a) State a linear regression model with a quadratic trend and quarterly harmonic seasonal variables. Your model should be written in the expanded form, showing each component, not using the summation notation.
Answer

$x_t = 0 + 1t + 2t^2 + {s1}sin() + {c1}cos() + {s2}sin() + _{c2}cos() + z_t $

b) Using the time variable created below, create the quarterly harmonic seasonal variables of your model. In a plot, overlap all the seasonal variables you created for the first four quarterly seasons. Please make sure you label each variable. Use the following as parameters:

\(\alpha_{s1} = 11.3\)

\(\alpha_{c1} = 15.4\)

\(\alpha_{s2} = 17.3\)

\(\alpha_{c2} = 13.2\)

Answer
set.seed(123)

t <-  1:40

alpha_0 <- 30

alpha_1 <- 4

alpha_2 <- 0.4 

alpha_s1 <- 11.3

alpha_c1 <- 15.4

alpha_s2 <- 17.3

alpha_c2 <- 13.2

m_t <- alpha_0 + alpha_1*t + alpha_2*t^2 

s_t <- (alpha_s1*sin(2*pi*t/4) + alpha_c1*cos(2*pi*t/4)) + (alpha_s2*sin(2*pi*2*t/4) + alpha_c2*cos(2*pi*2*t/4))

z_t <- 0

x_t <- m_t + s_t  +z_t

time_var <- as_tsibble(tibble(t, x_t, s_t), index = t)

autoplot(time_var) +
  geom_line(aes(y=s_t), color = "orange")
Plot variable not specified, automatically selected `.vars = x_t`

  1. Currently, the only difference between all the variables you created is the frequency of the underlying sine and cosine functions. Please explain the effect of changing the frequency of the functions used to create the harmonic variables. What is the purpose of doing so?
Answer

Changing the frequency of the sine and cosine functions used to create harmonic seasonal variables alters how often the seasonal cycle repeats within the time series. A higher frequency results in more cycles per unit of time—for example, shifting from a frequency of 1 cycle per year (annual seasonality) to 4 cycles per year captures quarterly patterns, while 12 cycles per year captures monthly patterns. The purpose of varying the frequency is to model different layers of seasonality that may be present in the data.

  1. When we estimate the model parameters \(\alpha_{s}=A\cos(\phi)\) and \(\alpha_{c}= A\sin(\phi)\) how does different values of the parameters change the shape of the fitted harmonic components, please explain.
Answer

These values control the amplitude and phase shift of the harmonic components, which together shape the seasonal oscillation. The amplitude affects how strong or pronounced the seasonal fluctuations appear—larger amplitudes result in taller peaks and deeper troughs. The phase shift determines where in the cycle those peaks and troughs occur, effectively shifting the entire seasonal pattern earlier or later in time. By adjusting these parameters, the model can represent different intensities and timings of seasonality observed in the data.

Question 2 - Seasonal Harmonics: Daily Data (15 points)

a) State a linear regression model with an exponential trend and daily harmonic seasonal variables. Your model should be written in the expanded form, showing each component, not using the summation notation.
Answer

$ x_t = _0e^{*1 t} + {s1}sin() + {c1}cos() + {s2}sin() + {c2}cos() + {s3}sin() + _{c3}cos() + z_t $

b) Using the time variable created below, create the daily harmonic seasonal variables of your model. In a plot, overlap all the seasonal variables you created for the first four weekly seasons.

\(\alpha_{s1} = 11.3\)

\(\alpha_{c1} = 15.4\)

\(\alpha_{s2} = 17.3\)

\(\alpha_{c2} = 13.2\)

\(\alpha_{s2} = 12.5\)

\(\alpha_{c2} = 10.7\)

Answer
set.seed(123)

t <-  1:14

alpha_0 <- 2

alpha_1 <- 0.4

alpha_s1 <- 11.3

alpha_c1 <- 15.4

alpha_s2 <- 17.3

alpha_c2 <- 13.2

alpha_s3 <- 12.5

alpha_c3 <- 10.7

m_t <- alpha_0 *exp(alpha_1*t)

s_t <- (alpha_s1*sin(2*pi*t/7) + alpha_c1*cos(2*pi*t/7)) + (alpha_s2*sin(2*pi*2*t/7) + alpha_c2*cos(2*pi*2*t/7)) + (alpha_s3*sin(2*pi*3*t/7) + alpha_c3*cos(2*pi*3*t/7))

z_t <- 0

x_t <- m_t + s_t  + z_t

time_var <- as_tsibble(tibble(t, x_t, s_t), index = t)

autoplot(time_var) +
  geom_line(aes(y=s_t), color = "orange")
Plot variable not specified, automatically selected `.vars = x_t`

Question 3 - Model Selection CriteriaAIC (30 points) -Extra Credit

In time series analysis,the concept of model selection criteria plays a crucial role. Model selection criteria are statistical measures designed to help us choose the most appropriate model from a set of competing models. These criteria balance the trade-off between model complexity and goodness of fit to the data, aiding us in identifying the model that best captures the underlying patterns and dynamics of the time series data. Commonly used criteria include the Akaike Information Criterion (AIC), its corrected version (AICc), and the Bayesian Information Criterion (BIC), each offering unique perspectives on model selection. Understanding these criteria is essential for effectively building and evaluating time series models, empowering analyst to make informed decisions when analyzing real-world time series. While these criteria provide helpful guidance they are not without their caveats.By acknowledging and navigating these limitations thoughtfully, you can enhance the robustness and reliability of your time series analyses.

a) Please research the Akaike Information Criterion (AIC). Please state the model selection criteria and it’s potential limitations.
Answer
b) Please research the AICc (Akaike Information Criterion corrected). Please state the model selection criteria and it’s potential limitations.
Answer
c) Please research the BIC (Bayesian Information Criterion). Please state the model selection criteria and it’s potential limitations.
Answer

Rubric

Criteria Mastery (10) Incomplete (0)

Question 1: Definitions

The student provides sufficient evidence of mastery of the outcome prompt. The submission included mathematical expressions or illustration if available in the text or the Time Series Notebook The student did not provide sufficient evidence to evaluate the outcome prompt.
Mastery (5) Incomplete (0)

Question 2a: Quadratic trend, quarterly harmonics model

Students state the linear regression model with a quadratic trend and quarterly harmonic seasonal variables, providing each component in expanded form. The model is incorrect, it contains extraneous components, or is not showing all the components to be evaluated.
Mastery (10) Incomplete (0)

Question 2b: Quadratic trend, quarterly harmonics variables

Students create the quarterly harmonic seasonal variables and plot them, ensuring clear labeling for each variable and providing well-commented code. The variables are not created correctly, the plot is missing, or the plot is not correctly labeled. Code is not commented or is hard to read.
Mastery (10) Incomplete (0)

Question 2c: Frequency

Students provide a clear explanation of how changing the frequency of the sine and cosine functions affects the harmonic variables and the purpose of doing so in modeling seasonal patterns. The response doesn’t make clear that students understand the effect of changing the frequency on sine and cosine functions and their applications to seasonal pattern modeling.
Mastery (10) Incomplete (0)

Question 2d: Amplitude and Phase

Students explain how different values of the parameters affect the shape of the fitted harmonic components, considering variations in amplitude and phase angle, and provide well-commented explanations. Explanation of how different values of the parameters change the shape of the fitted harmonic components may be incomplete, inaccurate, or unclear, lacking depth or coherence in discussing variations in amplitude and phase angle.
Mastery (5) Incomplete (0)

Question 3a: Exponential trend, weekly harmonics model

Students state the linear regression model with a exponential trend and daily harmonic seasonal variables, providing each component in expanded form. The model is incorrect, it contains extraneous components, or is not showing all the components to be evaluated.
Mastery (10) Incomplete (0)

Question 3b: Exponential trend, weekly harmonics variables

Students create the daily harmonic seasonal variables and plot them, ensuring clear labeling for each variable and providing well-commented code. The variables are not created correctly, the plot is missing, or the plot is not correctly labeled. Code is not commented or is hard to read.
Mastery (10) Incomplete (0)

Question 4a: AIC

Students accurately research the Akaike Information Criterion (AIC), stating its model selection criteria and potential limitations clearly and concisely. The model selection criterion is not stated correctly or is not clear that the student understand the tradeoffs and limitations of the criteria.
Mastery (10) Incomplete (0)

Question 4b: AICc

Students accurately research the AICc (Akaike Information Criterion corrected), stating its model selection criteria and potential limitations clearly and concisely. The model selection criterion is not stated correctly or is not clear that the student understand the tradeoffs and limitations of the criteria.
Mastery (15) Incomplete (0)

Question 4c: BIC

Students accurately research the Bayesian Information Criterion (BIC), stating its model selection criteria and potential limitations clearly and concisely. The model selection criterion is not stated correctly or is not clear that the student understand the tradeoffs and limitations of the criteria.
Total Points 95