Dicsussion 4

Discussion 4

Part 1. Applying Exponential Smoothing Models

Data

library(fpp3)
Warning: package 'fpp3' was built under R version 4.5.2
── Attaching packages ──────────────────────────────────────────── fpp3 1.0.3 ──
✔ tibble      3.3.0     ✔ tsibble     1.2.0
✔ dplyr       1.2.1     ✔ tsibbledata 0.4.1
✔ tidyr       1.3.1     ✔ ggtime      0.2.0
✔ lubridate   1.9.4     ✔ feasts      0.5.0
✔ ggplot2     4.0.3     ✔ fable       0.5.0
Warning: package 'dplyr' was built under R version 4.5.2
Warning: package 'ggplot2' was built under R version 4.5.2
Warning: package 'tsibble' was built under R version 4.5.2
Warning: package 'ggtime' was built under R version 4.5.2
Warning: package 'feasts' was built under R version 4.5.2
Warning: package 'fabletools' was built under R version 4.5.2
Warning: package 'fable' was built under R version 4.5.2
── Conflicts ───────────────────────────────────────────────── fpp3_conflicts ──
✖ lubridate::date()    masks base::date()
✖ dplyr::filter()      masks stats::filter()
✖ tsibble::intersect() masks base::intersect()
✖ tsibble::interval()  masks lubridate::interval()
✖ dplyr::lag()         masks stats::lag()
✖ tsibble::setdiff()   masks base::setdiff()
✖ tsibble::union()     masks base::union()
unique(aus_livestock$Animal)
[1] Bulls, bullocks and steers Calves                    
[3] Cattle (excl. calves)      Cows and heifers          
[5] Lambs                      Pigs                      
[7] Sheep                     
7 Levels: Bulls, bullocks and steers Calves ... Sheep
livestock_data <- aus_livestock |>
  filter(
    State == "Victoria",
    Animal == "Cows and heifers"
  ) |>
  select(Month, Count)

livestock_data
# A tsibble: 510 x 2 [1M]
      Month  Count
      <mth>  <dbl>
 1 1976 Jul 111400
 2 1976 Aug  98600
 3 1976 Sep  90500
 4 1976 Oct  80300
 5 1976 Nov  86100
 6 1976 Dec  95700
 7 1977 Jan  87500
 8 1977 Feb 114900
 9 1977 Mar  99700
10 1977 Apr  95200
# ℹ 500 more rows
livestock_data |>
  autoplot(Count) +
  labs(
    title = "Monthly Cows Slaughter in Victoria",
    x = "Month",
    y = "Cows and heifers"
  ) +
  theme_classic()

Splitting Data

livestock_train <- livestock_data |>
  slice_head(n = nrow(livestock_data) - 24)

livestock_test <- livestock_data |>
  slice_tail(n = 24)

Models

livestock_models <- livestock_train |>
  model(
    SES = ETS(
      Count ~
        error("A") +
        trend("N") +
        season("N")
    ),

    Holt = ETS(
      Count ~
        error("A") +
        trend("A") +
        season("N")
    ),

    Holt_Winters = ETS(
      Count ~
        error("A") +
        trend("A") +
        season("A")
    ),
    Holt_Winters_Multiplicative = ETS(
  Count ~
    error("M") +
    trend("A") +
    season("M")
)
  )


livestock_fc<- livestock_models|>
    forecast(new_data = livestock_test)


livestock_fc |>
  autoplot(livestock_train) +
  autolayer(
    livestock_test,
    Count
  ) +
  labs(
    title = "Livestock Forecast",
    subtitle = "SES, Holt, and Holt-Winters Comparison",
    x = "Month",
    y = "Monthly Count"
  ) +
  theme_classic()

livestock_fc |>
  autoplot(livestock_train, level = NULL) +
  autolayer(
    livestock_test,
    Count,
    color = "black"
  ) +
  facet_wrap(vars(.model), ncol = 1) +
  labs(
    title = "Forecasts by Exponential Smoothing Model",
    x = "Month",
    y = "Number of Animals Slaughtered"
  ) +
  theme_classic()

Part 2. Evaluating Model Accuracy

Metric Review

accuracy_results <- livestock_fc |>
  accuracy(livestock_test) |>
  select(.model, RMSE, MAE, MAPE) |>
  arrange(RMSE)

accuracy_results
# A tibble: 4 × 4
  .model                        RMSE    MAE  MAPE
  <chr>                        <dbl>  <dbl> <dbl>
1 Holt_Winters_Multiplicative 17575. 13748.  17.2
2 Holt_Winters                19790. 15842.  19.9
3 Holt                        21197. 17196.  21.3
4 SES                         21728. 17676.  21.9

Using the final 24 months as the test period, the Holt-Winters multiplicative model produced the lowest RMSE, MAE, and MAPE. This indicates that the livestock series contains both trend and seasonal patterns, and that the size of the seasonal fluctuations changes with the overall level of the series. The multiplicative Holt-Winters model outperformed the additive Holt-Winters model, suggesting that seasonality is better represented proportionally rather than as a constant absolute amount. Holt’s model performed worse because it captured the trend but ignored monthly seasonality, while SES produced the largest errors because it modeled neither trend nor seasonality.

livestock_models |>
  tidy() |>
  filter(term %in% c("alpha", "beta", "gamma"))
# A tibble: 9 × 3
  .model                      term  estimate
  <chr>                       <chr>    <dbl>
1 SES                         alpha 0.511   
2 Holt                        alpha 0.521   
3 Holt                        beta  0.00175 
4 Holt_Winters                alpha 0.563   
5 Holt_Winters                beta  0.000938
6 Holt_Winters                gamma 0.000100
7 Holt_Winters_Multiplicative alpha 0.385   
8 Holt_Winters_Multiplicative beta  0.000101
9 Holt_Winters_Multiplicative gamma 0.117   
report(livestock_models)
Warning in report.mdl_df(livestock_models): Model reporting is only supported
for individual models, so a glance will be shown. To see the report for a
specific model, use `select()` and `filter()` to identify a single model.
# A tibble: 4 × 9
  .model              sigma2 log_lik    AIC   AICc    BIC    MSE   AMSE      MAE
  <chr>                <dbl>   <dbl>  <dbl>  <dbl>  <dbl>  <dbl>  <dbl>    <dbl>
1 SES                9.45e+7  -5965. 11935. 11935. 11948. 9.41e7 1.20e8 7.43 e+3
2 Holt               9.56e+7  -5966. 11943. 11943. 11964. 9.48e7 1.22e8 7.46 e+3
3 Holt_Winters       7.90e+7  -5914. 11862. 11864. 11934. 7.64e7 1.01e8 6.35 e+3
4 Holt_Winters_Mult… 1.93e-2  -5939. 11912. 11913. 11983. 8.59e7 1.09e8 1.000e-1

The smoothing parameters show how quickly each exponential smoothing model reacts to new data. Alpha controls the level of the series. When alpha is high, the model gives more weight to recent observations, so the forecast adjusts quickly to new changes. When alpha is low, the forecast becomes smoother and changes more slowly.

Beta controls the trend. A high beta allows the model to update the trend quickly when the series starts increasing or decreasing at a different rate. A low beta keeps the trend more stable and assumes that it changes gradually over time.

Gamma controls the seasonal pattern. A high gamma allows the model to adjust the seasonal component quickly when recent seasonal behavior changes. A low gamma assumes that the seasonal pattern is relatively stable and continues in a similar way.

Overall, larger smoothing parameters make the model more responsive to recent changes, but they can also make the forecast more sensitive to temporary noise. Smaller values create smoother forecasts, although they may react too slowly when the pattern of the series changes suddenly.

Part 3. Scenario Analysis

Exponential smoothing can adjust to sudden changes because it gives more weight to recent observations. Higher values of alpha, beta, and gamma help the model respond more quickly, but they can also make forecasts too sensitive to temporary noise. After a major disruption, the model may still react too slowly because it continues to rely on past patterns. Forecasts can be improved by updating the model frequently, using a rolling training window, treating outliers carefully, and adding external variables such as weather, prices, or processing capacity.