Australian monthly gas production dataset summary

https://rdrr.io/cran/forecast/man/gas.html

Australian monthly gas production: 1956–1995.

library(forecast)
Registered S3 method overwritten by 'quantmod':
  method            from
  as.zoo.data.frame zoo 
library(TTR)
library(tseries)

    ‘tseries’ version: 0.10-50

    ‘tseries’ is a package for time series analysis and computational finance.

    See ‘library(help="tseries")’ for details.
data(gas, package='forecast')
head(gas)
      Jan  Feb  Mar  Apr  May  Jun
1956 1709 1646 1794 1878 2173 2321
summary(gas)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
   1646    2675   16788   21415   38628   66600 
plot.ts(gas, xlab="Time", ylab="Gas production")

ggseasonplot(gas)

plot.ts(log(gas), xlab="Time", ylab="Gas production")

plot.ts(SMA(log(gas), n = 50), xlab="Time", ylab="Gas production")

plot(decompose(log(gas)))

Auto- and Cross- Covariance and -Correlation Function Estimation

acf(log(gas))

pacf(log(gas))

Holt-Winters Filtering

hw1 <- HoltWinters(log(gas))
hw1
Holt-Winters exponential smoothing with trend and additive seasonal component.

Call:
HoltWinters(x = log(gas))

Smoothing parameters:
 alpha: 0.6640584
 beta : 0.01627736
 gamma: 0.2511116

Coefficients:
            [,1]
a   10.817740200
b    0.002421792
s1   0.081519909
s2   0.005080236
s3  -0.074841438
s4  -0.175083641
s5  -0.205117401
s6  -0.188208891
s7  -0.106375501
s8  -0.063333907
s9   0.101100492
s10  0.178808443
s11  0.241557419
s12  0.203283289
plot(hw1)

hw2 <- forecast:::forecast.HoltWinters(hw1, h = 50)
plot(hw2)

Augmented Dickey-Fuller Test

adf.test(log(gas))

    Augmented Dickey-Fuller Test

data:  log(gas)
Dickey-Fuller = -0.515, Lag order = 7, p-value = 0.9811
alternative hypothesis: stationary
plot(diff(log(gas)))

plot(diff(diff(log(gas))))

ARIMA model

fit <- auto.arima(log(gas), stationary = FALSE)
autoplot(forecast(fit, level = c(95), h = 50))

acf(fit$residuals)

Box.test(fit$residuals, type="Ljung-Box")

    Box-Ljung test

data:  fit$residuals
X-squared = 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