Icon

Energy Demand Forecasting for Capacity Planning

Initial Diagnostics (EDA)

Exploratory analysis was performed to identify trend, seasonality, and autocorrelation in the time series, informing appropriate model selection.

Model Building and Comparison

Models are fitted on training data and evaluated on the test set using forecast accuracy metrics and residual diagnostics. Forecast plots with 80% and 95% prediction intervals are generated for visual comparison.

Data Loading

Imported raw dataset containing multiple energy-related time series variables.

Data Preparation / Wrangling

The dataset was cleaned and transformed to prepare it for time series analysis. The YYYYMM field was split into Year and Month components, and invalid observations were removed. A proper monthly time index was constructed and converted to Date&Time format, followed by sorting to ensure chronological order. The dataset was then filtered to retain only the “Total Primary Energy Consumption” series, and unnecessary columns were removed. The final output is a clean, structured monthly time series with Date and Value columns.

Train-Test Split

The data was split chronologically, with observations prior to 2015 used for training and the most recent observations reserved for out-of-sample evaluation to ensure reliable model comparison. The test set spans approximately 121 months (~19% of the full series). This larger evaluation window was chosen to assess model stability across a full decade of out-of-sample data.

Time Series Plot

The series shows a clear upward trend until the mid-2000s, followed by stabilization. Strong and consistent yearly seasonality is present, with relatively constant amplitude, suggesting additive seasonality.

STL Decomposition

The decomposition confirms a strong and consistent seasonal pattern with stable amplitude, indicating additive seasonality. The trend shows long-term growth followed by stabilization in later years. The remainder component appears mostly random with no clear structure.

ACF & PACF

The ACF shows strong autocorrelation with a slow decay, indicating the presence of a trend. Seasonal patterns are also evident with seasonal spikes at multiples of lag 12. The PACF shows significant spikes at low lags, suggesting short-term dependence. Overall, the series exhibits both trend and seasonality, supporting the use of seasonal time series models.

Ljung Box Test on Residuals

The Ljung-Box test strongly rejects the null hypothesis of no autocorrelation (p-value < 0.05), indicating that the series exhibits significant autocorrelation and is not white noise.

NAIVE
SNAIVE

Seasonal baseline (lag = 12) included due to strong monthly seasonality.

DRIFT
ETS (A, A, A)

Additive ETS model used based on observed trend and stable seasonal variation in the time series, STL, & ACF plots

Auto ETS

ETS structure selected automatically using AICc.

Lowest forecast error among all models.

Auto ARIMA

ARIMA orders selected automatically under constraints (stepwise=TRUE, approximation=TRUE, p≤3, q≤3, P≤2, Q≤2, d=1), based on observed autocorrelation and seasonality in ACF and PACF plots.

Residual diagnostics indicate no significant autocorrelation (Ljung-Box p-value > 0.05). It has the best AICc score.

SARIMA (1,1,1)(1,1,1)[12]

Differencing applied to address trend (d = 1) and seasonality (D = 1). AR and MA terms selected based on ACF/PACF patterns.

STL + ETS

STL decomposition used to separate components before applying ETS.

Transformation Check

Box-Cox test was performed on the cleaned data to verify that no transformation is needed.

Since the lambda value is 0.924 (~1), no transformation is needed before fitting the models

Model comparison based on RMSE, MAE, MAPE, MASE, AICc, and Ljung-Box residual diagnostics. Auto ETS achieves the best forecast accuracy (RMSE=0.258, MAPE=2.291%, MASE=0.845), outperforming all baselines and advanced models on error metrics. Auto ARIMA produces the cleanest residuals (LB p-value=0.21) and the best AICc (-320.774), the only model failing to reject the white noise null hypothesis. SARIMA(1,1,1)(1,1,1)[12] offers competitive AICc (-316.853) within the manually specified ARIMA family. Seasonal Naive, while simpler, achieves competitive accuracy (RMSE=0.317) relative to its complexity. Final model selection is addressed in the Best Model Selection node.

Time Series Cross Validation (TSCV)

Stronger validation is applied to the top three models (Auto ETS, Auto ARIMA, Seasonal Naive) using expanding-window time series cross-validation on the complete data. The initial window is set to 36 months, with 12-month step size and 24-month forecast horizon, allowing performance to be evaluated across multiple rolling forecast origins.

Seasonal Naive ranked first on Mean RMSE (0.317) and was the most stable model (SD_RMSE=0.1). Auto ARIMA won the most individual folds (27) but showed higher variance (SD_RMSE=0.189). Auto ETS, despite leading on the held-out test set, ranked last in TSCV (RMSE=0.325, Best_Folds=10), suggesting its earlier advantage may not be consistent over time. 

Final Forecast

Auto ARIMA refit on full dataset (1973–2025) and used to generate a 24-month forward forecast (2026–2027) with 80% and 95% prediction intervals. Residual diagnostics (time plot, ACF, histogram) confirm model adequacy prior to deployment.

Residuals are centered at zero with no significant ACF spikes, confirming no remaining autocorrelation. The histogram is approximately normal. Auto ARIMA's forecasts are statistically reliable for deployment.

BEST MODEL SELECTION: AUTO ARIMA

Auto ARIMA was selected as the final forecasting model based on consistent evidence across two independent validation approaches. On the held-out test set (January 2015 onward), Auto ARIMA produced the best AICc (-320.774) and was the only model whose residuals passed the Ljung-Box white noise test (p = 0.21), indicating no meaningful autocorrelation structure was left unexplained. Across time series cross-validation (expanding window, 36-month initial, 12-month step, 24-month horizon), Auto ARIMA won the most individual folds (27 of 50), confirming that its test-set performance reflects genuine generalization rather than a favorable split.

Auto ETS achieved the lowest test-set RMSE (0.258, MAPE 2.29%) but ranked last in TSCV mean RMSE (0.325) and showed the highest fold-to-fold variance, suggesting overfitting to the post-2015 test window. SARIMA(1,1,1)(1,1,1)[12] produced a competitive AICc (-316.853) but did not match Auto ARIMA on residual diagnostics or TSCV consistency.

Tradeoff: Seasonal Naïve ranked first in TSCV mean RMSE (0.317) and was the most stable model (SD_RMSE = 0.100). For a lower-stakes use case — internal reporting, rough planning estimates, or contexts where non-technical staff must maintain the model — Seasonal Naïve is a fully defensible alternative. For a capital allocation decision where a directional error carries material financial consequence, Auto ARIMA's superior fit, clean residuals, and cross-validation consistency make it the stronger choice.

CSV Reader
Number to String
R Snippet
String Manipulation
String Manipulation
String to Number
Row Filter
String Manipulation
Table View
Forecast Plot
R View (Table)
Forecast Plot
R View (Table)
Forecast Plot
R View (Table)
Forecast Plot
R View (Table)
Forecast Plot
R View (Table)
R Snippet
Concatenate
R Snippet
Table View
Forecast Plot
R View (Table)
Table View
Forecast Plot
R View (Table)
Table View
R Snippet
R Snippet
Table View
Table View
R Snippet
Table View
R Snippet
Column Filter
R Snippet
Final Forecast Plot
R View (Table)
R Snippet
Residual Diagnostics for the Final Forecast
R View (Table)
String to Date&Time
Table View
Sorter
R View (Table)
Table View
Column Resorter
R Snippet
Line Plot
Table View
Forecast Plot
R View (Table)
R Snippet
R View (Table)
R Snippet
Table View

Nodes

Extensions

Links