From this series, we’d like to predict what might happen in the future in terms of goals scored.
Autoregression (AR): Incorporates past values to predict future values.
Integration (I): Differencing is used to make a series stationary.
Moving Average (MA): Uses past error terms to refine predictions.
Example: AR(1) model predicts the current value as a weighted sum of the previous value.
We can overlay the original series (blue) with its lag (red) to show the relationship between past and present values.
‘Integration’ refers to the number of times the data needs to be differenced to achieve stationarity.
Remember: differencing removes trends and stabilises the mean, making ARIMA applicable.
Represented as I(\(d\)), where \(d\) is the number of times differencing is applied.
Augmented Dickey-Fuller Test
data: ts_data
Dickey-Fuller = -2.4407, Lag order = 4, p-value = 0.3935
alternative hypothesis: stationary
Note: If the ADF test suggests non-stationarity (p >0.05), differencing is required.
# Compute first-order differencing
ts_diff <- diff(ts_data)
# Plot differenced data
autoplot(ts_diff) + ggtitle("Integrated (I) Component - Differenced Data")
# Perform Augmented Dickey-Fuller (ADF) test
adf_result <- adf.test(ts_diff, alternative = "stationary")
# Print test result
print(adf_result)
Augmented Dickey-Fuller Test
data: ts_diff
Dickey-Fuller = -4.3961, Lag order = 4, p-value = 0.01
alternative hypothesis: stationary
Compare the original and differenced series to see how differencing removes trends.
Note: If ACF has a sharp cutoff, the data likely follows an MA model.
Highlight significant lags in ACF/PACF plots.
auto.arima()
simplifies forecasting.
Augmented Dickey-Fuller Test
data: ts_data
Dickey-Fuller = -7.8448, Lag order = 4, p-value = 0.01
alternative hypothesis: stationary
Augmented Dickey-Fuller Test
data: ts_data
Dickey-Fuller = -7.8448, Lag order = 4, p-value = 0.01
alternative hypothesis: stationary
Augmented Dickey-Fuller Test
data: ts_diff
Dickey-Fuller = -9.9208, Lag order = 4, p-value = 0.01
alternative hypothesis: stationary
If ACF cuts off after lag \(q\), use MA(\(q\)).
If PACF cuts off after lag \(p\), use AR(\(p\)).
If both decay slowly, more differencing may be needed.
auto.arima()
to automatically select \(p\), \(d\), and \(q\) based on AIC/BIC.Series: ts_data
ARIMA(1,0,0)(2,1,0)[12] with drift
Coefficients:
ar1 sar1 sar2 drift
0.7055 -0.7818 -0.3557 0.2954
s.e. 0.0685 0.0907 0.0969 0.0137
sigma^2 = 1.067: log likelihood = -159.08
AIC=328.15 AICc=328.74 BIC=341.56
Training set error measures:
ME RMSE MAE MPE MAPE MASE
Training set -0.01375009 0.9614931 0.7330779 -0.0949486 2.885972 0.2105412
ACF1
Training set -0.001185935
Box-Ljung test
data: res
X-squared = 7.3297, df = 10, p-value = 0.694
Note: If p-value > 0.05, residuals are random (good model fit).
library(Metrics)
fitted_vals <- fitted(fit)
actual_vals <- as.numeric(ts_data)
rmse(actual_vals, fitted_vals)
[1] 0.9614931
[1] 0.02885972
Series: ts_data
ARIMA(1,0,0)(2,1,0)[12] with drift
Coefficients:
ar1 sar1 sar2 drift
0.7055 -0.7818 -0.3557 0.2954
s.e. 0.0685 0.0907 0.0969 0.0137
sigma^2 = 1.067: log likelihood = -159.08
AIC=328.15 AICc=328.74 BIC=341.56
Training set error measures:
ME RMSE MAE MPE MAPE MASE
Training set -0.01375009 0.9614931 0.7330779 -0.0949486 2.885972 0.2105412
ACF1
Training set -0.001185935
economic_index <- rnorm(length(ts_data), mean = 50, sd = 10)
xreg_fit <- auto.arima(ts_data, xreg = economic_index)
summary(xreg_fit)
Series: ts_data
Regression with ARIMA(1,0,0)(2,1,0)[12] errors
Coefficients:
ar1 sar1 sar2 drift xreg
0.7040 -0.8353 -0.3823 0.2958 0.0109
s.e. 0.0688 0.0947 0.0989 0.0130 0.0064
sigma^2 = 1.039: log likelihood = -157.69
AIC=327.38 AICc=328.21 BIC=343.47
Training set error measures:
ME RMSE MAE MPE MAPE MASE
Training set -0.01321115 0.9442364 0.7126028 -0.089611 2.820851 0.2046607
ACF1
Training set -0.007536587
forecast()
.This compares baseline forecast (using the existing ARIMA model to predict future performance) with an Improved Performance Scenario.
Simulates what would happen if the team increased their goal-scoring rate by, say, 10%.
Goal Differential
and why use it?We assume goal differential follows a time-dependent structure, meaning past performances affect future outcomes.
ARIMA learns patterns in performance trends (e.g., a team improving or declining over time).
Forecasting goal differentials helps predict if a team is expected to maintain, improve, or decline.
We can use a normal distribution (pnorm
) to estimate win probability.
If goal differential is positive, the team is expected to win.
The higher the forecasted goal differential, the greater the win probability.
Transforms raw ARIMA predictions into “actionable insights”.
Instead of just forecasting a number, we translate it into real-world decision-making (e.g., “How likely is my team to win?”).
A dynamic probability curve shows expected chances of winning in future matches.
The blue line represents projected probabilities, while red points highlight key changes.
opponent strength
: e.g., include other teams’ performance as external regressors (ARIMAX model).