Project 5 - Gas
Project 5 - Gas
Project 5 - Gas
Forecasting- Gas
0
Contents
1. PROJECT OBJECTIVE.......................................................................................................................2
2. EXPLORATORY DATA ANALYSIS – STEP BY STEP APPROACH..........................................................2
3. Exploratory Data Analysis..............................................................................................................2
3.1 Analysis..................................................................................................................................2
3.2 Additive and Multiplicative model.........................................................................................4
4. Stationarity....................................................................................................................................7
5. Train and Test................................................................................................................................8
6. Forecasting....................................................................................................................................8
6.1 Simple Forecasting.....................................................................................................................8
6.2 Exponential Forecasting on Gas..................................................................................................9
6.3 Holts method...............................................................................................................................9
6.4 Removing seasonality from the time series and testing Holt's efficacy again...........................10
6.6 Holt winters...............................................................................................................................11
6.7 Holt winters multiplicative model..............................................................................................12
7. ARIMA and Auto ARIMA..............................................................................................................13
8. Model Accuracy...........................................................................................................................15
8.1 Ljung box test............................................................................................................................15
8.2 Box-Pierce test...........................................................................................................................15
8.3 Accuracy of the forecast............................................................................................................15
1
1. PROJECT OBJECTIVE
The objective of the report is to explore the datasets on the Gas and to perform Principal Component
Analysis and Regression on the variables. The Case Study will be solved using R programming. The
report will mainly consist of the following:
i. Importing the dataset in R
ii. Examining the structure of the Gas dataset
iii. Graphically depicting the Gas dataset
iv. Examining the presence of stationarity
v. Forecast for 20 periods
vi. Check accuracy
2
There is no missing value. The dataset starts from January 1956 and ends on August 1995. Summary
output of the data indicates that the dataset might be skewed.
The Monthly, Quarterly and Annual Gas trends indicate that Gas consumption rises after 1980 with
high rate of growth after 1985.
On observing the Seasonality, it is seen that Gas consumption rises from April, is maximum in July
and then decreases.
The dataset has outliers in the month of March, May, July and August.
3
Boxplot
It is important to adjust the time series as each month has different number of days. The adjusted
series trend is as follows:
4
Similar trend is observed in case of Multiplicative time series
5
Loess ("locally-weighted scatterplot smoothing") uses local regression. A window of a specified
width is placed over the data. The wider the window, the smoother the resulting loess curve. If you
think the seasonal pattern is constant through time, you should set this parameter to a big value, so
that you use the entire data to perform your analysis.
6
Summary:
Seasonality is strong but consistent.
Trend - 1950 to 1970, there was a strong growth and after that, the noises went up started from
1990 as well.
Additive and Multiplicative gives same results. Hence, the dataset (time series) is additive.
As the time series increases in magnitude, the seasonal variation increases as well.
4. Stationarity
Stationarity is important in time series forecasting. It is seen through KPSS and ADF that time series
is not stationary.
data: gas.ts
KPSS Level = 4.3406, Truncation lag parameter = 5, p-value = 0.01
data: gas.ts
Dickey-Fuller = 0.73972, Lag order = 6, p-value = 0.99
alternative hypothesis: stationary
7
ACF and PACF plots ( another method to observe stationarity)
6. Forecasting
6.1 Simple Forecasting
On plotting the forecast it is seen that for 20 periods,
For 12 periods
8
Accuracy:
ME RMSE MAE MPE MAPE ACF1 Theil's U
Test set 2153.958 4904.692 3809.181 5.203979 12.32112 0.703002 1.638023
s
The forecasts indicate rising trend in the next 12 periods.
Initial states:
l = 1928.6188
sigma: 1702.584
9
Theil's U
Training set NA
Test set 2.114935
The forecasts indicate stagnant trend in the next 12 periods.
Smoothing parameters:
alpha = 0.9642
beta = 0.7143
Initial states:
l = 1818.4411
b = 74.9327
sigma: 951.2777
10
6.4 Removing seasonality from the time series and testing Holt's efficacy again
11
6.6 Holt winters
Smoothing parameters:
alpha = 0.2596
beta = 0.0202
gamma = 0.7404
phi = 0.98
Initial states:
l = 2230.6766
b = 7.2177
s = -1034.848 -532.6302 71.5714 516.9939 1504.973 1781.418
1320.311 588.8141 -554.9172 -747.7943 -1420.407 -1493.485
sigma: 605.0447
accuracy(gashw.f1, gas.test)
ME RMSE MAE MPE MAPE MASE
Training set 81.59189 586.9159 387.415 0.9087759 7.175919 0.3939828
Test set 2233.13630 2602.5705 2233.136 7.2892297 7.289230 2.2709944
ACF1 Theil's U
Training set 0.4235979 NA
Test set 0.4241718 0.9189364
The forecasts indicate seasonal trend in the next 12 periods.
12
6.7 Holt winters multiplicative model
Smoothing parameters:
alpha = 0.792
beta = 0.051
gamma = 2e-04
phi = 0.9797
Initial states:
l = 2034.7689
b = 3.6615
s = 0.8541 0.917 1.0114 1.0758 1.218 1.2715
1.1749 1.0929 0.9184 0.8838 0.7932 0.789
sigma: 0.0454
Coefficients:
ar1 ma1
0.5134 -0.0584
s.e. 0.0850 0.0893
13
Fitting with Auto ARIMA
ARIMA(1,1,0)
Coefficients:
ar1
0.4668
s.e. 0.0522
14
Auto ARIMA also fits the same p and q parameters for the model, but has a slightly lower AIC.
15
8. Model Accuracy
8.1 Ljung box test
H0: Residuals are independent
Ha: Residuals are not independent
Box-Pierce test
data: gasarima$residuals
X-squared = 0.012044, df = 1, p-value = 0.9126
16