---
title: "Time Series Homework: Chapter 3 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}

unratensa <- rio::import("https://byuistats.github.io/timeseries/data/UNRATENSA.csv")

avgkwhr <- rio::import("https://byuistats.github.io/timeseries/data/USENERGYPRICE.csv")

```

## Questions

### Question 1 - Context and Measurement (10 points)

The first part of any time series analysis is context. You cannot properly analyze data without knowing what the data is measuring. Without context, the most simple features of data can be obscure and inscrutable. This homework assignment will center around the series below.

Please research the time series. In the spaces below, give the data collection process, unit of analysis, and meaning of each observation for the series.

**Average Price of Electricity per Kilowatt-Hour in U.S.: City Average**

<https://fred.stlouisfed.org/series/APU000072610>

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

### Question 2 - 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"}
-   **Explain the purpose of the Holt-Winters parameters** $\alpha$, $\beta$, **and** $\gamma$ : <!-- Delete this and put your answer here. -->

-   **Explain the Holt-Winters forecasting equation for additive decomposition models, Equation (3.22)** <!-- Delete this and put your answer here. -->
:::

### Question 3 - US Unemployment Rate: Additive Holt-Winters Forecasting (10 points)

We have used a measure of US unemployment rates before. This series imported above has not been seasonally adjusted.

#### a) Please use the Holt-Winters smoothing method to the series.

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



```
:::

#### b) What parameters values did you choose for $\alpha$, $\beta$, and $\gamma$. Justify your choice.

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

#### c) Please plot the Holt-Winters forecast of the series for the next 12 months superimposed against the original series. Please see [Figure 7](https://byuistats.github.io/timeseries/chapter_3_lesson_3.html#fig-crime-hw-forecast) in Chapter 3: Lesson 3

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



```
:::

#### d) Is the trend in the US unemployment series deterministic or stochastic? What is the basis of your evaluation?

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

### Question 4 - US Average Price of Electricity: Additive Holt-Winters Forecasting (25 points)

#### a) Please use the Holt-Winters smoothing method to the series.

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



```
:::

#### b) What parameters values did you choose for $\alpha$, $\beta$, and $\gamma$. Justify your choice.

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

#### c) Please plot the Holt-Winters forecast of the series for the next 12 months superimposed against the original series. Please see [Figure 7](https://byuistats.github.io/timeseries/chapter_3_lesson_3.html#fig-crime-hw-forecast) in Chapter 3: Lesson 3

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



```
:::

#### d) Is the trend in the US unemployment series deterministic or stochastic? What is the basis of your evaluation?

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

### Question 5 - Additive Holt-Winters Forecasting: Evaluation (45 points)

You used the same algorithm to forecast the US Unemployment Rate and the Energy Price series. However, underneath, the processes that generated the two series are very different. Whether a series has a deterministic or stochastic trend has implications for forecasting. The parameter values used in the algorithm and their justification matters for the result. Please contrast the complexity or ease of modeling, and the uncertainty of the forecast between series with deterministic and stochastic trends.

#### a) What is the reason behind the difference in the ease of modeling between the US Unemployment Rate and the Energy Price series?

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

#### b) Based on your forecast of the US Unemployment Rate and the Energy Price series, which are you the most confident with? Why?

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

#### c) Grey rhinos?????

### Rubric

|                                         |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
|-----------------|--------------------------------------|------------------|
| **Criteria**                            | **Mastery (5)**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | **Incomplete (0)**                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| **Question 1: Context and Measurement** | The student thoroughly researches the data collection process, unit of analysis, and meaning of each observation for both the requested time series. Clear and comprehensive explanations are provided.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             | The student does not adequately research or provide information on the data collection process, unit of analysis, and meaning of each observation for the specified series.                                                                                                                                                                                                                                                                                                                  |
|                                         | **Mastery (10)**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | **Incomplete (0)**                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| **Question 2: 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 3a: HW Smoothing**           | Demonstrate the implementation of the Holt-Winters smoothing method in R, providing well-commented code that clearly explains each step of the algorithm. They correctly specify the necessary parameters, including trend and seasonality components.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              | Students encounter difficulties in accurately implementing the Holt-Winters smoothing method in R. Their code may lack sufficient comments or clarity, making it challenging to understand the implementation process. Additionally, they may overlook important parameters or make errors in the application of the method, leading to inaccuracies in the results.                                                                                                                         |
|                                         | **Mastery (10)**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | **Incomplete (0)**                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| **Question 3b: Parameter Choice**       | Responses not only specify the chosen parameter values for $\alpha$, $\beta$, and $\gamma$ in the context of the Holt-Winters smoothing method but also correctly identify the purpose of each parameter in their explanation. They provide a thorough justification for each parameter choice, considering factors such as the data characteristics, seasonality patterns, and the desired level of smoothing                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | Student struggles to clearly specify the chosen parameter values for $\alpha$, $\beta$, and $\gamma$. It's no clear that they understand the purpose of each parameter in their explanation. They may provide limited or vague justification for each parameter choice, lacking consideration of important factors such as data characteristics or seasonality patterns.                                                                                                                     |
|                                         | **Mastery (5)**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | **Incomplete (0)**                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| **Question 3c: Forecast Plot**          | Responses effectively create a plot of the Holt-Winters forecast for the next 24 months superimposed against the original series in R. The forecasted values align with the original series and display relevant trends and seasonality patterns. Additionally, they appropriately label the axes, title the plot, and provide a clear legend to distinguish between the original series and the forecast. The plot closely resembles Figure 7 in the Time Series Notebook                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          | Student encounter challenges in creating a plot of the Holt-Winters forecast. They may struggle with accurately implementing the plotting code, resulting in inaccuracies or inconsistencies in the plotted forecast. Additionally, their plot may lack proper labeling of the axes, a title, or a legend, making it difficult to interpret the information presented. Furthermore, their plot may deviate significantly from Figure 7 in the Time Series Notebook.                          |
|                                         | **Mastery (5)**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | **Incomplete (0)**                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| **Question 3d: Trend Evaluation**       | The submission demonstrate a clear understanding of the distinction between deterministic and stochastic trends and provide a reasoned argument for their assessment based on the observed data properties. They provide an evaluation of the data characteristics, considering factors such as the presence of consistent patterns or irregular fluctuations over time. Analyses involve visual inspections to identify any discernible patterns or randomness in the trend.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       | Student offers limited insights into the data characteristics, lacking consideration of relevant factors such as patterns or fluctuations over time. Additionally, their evaluation may lack depth or coherence. No plots drawn to evaluate the trend.                                                                                                                                                                                                                                       |
|                                         | **Mastery (5)**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | **Incomplete (0)**                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| **Question 4a: HW Smoothing**           | Demonstrate the implementation of the Holt-Winters smoothing method in R, providing well-commented code that clearly explains each step of the algorithm. They correctly specify the necessary parameters, including trend and seasonality components.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              | Students encounter difficulties in accurately implementing the Holt-Winters smoothing method in R. Their code may lack sufficient comments or clarity, making it challenging to understand the implementation process. Additionally, they may overlook important parameters or make errors in the application of the method, leading to inaccuracies in the results.                                                                                                                         |
|                                         | **Mastery (10)**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | **Incomplete (0)**                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| **Question 4b: Parameter Choice**       | Responses not only specify the chosen parameter values for $\alpha$ , $\beta$, and $\gamma$ in the context of the Holt-Winters smoothing method but also correctly identify the purpose of each parameter in their explanation. They provide a thorough justification for each parameter choice, considering factors such as the data characteristics, seasonality patterns, and the desired level of smoothing                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | Student struggles to clearly specify the chosen parameter values for $\alpha$, $\beta$, and $\gamma$. It's no clear that they understand the purpose of each parameter in their explanation. They may provide limited or vague justification for each parameter choice, lacking consideration of important factors such as data characteristics or seasonality patterns.                                                                                                                     |
|                                         | **Mastery (5)**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | **Incomplete (0)**                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| **Question 4c: Forecast Plot**          | Responses effectively create a plot of the Holt-Winters forecast for the next 24 months superimposed against the original series in R. The forecasted values align with the original series and display relevant trends and seasonality patterns. Additionally, they appropriately label the axes, title the plot, and provide a clear legend to distinguish between the original series and the forecast. The plot closely resembles Figure 7 in the Time Series Notebook                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          | Student encounter challenges in creating a plot of the Holt-Winters forecast. They may struggle with accurately implementing the plotting code, resulting in inaccuracies or inconsistencies in the plotted forecast. Additionally, their plot may lack proper labeling of the axes, a title, or a legend, making it difficult to interpret the information presented. Furthermore, their plot may deviate significantly from Figure 7 in the Time Series Notebook.                          |
|                                         | **Mastery (5)**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | **Incomplete (0)**                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| **Question 4d: Trend Evaluation**       | The submission demonstrate a clear understanding of the distinction between deterministic and stochastic trends and provide a reasoned argument for their assessment based on the observed data properties. They provide an evaluation of the data characteristics, considering factors such as the presence of consistent patterns or irregular fluctuations over time. Analyses involve visual inspections to identify any discernible patterns or randomness in the trend.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       | Student offers limited insights into the data characteristics, lacking consideration of relevant factors such as patterns or fluctuations over time. Additionally, their evaluation may lack depth or coherence. No plots drawn to evaluate the trend.                                                                                                                                                                                                                                       |
|                                         | **Mastery (20)**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | **Incomplete (0)**                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| **Question 5a: Modeling Complexity**    | Responses provide a well-analyzed contrast between the complexity or ease of modeling and the uncertainty of forecasting for series with deterministic and stochastic trends, specifically comparing the US Unemployment Rate and the Energy Price series. They offer a clear explanation of the reasons behind the difference in the ease of modeling between the two series, considering factors such as the underlying processes that generate each series and their characteristics. Analyses may highlight how the US Unemployment Rate is influenced by economic policies, labor market dynamics, and societal factors. The analysis highlights how Energy Price series, are influenced by complex market dynamics, geopolitical events, and environmental factors. Additionally, they may discuss the implications of these differences for forecasting accuracy and the importance of parameter selection in capturing the underlying patterns effectively. | Submissions may provide vague or superficial explanations, lacking depth or coherence in their analysis. Additionally, they may overlook key factors influencing the complexity of modeling, such as the underlying processes or characteristics of each series. Furthermore, they may fail to effectively contrast the uncertainty of forecasting between series with deterministic and stochastic trends, indicating a limited understanding of the implications for forecasting accuracy. |
|                                         | **Mastery (10)**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | **Incomplete (0)**                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| **Question 5b: Forecast Confidence**    | Students demonstrate a solid understanding of the statistical concept of confidence in forecasting. They relate their confidence levels to their previous evaluations of the data, ensuring consistency in their assessment.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | Students may struggle to demonstrate a clear understanding of the statistical concept of confidence in forecasting. They may fail to relate their confidence levels to their previous evaluations of the data, resulting in inconsistency in their assessment. Furthermore, their explanations may lack depth or coherence, indicating a limited understanding of how confidence relates to forecast accuracy.                                                                               |
|                                         | **Mastery (20)**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | **Incomplete (0)**                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| **Question 5c: Gray Rhinos**            | Students provide a comparison between their forecasting results and the actual realization of the series, highlighting areas of accuracy and any discrepancies observed. They demonstrate an understanding of the impact of Gray Rhino event on forecasting. Responses are clear, coherent, and well-structured, ensuring that the evaluation and lessons learned are effectively communicated                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | Submissions provide a limited or superficial comparison between their forecasting results and the actual realization of the series, lacking depth in their analysis or failing to identify key discrepancies.Responses demonstrate a lack of understanding of the impact of Gray Rhino events on forecasting. Explanations may lack clarity, coherence, or structure, making it difficult to understand the evaluation and lessons learned effectively.                                      |
| **Total Points**                        | **115**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
