#Reading the Murban Data
Months crude_oil_prices
1 1/1/2003 29.60
2 2/1/2003 31.70
3 3/1/2003 29.10
4 4/1/2003 25.00
5 5/1/2003 25.85
6 6/1/2003 26.80
#Exploratory Data Analysis & Preprocessing #Plot the time series of crude oil prices. Describe the main patterns, trends, and seasonality observed. # STL decomposition #Compute and interpret the autocorrelation function (ACF) and partial autocorrelation function (PACF) of the crude oil price data. What do they suggest about the underlying structure of the data?
#Analyze autocorrelation using ACF
#Perform a stationarity test (e.g., Augmented Dickey-Fuller test). What
are the null and alternative hypotheses, and what conclusion do you draw
from the test?
Augmented Dickey-Fuller Test
data: ts_data
Dickey-Fuller = -2.5885, Lag order = 6, p-value = 0.328
alternative hypothesis: stationary
#If the data is non-stationary, apply differencing and re-evaluate
stationarity. How many differences are required to achieve stationarity?
Augmented Dickey-Fuller Test
data: diff_data
Dickey-Fuller = -6.4632, Lag order = 6, p-value = 0.01
alternative hypothesis: stationary
#Model Selection & Estimation #Fit an ARIMA model to the crude oil price data. What are the optimal parameters (p, d, q), and how did you determine them? #Explain the role of seasonal differencing in a SARIMA model. Would you consider seasonal components in modeling crude oil prices?
Series: ts_data
ARIMA(1,1,0)
Coefficients:
ar1
0.4001
s.e. 0.0578
sigma^2 = 33.12: log likelihood = -795.02
AIC=1594.04 AICc=1594.08 BIC=1601.09
Training set error measures:
ME RMSE MAE MPE MAPE MASE
Training set 0.1076132 5.732362 4.387159 0.06247943 6.884854 0.2160971
ACF1
Training set 0.009670956
#Forecasting & Evaluation #Use your fitted model to generate out-of-sample forecasts for the next 12 months. How do the predicted values compare with the actual values (if available)?
$method
[1] "ARIMA(1,1,0)"
$model
Series: ts_data
ARIMA(1,1,0)
Coefficients:
ar1
0.4001
s.e. 0.0578
sigma^2 = 33.12: log likelihood = -795.02
AIC=1594.04 AICc=1594.08 BIC=1601.09
$level
[1] 80 95
$mean
Jan Feb Mar Apr May Jun Jul Aug
2024 76.63118 75.68333 75.30406 75.15230 75.09157 75.06728 75.05755 75.05366
Sep Oct Nov Dec
2024 75.05211 75.05148 75.05123 75.05113
$lower
80% 95%
Jan 2024 69.25554 65.35111
Feb 2024 62.99297 56.27509
Mar 2024 58.17293 49.10426
Apr 2024 54.24764 43.18138
May 2024 50.90273 38.09793
Jun 2024 47.95561 33.60356
Jul 2024 45.29638 29.54177
Aug 2024 42.85569 25.81111
Sep 2024 40.58747 22.34300
Oct 2024 38.45968 19.08915
Nov 2024 36.44906 16.01430
Dec 2024 34.53813 13.09183
$upper
80% 95%
Jan 2024 84.00683 87.91126
Feb 2024 88.37370 95.09157
Mar 2024 92.43519 101.50386
Apr 2024 96.05696 107.12321
May 2024 99.28041 112.08521
Jun 2024 102.17894 116.53099
Jul 2024 104.81872 120.57333
Aug 2024 107.25163 124.29621
Sep 2024 109.51674 127.76121
Oct 2024 111.64328 131.01381
Nov 2024 113.65341 134.08817
Dec 2024 115.56414 137.01043
#Evaluate the accuracy of your forecasts using metrics such as RMSE, MAE, and MAPE. What do these values tell you about the model’s performance? #Suppose there was a major geopolitical event affecting crude oil prices. How would you adjust your model to account for this external shock?
#Model Diagnostics & Interpretation #Examine the residuals of
your fitted ARIMA model. Are they approximately white noise? Support
your answer with residual plots and statistical tests.
Ljung-Box test
data: Residuals from ARIMA(1,1,0)
Q* = 25.535, df = 23, p-value = 0.3233
Model df: 1. Total lags used: 24
#Interpret the estimated coefficients of your ARIMA model. What do they tell you about the impact of past price movements on future prices?
ar1
0.4001378
#If your residuals exhibit volatility clustering, which model would you recommend to better capture this behavior? Why? #Discuss the limitations of time series modeling for crude oil price forecasting. What alternative approaches could improve prediction accuracy?
#build and evaluate an ARIMA Model #Check stationarity