---
title: "Time Series Homework: Chapter 4 Lesson 3"
subtitle: "Please_put_your_name_here"
format: 
  html:
    embed-resources: true
    toc: true
---

```{r, echo=FALSE, message=FALSE, warning=FALSE}

# Loading R packages
if (!require("pacman")) install.packages("pacman")
pacman::p_load(tidyverse, 
               tsibble, fable,
               feasts, tsibbledata,
               fable.prophet,
               patchwork,
               lubridate, 
               rio,
               ggplot2,
               kableExtra
               )
```

## Data

```{r, message=FALSE}

ind_prod <- rio::import("https://byuistats.github.io/timeseries/data/ind_prod_us.csv")
```

## Questions

### Question 1 - Key Definitions (10 points)

Answer the prompt to the learning outcome below. Include any mathematical expressions or illustrations that may accompany the definitions and ideas if available.

::: {.callout-note title="Answer" icon="false"}
-   **Define an AR(p) stochastic process** <!-- Delete this and put your answer here. -->

-   **Express an AR(p) process using the backward shift operator** <!-- Delete this and put your answer here. -->

-   **State an AR(p) forecast function** <!-- Delete this and put your answer here. -->

-   **Determine the stationarity of an AR(p) process using a characteristic equation** <!-- Delete this and put your answer here. -->
:::

### Question 2 - AR(1) with non-zero mean (20 points)

An AR(1) process with a non-zero mean $\mu$ can be expressed by either:

$$x_t-\mu=\alpha(x_{t-1}-\mu)+w_t \hspace{5mm}\mbox{or}\hspace{5mm}x_t=\alpha_0+\alpha_1x_{t-1}+w_t$$

#### a) What is the relationship between the parameters of the first expression ($\mu$ and $\alpha$) and the parameters of the second expression ($\alpha_0$ and $\alpha_1$)?

::: {.callout-note title="Answer" icon="false"}
<!-- Delete this and put your answer here. The three colons mark the end of your answer. -->
:::

#### b) Deduce a similar relationship for an AR(2) process with mean $\mu$

::: {.callout-note title="Answer" icon="false"}
<!-- Delete this and put your answer here. The three colons mark the end of your answer. -->
:::

### Question 3 - Stationarity (40 points)

#### a) Show that the series {$x_t$} given by $x_t=\frac{3}{2}x_{t-1}-\frac{1}{2}x_{t-2}+w_t$ is non-stationary. Please use the characteristic equation method.

::: {.callout-note title="Answer" icon="false"}
<!-- Delete this and put your answer here. The three colons mark the end of your answer. -->
:::

#### b) Please simulate the series {$x_t$} using 1000 realizations and calculate the first difference {$y_t$}, where $y_t=\nabla x_t$.

::: {.callout-note title="Answer" icon="false"}
```{r}



```
:::

#### c) Plot a correlogram of {$y_t$}.

::: {.callout-note title="Answer" icon="false"}
```{r}



```

<!-- Delete this and put your answer here. The three colons mark the end of your answer. -->
:::

#### d) Please explain that {$y_t$} is stationary using the correlogram.

::: {.callout-note title="Answer" icon="false"}
<!-- Delete this and put your answer here. The three colons mark the end of your answer. -->
:::

### Question 4 - Partial Correlogram (45 points)

#### a) Please use the Holt-Winters method to decompose the US Industrial Production Index. Please justify your choice of parameters.Use the context and your understanding of the series as part of your answers.

::: {.callout-note title="Answer" icon="false"}
```{r}



```

<!-- Delete this and put your answer here. The three colons mark the end of your answer. -->
:::

#### b) Plot the remainder (random) component of the decomposed series.

::: {.callout-note title="Answer" icon="false"}
```{r}



```
:::

#### c) Plot a correlogram of the random component of the the US Industrial Production Index. Is the random component stationary? Please explain.

::: {.callout-note title="Answer" icon="false"}
```{r}



```

<!-- Delete this and put your answer here. The three colons mark the end of your answer. -->
:::

#### d) Plot a partial correlogram of the random component of the the US Industrial Production Index. What kind of autoregressive process would you pick to model the random component?

::: {.callout-note title="Answer" icon="false"}
```{r}



```

<!-- Delete this and put your answer here. The three colons mark the end of your answer. -->
:::

### Rubric

+------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| **Criteria**                                         | **Mastery (5)**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | **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 (10)**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       | **Incomplete (0)**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
+------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| #### **Question 2a: AR(1) with non-zero mean**       | Students show the mathematical relationship between the parameters of the two expressions. They demonstrate this by using algebraic steps to connect the parameters in a clear and logical manner, showing a solid understanding of the mathematical equivalence between the two representations.                                                                                                                                                                                                                                                                                                      | Students show the mathematical relationship between the parameters of the two expressions. They demonstrate this by using algebraic steps to connect the parameters in a clear and logical manner, showing a solid understanding of the mathematical equivalence between the two representations.                                                                                                                                                                                                                                    |
+------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|                                                      | **Mastery (10)**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       | **Incomplete (0)**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
+------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| #### **Question 2b: AR(2) with non-zero mean**       | Students show the mathematical relationship between the parameters of the two expressions for the AR(2) case. They demonstrate this by using algebraic steps to connect the parameters in a clear and logical manner, showing a solid understanding of the mathematical equivalence between the two representations.                                                                                                                                                                                                                                                                                   | Students show the mathematical relationship between the parameters of the two expressions. They demonstrate this by using algebraic steps to connect the parameters in a clear and logical manner, showing a solid understanding of the mathematical equivalence between the two representations.                                                                                                                                                                                                                                    |
+------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|                                                      | **Mastery (10)**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       | **Incomplete (0)**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
+------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| #### **Question 3a: Non-stationarity**               | Responses show that the series is non-stationary using the characteristic equation method. They derive the characteristic equation, find the roots with polyroot(), and identify if any roots lie outside the unit circle using the absolute value if necessary. Submissions provide clear steps, including deriving the characteristic equation, using polyroot, and interpreting the results to conclude non-stationarity.                                                                                                                                                                           | Submissions make errors in computing the characteristic equation or incorrectly interpret the roots. Responses lack clarity in their mathematical steps or misunderstand the concept of stationarity.                                                                                                                                                                                                                                                                                                                                |
+------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|                                                      | **Mastery (5)**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | **Incomplete (0)**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
+------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| #### **Question 3b: Simulation**                     | Responses simulate the series {\$x_t\$} and {\$y_t\$}. Students provide clear and well-commented code that is easy to follow and execute the first-difference calculation process accurately.                                                                                                                                                                                                                                                                                                                                                                                                          | Students' code may lack clarity or sufficient comments, making it difficult to follow. They might make errors in the simulation process or fail to provide clear explanations for each step                                                                                                                                                                                                                                                                                                                                          |
+------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|                                                      | **Mastery (5)**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | **Incomplete (0)**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
+------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| #### **Question 3c: Correlogram**                    | The plot has clear labels and a title, ensuring clarity and readability. They provide well-commented code that generates the correlogram.                                                                                                                                                                                                                                                                                                                                                                                                                                                              | Responses struggle to produce a correlogram of {\$y_t\$} with clear labels and a title, making interpretation difficult. Their plot may lack clarity or detail, hindering the reader's ability to discern autocorrelation patterns                                                                                                                                                                                                                                                                                                   |
+------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|                                                      | **Mastery (10)**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       | **Incomplete (0)**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
+------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| #### **Question 3d: Stationarity using correlogram** | Students explain that {\$y_t\$} is stationary using the correlogram. They provide a clear interpretation of the autocorrelation patterns displayed in the correlogram. Responses demonstrate a solid understanding of the concept of stationarity and its manifestation in the correlogram, articulating how the absence of correlations at higher lags indicates stationarity in {\$y_t\$}. Students discuss the statistical significant autocorrelations.                                                                                                                                            | Submissions may lack coherence or precision in articulating how the absence of correlations at higher lags indicates stationarity in {\$y_t\$}. Additionally, they may overlook the importance of discussing the statistical significance of autocorrelations or fail to provide sufficient evidence from the correlogram to support their explanation.                                                                                                                                                                              |
+------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|                                                      | **Mastery (20)**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       | **Incomplete (0)**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
+------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| #### **Question 4a: Decomposition**                  | Responses apply the Holt-Winters method to decompose the US Industrial Production Index, providing a report of the parameters chosen and justifying their choice. They provide a clear explanation for selecting values for the smoothing parameters (alpha, beta, and gamma) based on their understanding of the series and its characteristics. Proficient submissions show a solid grasp of the method and how the chosen parameters correspond to the trend, seasonality, and noise in the data. They consider contextual factors such as historical behavior to inform their parameter selection. | Students attempt to use the Holt-Winters method but lack clarity in justifying their parameter choices. They may struggle to explain why specific values were selected or fail to relate them to the Industrial Production Index. Below expectations submissions may lack coherence in explaining how the chosen parameters align with the data's components and may overlook contextual factors. Overall, their analysis may lack clarity, suggesting a need for improvement in understanding time series decomposition techniques. |
+------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|                                                      | **Mastery (5)**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | **Incomplete (0)**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
+------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| #### **Question 4b: Plot**                           | Responses plot the remainder (random) component of the decomposed series. They provide a well-labeled and clear plot that effectively visualizes the random component.                                                                                                                                                                                                                                                                                                                                                                                                                                 | Plot that lacks clarity, with insufficient labeling or unclear visualization of the random component.                                                                                                                                                                                                                                                                                                                                                                                                                                |
+------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|                                                      | **Mastery (10)**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       | **Incomplete (0)**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
+------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| #### **Question 4c: Stationarity**                   | Students provide a clear interpretation of the autocorrelation patterns displayed in the correlogram. Responses demonstrate a solid understanding of the concept of stationarity and its manifestation in the correlogram, articulating how the absence of correlations at higher lags indicates stationarity. Students discuss the statistical significant autocorrelations.                                                                                                                                                                                                                          | Submissions may lack coherence or precision in articulating how the absence of correlations at higher lags indicates stationarity. Additionally, they may overlook the importance of discussing the statistical significance of autocorrelations or fail to provide sufficient evidence from the correlogram to support their explanation.                                                                                                                                                                                           |
+------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|                                                      | **Mastery (10)**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       | **Incomplete (0)**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
+------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| **Question 4d: Partial Correlogram**                 | Responses plot a partial correlogram of the remainder component and provide a clear interpretation regarding the choice of autoregressive process. They articulate how the significant coefficients in the partial correlogram indicate the lag values of the autoregressive process. Submissions effectively identify the practically significant autocorrelations in the partial correlogram and relate them to the characteristics of potential autoregressive processes, providing a coherent explanation for their choice.                                                                        | Student struggles to accurately plot the partial correlogram of the remainder component or provide a clear interpretation regarding the choice of autoregressive process. They may produce a plot that lacks clarity or fail to effectively communicate the autocorrelation patterns. Submissions overlook important details or fail to provide a coherent explanation for their choice of autoregressive process based on the partial correlogram.                                                                                  |
+------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| **Total Points**                                     | **100**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
+------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
