Report on Stationarity, Impact of Components and Modelling of a dataset

The report shows the investigation of monthly averages of ASX All Ordinaries Price Index, Gold price, Crude Oil and Copper prices starting from January 2004. The report focuses on following three components:

The objective of this report is to give analysis of the time series.

The following packages are used to complete the mentioned tasks:

library(TSA)

library(urca)

library(readr)

library(forecast)

library(x12)

library(dLagM)

library(tseries)

Importing Dataset and Creating time series

rm(list=ls())  #clears the memory
setwd("C:/Users/Wajahath/Desktop/Analytics/Sem 2/Forcasting/Assignment 1") #sets working directory

ASXD <- read.csv("ASX_data.csv") #reads the file
class(ASXD)   #class of file
## [1] "data.frame"
head(ASXD)
##   ASX.price Gold.price Crude.Oil..Brent._USD.bbl Copper_USD.tonne
## 1    2935.4      611.9                     31.29            1,650
## 2    2778.4      603.3                     32.65            1,682
## 3    2848.6      565.7                     30.34            1,656
## 4    2970.9      538.6                     25.02            1,588
## 5    2979.8      549.4                     25.81            1,651
## 6    2999.7      535.9                     27.55            1,685
class(ASXD$ASX.price) #class of ASX price
## [1] "numeric"
ASXprice = ts(ASXD$ASX.price, start = c(2004, 1),frequency = 12)    #converts number class to time series
head(ASXprice)
##         Jan    Feb    Mar    Apr    May    Jun
## 2004 2935.4 2778.4 2848.6 2970.9 2979.8 2999.7
class(ASXD$Gold.price) #class of Gold price
## [1] "factor"
ASXD$Gold.price = gsub(",","", ASXD$Gold.price) #Removes the comas from dataset
ASXD$Gold.price = as.numeric(as.character(ASXD$Gold.price)) #Converts character class to numeric
Goldprice= ts(ASXD$Gold.price, start = c(2004, 1),frequency = 12) #Converts numeric to time series
head(Goldprice)
##        Jan   Feb   Mar   Apr   May   Jun
## 2004 611.9 603.3 565.7 538.6 549.4 535.9
class(ASXD$Crude.Oil..Brent._USD.bbl) #class of Crude oil
## [1] "numeric"
CrudeOilprice = ts(ASXD$Crude.Oil..Brent._USD.bbl, start = c(2004, 1),frequency = 12) #Converts numeric to time series
head(CrudeOilprice)
##        Jan   Feb   Mar   Apr   May   Jun
## 2004 31.29 32.65 30.34 25.02 25.81 27.55
class(ASXD$Copper_USD.tonne) #class of copper
## [1] "factor"
ASXD$Copper_USD.tonne = gsub(",","", ASXD$Copper_USD.tonne) #Removes commas from the data
ASXD$Copper_USD.tonne = as.numeric(as.character(ASXD$Copper_USD.tonne)) #Converts character to numeric
Copperprice = ts(ASXD$Copper_USD.tonne, start = c(2004, 1),frequency = 12) #Converts numeric to time series
head(Copperprice)
##       Jan  Feb  Mar  Apr  May  Jun
## 2004 1650 1682 1656 1588 1651 1685

Existence of Non-Stationarity

The task here is to check if the time series is stationary or non-stationary. The foremost way to check for the same is by visualization which is advocated by ACF and PACF. The aunthenticity of this is achieved by performing unit root test. The two tests are augmented Dickey-Fuller (ADF) and Phillips-Perron (PP) tests of which I am only considering the ADF test.

The process demands the parameters to be converted into a time series initially and then plotting on the graphs. Lets see how each parameter of the dataset fairs.

Descriptive Analysis

The five main patterns we could infer from a time series plot are:

#plots the visualization of series

par(mfrow=c(2,2))
plot(ASXprice, ylab="Avg monthly ASX price", xlab = "Year", main = "ASX price series")
plot(Goldprice, ylab="Avg monthly Gold price", xlab = "Year", main = "Gold price series")
plot(CrudeOilprice, ylab="Avg monthly ASX price", xlab = "Year", main = "Crude oil price series")
plot(Copperprice, ylab="Avg monthly Copper price", xlab = "Year", main = "Copper price series")

ASX

Gold

Crude Oil

Copper

ACF and PACF

#ACF and PACF
par(mfrow=c(2,4)) # Put the ACF and PACF plots next to each other

acf(ASXprice, lag.max = 24, main = "ACF of avg monthly ASX price")
pacf(ASXprice, lag.max = 24, main = "PACF of avg monthly ASX price")

acf(Goldprice, lag.max = 24, main = "ACF of avg monthly Gold price")
pacf(Goldprice, lag.max = 24, main = "PACF of avg monthly Gold price")

acf(CrudeOilprice, lag.max = 24, main = "ACF of avg monthly Crude oil price")
pacf(CrudeOilprice, lag.max = 24, main = "PACF of avg monthly Crude oil price")

acf(Copperprice, lag.max = 24, main = "ACF of avg monthly Copper price")
pacf(Copperprice, lag.max = 24, main = "PACF of avg monthly Copper price")

ADF Test

#Checking for lag length of ASX

k1 = ar(ASXprice)$order 
k1
## [1] 2
ASXprice.adf = ur.df(ASXprice, type = "none", lags = 2 ,  selectlags =  "AIC") #ADF of ASX
summary(ASXprice.adf)
## 
## ############################################### 
## # Augmented Dickey-Fuller Test Unit Root Test # 
## ############################################### 
## 
## Test regression none 
## 
## 
## Call:
## lm(formula = z.diff ~ z.lag.1 - 1 + z.diff.lag)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -696.15 -108.92   34.02  133.30  792.06 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)
## z.lag.1     0.001504   0.003321   0.453    0.651
## z.diff.lag1 0.076549   0.080116   0.955    0.341
## z.diff.lag2 0.130992   0.079970   1.638    0.103
## 
## Residual standard error: 202.7 on 155 degrees of freedom
## Multiple R-squared:  0.02775,    Adjusted R-squared:  0.008932 
## F-statistic: 1.475 on 3 and 155 DF,  p-value: 0.2236
## 
## 
## Value of test-statistic is: 0.4529 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau1 -2.58 -1.95 -1.62
#Checking for lag length of Gold
k2 = ar(Goldprice)$order
k2
## [1] 1
Goldprice.adf = ur.df(Goldprice, type = "none", lags = 1,  selectlags =  "AIC") #ADF of Gold
summary(Goldprice.adf)
## 
## ############################################### 
## # Augmented Dickey-Fuller Test Unit Root Test # 
## ############################################### 
## 
## Test regression none 
## 
## 
## Call:
## lm(formula = z.diff ~ z.lag.1 - 1 + z.diff.lag)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -138.655  -26.586   -2.016   22.726  206.439 
## 
## Coefficients:
##            Estimate Std. Error t value Pr(>|t|)
## z.lag.1    0.003218   0.003322   0.969    0.334
## z.diff.lag 0.122451   0.079603   1.538    0.126
## 
## Residual standard error: 52.57 on 157 degrees of freedom
## Multiple R-squared:  0.02351,    Adjusted R-squared:  0.01107 
## F-statistic:  1.89 on 2 and 157 DF,  p-value: 0.1545
## 
## 
## Value of test-statistic is: 0.9687 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau1 -2.58 -1.95 -1.62
#Checking for lag length of Crude Oil
k3 = ar(CrudeOilprice)$order
k3
## [1] 3
CrudeOilprice.adf = ur.df(CrudeOilprice, type = "none", lags = 3,  selectlags =  "AIC") #ADF of Crude Oil
summary(CrudeOilprice.adf)
## 
## ############################################### 
## # Augmented Dickey-Fuller Test Unit Root Test # 
## ############################################### 
## 
## Test regression none 
## 
## 
## Call:
## lm(formula = z.diff ~ z.lag.1 - 1 + z.diff.lag)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -19.943  -3.549   1.248   3.982  15.176 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## z.lag.1    -0.003793   0.005835  -0.650    0.517    
## z.diff.lag  0.399011   0.073572   5.423  2.2e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 5.863 on 155 degrees of freedom
## Multiple R-squared:  0.1601, Adjusted R-squared:  0.1493 
## F-statistic: 14.78 on 2 and 155 DF,  p-value: 1.339e-06
## 
## 
## Value of test-statistic is: -0.65 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau1 -2.58 -1.95 -1.62
#Checking for lag length of Copper
k4 = ar(Copperprice)$order
k4
## [1] 2
Copperprice.adf = ur.df(Copperprice, type = "none", lags = 2,  selectlags =  "AIC") #ADF of Copper
summary(Copperprice.adf)
## 
## ############################################### 
## # Augmented Dickey-Fuller Test Unit Root Test # 
## ############################################### 
## 
## Test regression none 
## 
## 
## Call:
## lm(formula = z.diff ~ z.lag.1 - 1 + z.diff.lag)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1861.62  -167.44    35.95   248.39  2829.64 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## z.lag.1    -0.002248   0.005792  -0.388    0.698    
## z.diff.lag  0.307584   0.076382   4.027  8.8e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 464.6 on 156 degrees of freedom
## Multiple R-squared:  0.09423,    Adjusted R-squared:  0.08262 
## F-statistic: 8.115 on 2 and 156 DF,  p-value: 0.000444
## 
## 
## Value of test-statistic is: -0.3881 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau1 -2.58 -1.95 -1.62

Impact of components of time series on dataset

The usual components of a time series are,

It is very much important to decompose the time series into different components. This helps in observing individual effects and historical effects on existing components. Also, one can use this decomposition to visualise and get more information on the components. Note that one must not use decomposition methods to evaluate existence of components.

Now, lets look at lambda values and see if there is a need of transformation and then differencing before decomposing the data.

#Lambda values
ASXlambda = BoxCox.lambda(ASXprice) 
Goldlambda = BoxCox.lambda(Goldprice) 
CrudeOillambda = BoxCox.lambda(CrudeOilprice) 
Copperlambda = BoxCox.lambda(Copperprice)
cbind(ASXlambda, Goldlambda, CrudeOillambda, Copperlambda)
##      ASXlambda Goldlambda CrudeOillambda Copperlambda
## [1,]  1.999924   0.976695     -0.8304136    0.9336783

Let us now compute transformation of ASX price and Crude oil price.

#ASX Transformation
ASXlambda 
## [1] 1.999924
BC.ASX = ((ASXprice^(ASXlambda)) - 1) / ASXlambda
plot(BC.ASX,ylab='ASX price Index',xlab='Year',type='o', main="Box-Cox Transformed ASX price Index")

#Crudeoil Transformation
CrudeOillambda
## [1] -0.8304136
BC.Crudeoil = ((CrudeOilprice^(CrudeOillambda)) - 1) / CrudeOillambda
plot(BC.Crudeoil,ylab='Crudeoil price',xlab='Year',type='o', main="Box-Cox Transformed Crudeoil price")

One could infer that the series is not stationary after transformation. So lets compute the differencing for all the series now.

#ASX differencing
ASXdiff = diff(BC.ASX)
plot(ASXdiff,ylab='ASX prices',xlab='Year', main = "Time series plot of the first difference of ASX prices")

#Gold differencing
Golddiff = diff(CrudeOilprice)
plot(Golddiff,ylab='Gold prices',xlab='Year', main = "Time series plot of the first difference of Gold prices")

#Crudeoil differencing
Crudeoildiff = diff(BC.Crudeoil)
plot(Crudeoildiff,ylab='Crudeoil prices',xlab='Year', main = "Time series plot of the first difference of Crudeoil prices")

#Copper differencing
Copperdiff = diff(Copperprice)
plot(Copperdiff,ylab='Copper prices',xlab='Year', main = "Time series plot of the first difference of Copper prices")

Since the pattern of the series looks stationary, lets confirm it with ADF test on each of these.

#ADF test of all series

ASXtest = adf.test(ASXdiff) 
## Warning in adf.test(ASXdiff): p-value smaller than printed p-value
ASXtest
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ASXdiff
## Dickey-Fuller = -4.4343, Lag order = 5, p-value = 0.01
## alternative hypothesis: stationary
Goldtest = adf.test(Golddiff)
## Warning in adf.test(Golddiff): p-value smaller than printed p-value
Goldtest
## 
##  Augmented Dickey-Fuller Test
## 
## data:  Golddiff
## Dickey-Fuller = -5.4261, Lag order = 5, p-value = 0.01
## alternative hypothesis: stationary
Crudetest =adf.test(Crudeoildiff)
## Warning in adf.test(Crudeoildiff): p-value smaller than printed p-value
Crudetest
## 
##  Augmented Dickey-Fuller Test
## 
## data:  Crudeoildiff
## Dickey-Fuller = -5.5931, Lag order = 5, p-value = 0.01
## alternative hypothesis: stationary
Coppertest = adf.test(Copperdiff)
## Warning in adf.test(Copperdiff): p-value smaller than printed p-value
Coppertest
## 
##  Augmented Dickey-Fuller Test
## 
## data:  Copperdiff
## Dickey-Fuller = -5.478, Lag order = 5, p-value = 0.01
## alternative hypothesis: stationary

As the p-value is less than the 5% significance level in all the series, we could conclude the differenced series is STATIONARY.

Impact of Trend and Seasonality

The effect/impact of trend and seasonality can be analysed by decomposing the series. The decomposition here is done by using X12 decomposistion. We also consider STL decomposition.

ASX price Components

#ASX Decomposition
ASXdecom = x12(ASXprice)
plot(ASXdecom , sa=TRUE , trend=TRUE , forecast = TRUE)

plotSeasFac(ASXdecom)

ASXdecomstl <- stl(ASXprice,t.window=15, s.window="periodic", robust=TRUE) 
plot(ASXdecomstl)

Gold price components

#Gold Decomposition
Golddecom = x12(Goldprice)
plot(Golddecom , sa=TRUE , trend=TRUE , forecast = TRUE)

plotSeasFac(Golddecom)

Golddecomstl <- stl(Goldprice,t.window=15, s.window="periodic", robust=TRUE) 
plot(Golddecomstl)

Crudeoil price components

#Crudeoil Decomposition
Crudeoildecom = x12(CrudeOilprice)
plot(Crudeoildecom , sa=TRUE , trend=TRUE , forecast = TRUE)

plotSeasFac(Crudeoildecom)

Crudeoildecomstl <- stl(CrudeOilprice,t.window=15, s.window="periodic", robust=TRUE) 
plot(Crudeoildecomstl)

Copper price components

#Copper Decomposition
Copperdecom = x12(Copperprice)
plot(Copperdecom , sa=TRUE , trend=TRUE , forecast = TRUE)

plotSeasFac(Copperdecom)

Copperdecomstl <- stl(Copperprice,t.window=15, s.window="periodic", robust=TRUE) 
plot(Copperdecomstl)

Model Fitting

To find the best model that would fit ASX ordinaries, we undertake a systematic approach of finding models from DLM, Polynomial, Koecks and ADLM models.

We here try to find a good DLM model that fits the data appropriately.

AGCC <- cbind(ASXprice,Goldprice,CrudeOilprice,Copperprice)

cor(AGCC) #Corelationtest
##                ASXprice Goldprice CrudeOilprice Copperprice
## ASXprice      1.0000000 0.3431908     0.3290338   0.5617864
## Goldprice     0.3431908 1.0000000     0.4366382   0.5364213
## CrudeOilprice 0.3290338 0.4366382     1.0000000   0.8664296
## Copperprice   0.5617864 0.5364213     0.8664296   1.0000000

Off the four variables, since ASX price Index is considered as dependent variable, it takes up the y-axis. We compare this with other three variables.

Following is the function which plots all four DLMS.

DistLagMod <- function(x,y){
 for ( i in 1:10){
  model1.1 = dlm( x = as.vector(x) , y = as.vector(y), q = i )
  cat("q = ", i, "AIC = ", AIC(model1.1$model), "BIC = ", BIC(model1.1$model),"\n")
}
  
cat("\nFinite lag length based on AIC-BIC\n")
model1 = dlm( x = as.vector(x) , y = as.vector(y), q = 9 )
summary(model1)

cat("\nPloynomial DLM\n")
model2 = polyDlm(x = as.vector(x) , y = as.vector(y) , q = 2 , k = 2 , show.beta = TRUE)
summary(model2)

cat("\nKoyk model\n")
model3 = koyckDlm(x = as.vector(x) , y = as.vector(y))
summary(model3)

cat("\nARDLM model\n")
model4 = ardlDlm(x = as.vector(x) , y = as.vector(y), p = 1 , q = 1 )
summary(model4)

for (i in 1:10){
  for(j in 1:5){
    model4.1 = ardlDlm(x = as.vector(x) , y = as.vector(y), p = i , q = j )
    cat("p = ", i, "q = ", j, "AIC = ", AIC(model4.1$model), "BIC = ", BIC(model4.1$model),"\n")
  }
}


checkresiduals(model1$model)
checkresiduals(model2$model)
checkresiduals(model3$model)
checkresiduals(model4$model)

}

DistLagMod(Goldprice, ASXprice)   #ASXprice vs Goldprice
## q =  1 AIC =  2613.609 BIC =  2625.91 
## q =  2 AIC =  2596.292 BIC =  2611.637 
## q =  3 AIC =  2579.215 BIC =  2597.59 
## q =  4 AIC =  2562.296 BIC =  2583.69 
## q =  5 AIC =  2544.887 BIC =  2569.286 
## q =  6 AIC =  2527.575 BIC =  2554.966 
## q =  7 AIC =  2510.535 BIC =  2540.905 
## q =  8 AIC =  2493.885 BIC =  2527.22 
## q =  9 AIC =  2476.983 BIC =  2513.27 
## q =  10 AIC =  2460.345 BIC =  2499.57 
## 
## Finite lag length based on AIC-BIC
## 
## Call:
## lm(formula = model.formula, data = design)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1484.01  -590.23    13.97   473.71  1991.28 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 4452.20100  223.27538  19.940   <2e-16 ***
## x.t           -0.35288    1.27113  -0.278    0.782    
## x.1           -0.10591    1.88058  -0.056    0.955    
## x.2            0.02149    1.91708   0.011    0.991    
## x.3           -0.07972    1.93268  -0.041    0.967    
## x.4           -0.25836    1.93610  -0.133    0.894    
## x.5            0.36953    1.93817   0.191    0.849    
## x.6            0.16311    1.95298   0.084    0.934    
## x.7            0.70404    1.94616   0.362    0.718    
## x.8           -0.21513    1.91991  -0.112    0.911    
## x.9            0.16715    1.29373   0.129    0.897    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 802.4 on 141 degrees of freedom
## Multiple R-squared:  0.05795,    Adjusted R-squared:  -0.008866 
## F-statistic: 0.8673 on 10 and 141 DF,  p-value: 0.5654
## 
## AIC and BIC values for the model:
##        AIC     BIC
## 1 2476.983 2513.27
## 
## Ploynomial DLM
## Estimates and t-tests for beta coefficients:
##        Estimate Std. Error t value P(>|t|)
## beta.0    0.396       1.28   0.310   0.757
## beta.1   -0.233       1.90  -0.122   0.903
## beta.2    0.536       1.27   0.421   0.675
## 
## Call:
## "Y ~ (Intercept) + X.t"
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1632.50  -700.82     4.61   549.72  2213.87 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 3998.3587   212.3161  18.832   <2e-16 ***
## z.t0           0.3958     1.2767   0.310    0.757    
## z.t1          -1.3268     5.7723  -0.230    0.819    
## z.t2           0.6983     2.8546   0.245    0.807    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 834.5 on 155 degrees of freedom
## Multiple R-squared:  0.1015, Adjusted R-squared:  0.08409 
## F-statistic: 5.835 on 3 and 155 DF,  p-value: 0.0008385
## 
## 
## Koyk model
## 
## Call:
## "Y ~ (Intercept) + Y.1 + X.t"
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -682.19 -105.44   15.86  135.04  783.60 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 1.902e+02  8.958e+01   2.123   0.0353 *  
## Y.1         9.635e-01  1.909e-02  50.469   <2e-16 ***
## X.t         2.595e-03  4.304e-02   0.060   0.9520    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 201.4 on 157 degrees of freedom
## Multiple R-Squared: 0.9488,  Adjusted R-squared: 0.9481 
## Wald test:  1454 on 2 and 157 DF,  p-value: < 2.2e-16 
## 
## Diagnostic tests:
## NULL
## 
##                            alpha        beta       phi
## Geometric coefficients:  5205.15 0.002595168 0.9634602
## 
## ARDLM model
## 
## Time series regression with "ts" data:
## Start = 2, End = 161
## 
## Call:
## dynlm(formula = as.formula(model.text), data = data, start = 1)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -598.9 -102.9   10.4  119.5  724.6 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 182.80452   85.05812   2.149   0.0332 *  
## X.t          -1.24911    0.29162  -4.283 3.21e-05 ***
## X.1           1.23169    0.28976   4.251 3.66e-05 ***
## Y.1           0.97172    0.01812  53.624  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 191.1 on 156 degrees of freedom
## Multiple R-squared:  0.9542, Adjusted R-squared:  0.9533 
## F-statistic:  1083 on 3 and 156 DF,  p-value: < 2.2e-16
## 
## p =  1 q =  1 AIC =  2140.897 BIC =  2156.273 
## p =  1 q =  2 AIC =  2128.524 BIC =  2146.938 
## p =  1 q =  3 AIC =  2113.99 BIC =  2135.428 
## p =  1 q =  4 AIC =  2102.754 BIC =  2127.204 
## p =  1 q =  5 AIC =  2092.194 BIC =  2119.643 
## p =  2 q =  1 AIC =  2128.627 BIC =  2147.04 
## p =  2 q =  2 AIC =  2130.523 BIC =  2152.005 
## p =  2 q =  3 AIC =  2115.89 BIC =  2140.39 
## p =  2 q =  4 AIC =  2104.694 BIC =  2132.2 
## p =  2 q =  5 AIC =  2094.14 BIC =  2124.639 
## p =  3 q =  1 AIC =  2118.109 BIC =  2139.547 
## p =  3 q =  2 AIC =  2120.027 BIC =  2144.528 
## p =  3 q =  3 AIC =  2117.305 BIC =  2144.868 
## p =  3 q =  4 AIC =  2105.731 BIC =  2136.293 
## p =  3 q =  5 AIC =  2095.264 BIC =  2128.812 
## p =  4 q =  1 AIC =  2107.002 BIC =  2131.452 
## p =  4 q =  2 AIC =  2108.914 BIC =  2136.42 
## p =  4 q =  3 AIC =  2106.276 BIC =  2136.839 
## p =  4 q =  4 AIC =  2107.456 BIC =  2141.074 
## p =  4 q =  5 AIC =  2097.01 BIC =  2133.608 
## p =  5 q =  1 AIC =  2094.908 BIC =  2122.357 
## p =  5 q =  2 AIC =  2096.86 BIC =  2127.359 
## p =  5 q =  3 AIC =  2094.144 BIC =  2127.692 
## p =  5 q =  4 AIC =  2095.425 BIC =  2132.023 
## p =  5 q =  5 AIC =  2097.324 BIC =  2136.972 
## p =  6 q =  1 AIC =  2083.087 BIC =  2113.521 
## p =  6 q =  2 AIC =  2084.993 BIC =  2118.471 
## p =  6 q =  3 AIC =  2081.777 BIC =  2118.298 
## p =  6 q =  4 AIC =  2083.115 BIC =  2122.68 
## p =  6 q =  5 AIC =  2084.976 BIC =  2127.584 
## p =  7 q =  1 AIC =  2072.69 BIC =  2106.097 
## p =  7 q =  2 AIC =  2074.588 BIC =  2111.032 
## p =  7 q =  3 AIC =  2071.471 BIC =  2110.952 
## p =  7 q =  4 AIC =  2072.806 BIC =  2115.324 
## p =  7 q =  5 AIC =  2074.667 BIC =  2120.221 
## p =  8 q =  1 AIC =  2060.657 BIC =  2097.022 
## p =  8 q =  2 AIC =  2062.526 BIC =  2101.922 
## p =  8 q =  3 AIC =  2059.768 BIC =  2102.194 
## p =  8 q =  4 AIC =  2060.894 BIC =  2106.35 
## p =  8 q =  5 AIC =  2062.836 BIC =  2111.323 
## p =  9 q =  1 AIC =  2046.919 BIC =  2086.229 
## p =  9 q =  2 AIC =  2048.65 BIC =  2090.985 
## p =  9 q =  3 AIC =  2046.025 BIC =  2091.383 
## p =  9 q =  4 AIC =  2046.982 BIC =  2095.364 
## p =  9 q =  5 AIC =  2048.757 BIC =  2100.163 
## p =  10 q =  1 AIC =  2036.551 BIC =  2078.793 
## p =  10 q =  2 AIC =  2038.268 BIC =  2083.528 
## p =  10 q =  3 AIC =  2035.644 BIC =  2083.92 
## p =  10 q =  4 AIC =  2036.587 BIC =  2087.88 
## p =  10 q =  5 AIC =  2038.35 BIC =  2092.661

## 
##  Breusch-Godfrey test for serial correlation of order up to 10
## 
## data:  Residuals
## LM test = 7.9182, df = 10, p-value = 0.6368
DistLagMod(CrudeOilprice, ASXprice) #ASXprice vs CrudeOil price
## q =  1 AIC =  2614.698 BIC =  2626.998 
## q =  2 AIC =  2596.715 BIC =  2612.059 
## q =  3 AIC =  2579.101 BIC =  2597.477 
## q =  4 AIC =  2561.888 BIC =  2583.281 
## q =  5 AIC =  2544.936 BIC =  2569.335 
## q =  6 AIC =  2527.701 BIC =  2555.091 
## q =  7 AIC =  2510.754 BIC =  2541.124 
## q =  8 AIC =  2493.914 BIC =  2527.249 
## q =  9 AIC =  2476.871 BIC =  2513.158 
## q =  10 AIC =  2459.842 BIC =  2499.066 
## 
## Finite lag length based on AIC-BIC
## 
## Call:
## lm(formula = model.formula, data = design)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1563.08  -643.18   -11.17   571.05  1707.84 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 4641.7675   196.4286  23.631   <2e-16 ***
## x.t            8.8037    11.3647   0.775    0.440    
## x.1            2.8911    19.0087   0.152    0.879    
## x.2           -2.1607    19.2799  -0.112    0.911    
## x.3            2.9569    19.4045   0.152    0.879    
## x.4           -7.0213    19.3913  -0.362    0.718    
## x.5            0.7784    19.3589   0.040    0.968    
## x.6            1.7254    19.4044   0.089    0.929    
## x.7           -2.5268    19.5635  -0.129    0.897    
## x.8           -2.7015    19.3336  -0.140    0.889    
## x.9            0.8312    11.3876   0.073    0.942    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 802.1 on 141 degrees of freedom
## Multiple R-squared:  0.05864,    Adjusted R-squared:  -0.008123 
## F-statistic: 0.8783 on 10 and 141 DF,  p-value: 0.5551
## 
## AIC and BIC values for the model:
##        AIC      BIC
## 1 2476.871 2513.158
## 
## Ploynomial DLM
## Estimates and t-tests for beta coefficients:
##        Estimate Std. Error t value P(>|t|)
## beta.0    13.70       11.6   1.180   0.239
## beta.1     3.18       19.1   0.167   0.868
## beta.2    -8.41       11.5  -0.730   0.467
## 
## Call:
## "Y ~ (Intercept) + X.t"
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1616.4  -703.8   -77.9   657.5  1783.6 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 4209.0519   179.6342  23.431   <2e-16 ***
## z.t0          13.6870    11.5777   1.182    0.239    
## z.t1          -9.9541    57.9232  -0.172    0.864    
## z.t2          -0.5483    28.7836  -0.019    0.985    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 835.6 on 155 degrees of freedom
## Multiple R-squared:  0.09909,    Adjusted R-squared:  0.08165 
## F-statistic: 5.683 on 3 and 155 DF,  p-value: 0.001019
## 
## 
## Koyk model
## 
## Call:
## "Y ~ (Intercept) + Y.1 + X.t"
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -683.91 -108.66   13.68  139.77  762.55 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 209.89536   87.89368   2.388   0.0181 *  
## Y.1           0.97537    0.01905  51.193   <2e-16 ***
## X.t          -0.99907    0.58045  -1.721   0.0872 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 201.1 on 157 degrees of freedom
## Multiple R-Squared: 0.949,   Adjusted R-squared: 0.9483 
## Wald test:  1461 on 2 and 157 DF,  p-value: < 2.2e-16 
## 
## Diagnostic tests:
## NULL
## 
##                             alpha       beta       phi
## Geometric coefficients:  8522.034 -0.9990694 0.9753703
## 
## ARDLM model
## 
## Time series regression with "ts" data:
## Start = 2, End = 161
## 
## Call:
## dynlm(formula = as.formula(model.text), data = data, start = 1)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -684.06 -111.57   -1.77  138.90  719.35 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 211.45397   85.03705   2.487  0.01395 *  
## X.t           7.45111    2.46199   3.026  0.00290 ** 
## X.1          -8.17917    2.44422  -3.346  0.00103 ** 
## Y.1           0.97067    0.01837  52.827  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 194.5 on 156 degrees of freedom
## Multiple R-squared:  0.9525, Adjusted R-squared:  0.9516 
## F-statistic:  1044 on 3 and 156 DF,  p-value: < 2.2e-16
## 
## p =  1 q =  1 AIC =  2146.524 BIC =  2161.9 
## p =  1 q =  2 AIC =  2134.107 BIC =  2152.521 
## p =  1 q =  3 AIC =  2121.07 BIC =  2142.508 
## p =  1 q =  4 AIC =  2109.4 BIC =  2133.85 
## p =  1 q =  5 AIC =  2098.335 BIC =  2125.784 
## p =  2 q =  1 AIC =  2132.312 BIC =  2150.726 
## p =  2 q =  2 AIC =  2134.235 BIC =  2155.718 
## p =  2 q =  3 AIC =  2122.356 BIC =  2146.857 
## p =  2 q =  4 AIC =  2110.793 BIC =  2138.299 
## p =  2 q =  5 AIC =  2099.752 BIC =  2130.251 
## p =  3 q =  1 AIC =  2121.919 BIC =  2143.357 
## p =  3 q =  2 AIC =  2123.835 BIC =  2148.335 
## p =  3 q =  3 AIC =  2124.324 BIC =  2151.887 
## p =  3 q =  4 AIC =  2112.401 BIC =  2142.963 
## p =  3 q =  5 AIC =  2101.35 BIC =  2134.899 
## p =  4 q =  1 AIC =  2111.383 BIC =  2135.832 
## p =  4 q =  2 AIC =  2113.294 BIC =  2140.8 
## p =  4 q =  3 AIC =  2113.805 BIC =  2144.367 
## p =  4 q =  4 AIC =  2114.384 BIC =  2148.003 
## p =  4 q =  5 AIC =  2103.342 BIC =  2139.94 
## p =  5 q =  1 AIC =  2097.076 BIC =  2124.525 
## p =  5 q =  2 AIC =  2099.041 BIC =  2129.54 
## p =  5 q =  3 AIC =  2099.518 BIC =  2133.066 
## p =  5 q =  4 AIC =  2099.845 BIC =  2136.443 
## p =  5 q =  5 AIC =  2100.917 BIC =  2140.566 
## p =  6 q =  1 AIC =  2086.125 BIC =  2116.559 
## p =  6 q =  2 AIC =  2088.117 BIC =  2121.595 
## p =  6 q =  3 AIC =  2088.596 BIC =  2125.117 
## p =  6 q =  4 AIC =  2088.856 BIC =  2128.421 
## p =  6 q =  5 AIC =  2090.082 BIC =  2132.69 
## p =  7 q =  1 AIC =  2075.738 BIC =  2109.145 
## p =  7 q =  2 AIC =  2077.728 BIC =  2114.172 
## p =  7 q =  3 AIC =  2078.072 BIC =  2117.552 
## p =  7 q =  4 AIC =  2078.36 BIC =  2120.877 
## p =  7 q =  5 AIC =  2079.571 BIC =  2125.125 
## p =  8 q =  1 AIC =  2062.676 BIC =  2099.041 
## p =  8 q =  2 AIC =  2064.671 BIC =  2104.067 
## p =  8 q =  3 AIC =  2064.689 BIC =  2107.115 
## p =  8 q =  4 AIC =  2065.696 BIC =  2111.152 
## p =  8 q =  5 AIC =  2066.742 BIC =  2115.229 
## p =  9 q =  1 AIC =  2051.967 BIC =  2091.278 
## p =  9 q =  2 AIC =  2053.962 BIC =  2096.296 
## p =  9 q =  3 AIC =  2053.946 BIC =  2099.304 
## p =  9 q =  4 AIC =  2054.923 BIC =  2103.305 
## p =  9 q =  5 AIC =  2056.042 BIC =  2107.448 
## p =  10 q =  1 AIC =  2039.219 BIC =  2081.461 
## p =  10 q =  2 AIC =  2041.207 BIC =  2086.466 
## p =  10 q =  3 AIC =  2041.624 BIC =  2089.9 
## p =  10 q =  4 AIC =  2042.556 BIC =  2093.85 
## p =  10 q =  5 AIC =  2043.428 BIC =  2097.739

## 
##  Breusch-Godfrey test for serial correlation of order up to 10
## 
## data:  Residuals
## LM test = 6.0252, df = 10, p-value = 0.8131
DistLagMod(Copperprice, ASXprice) #ASXprice vs Copper price
## q =  1 AIC =  2574.488 BIC =  2586.789 
## q =  2 AIC =  2559.356 BIC =  2574.7 
## q =  3 AIC =  2544.155 BIC =  2562.531 
## q =  4 AIC =  2528.895 BIC =  2550.289 
## q =  5 AIC =  2513.265 BIC =  2537.664 
## q =  6 AIC =  2497.775 BIC =  2525.166 
## q =  7 AIC =  2481.988 BIC =  2512.357 
## q =  8 AIC =  2466.511 BIC =  2499.846 
## q =  9 AIC =  2451.016 BIC =  2487.302 
## q =  10 AIC =  2436.164 BIC =  2475.389 
## 
## Finite lag length based on AIC-BIC
## 
## Call:
## lm(formula = model.formula, data = design)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1163.95  -653.62    -5.48   601.46  1422.56 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  3.921e+03  2.114e+02  18.546   <2e-16 ***
## x.t          1.576e-01  1.351e-01   1.166    0.245    
## x.1          1.829e-02  2.177e-01   0.084    0.933    
## x.2          4.688e-02  2.177e-01   0.215    0.830    
## x.3          2.755e-02  2.164e-01   0.127    0.899    
## x.4          2.061e-02  2.157e-01   0.096    0.924    
## x.5         -5.263e-02  2.157e-01  -0.244    0.808    
## x.6          3.688e-02  2.165e-01   0.170    0.865    
## x.7         -5.357e-03  2.186e-01  -0.025    0.980    
## x.8         -2.372e-04  2.195e-01  -0.001    0.999    
## x.9         -9.203e-02  1.337e-01  -0.688    0.493    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 736.7 on 141 degrees of freedom
## Multiple R-squared:  0.2059, Adjusted R-squared:  0.1496 
## F-statistic: 3.656 on 10 and 141 DF,  p-value: 0.000233
## 
## AIC and BIC values for the model:
##        AIC      BIC
## 1 2451.016 2487.302
## 
## Ploynomial DLM
## Estimates and t-tests for beta coefficients:
##        Estimate Std. Error t value P(>|t|)
## beta.0  0.17800      0.131  1.3600   0.176
## beta.1  0.05290      0.207  0.2550   0.799
## beta.2 -0.00654      0.129 -0.0507   0.960
## 
## Call:
## "Y ~ (Intercept) + X.t"
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1302.7  -694.4  -135.3   635.5  1512.0 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 3484.26812  181.89988  19.155   <2e-16 ***
## z.t0           0.17781    0.13067   1.361    0.176    
## z.t1          -0.15771    0.62898  -0.251    0.802    
## z.t2           0.03277    0.31191   0.105    0.916    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 743 on 155 degrees of freedom
## Multiple R-squared:  0.2877, Adjusted R-squared:  0.274 
## F-statistic: 20.87 on 3 and 155 DF,  p-value: 2.065e-11
## 
## 
## Koyk model
## 
## Call:
## "Y ~ (Intercept) + Y.1 + X.t"
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -689.64 -108.62   12.78  140.20  771.79 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 189.368812  87.644648   2.161   0.0322 *  
## Y.1           0.971621   0.021895  44.376   <2e-16 ***
## X.t          -0.005864   0.009517  -0.616   0.5387    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 201.9 on 157 degrees of freedom
## Multiple R-Squared: 0.9485,  Adjusted R-squared: 0.9479 
## Wald test:  1448 on 2 and 157 DF,  p-value: < 2.2e-16 
## 
## Diagnostic tests:
## NULL
## 
##                             alpha         beta       phi
## Geometric coefficients:  6672.885 -0.005863623 0.9716211
## 
## ARDLM model
## 
## Time series regression with "ts" data:
## Start = 2, End = 161
## 
## Call:
## dynlm(formula = as.formula(model.text), data = data, start = 1)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -734.34 -101.82   16.56  123.05  774.55 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 173.61066   84.94572   2.044  0.04266 *  
## X.t           0.10629    0.03258   3.263  0.00136 ** 
## X.1          -0.10695    0.03228  -3.313  0.00115 ** 
## Y.1           0.96784    0.02103  46.027  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 195.2 on 156 degrees of freedom
## Multiple R-squared:  0.9522, Adjusted R-squared:  0.9513 
## F-statistic:  1035 on 3 and 156 DF,  p-value: < 2.2e-16
## 
## p =  1 q =  1 AIC =  2147.741 BIC =  2163.116 
## p =  1 q =  2 AIC =  2135.4 BIC =  2153.813 
## p =  1 q =  3 AIC =  2121.12 BIC =  2142.558 
## p =  1 q =  4 AIC =  2109.759 BIC =  2134.209 
## p =  1 q =  5 AIC =  2099.056 BIC =  2126.505 
## p =  2 q =  1 AIC =  2130.043 BIC =  2148.456 
## p =  2 q =  2 AIC =  2132.038 BIC =  2153.52 
## p =  2 q =  3 AIC =  2119.241 BIC =  2143.741 
## p =  2 q =  4 AIC =  2107.649 BIC =  2135.155 
## p =  2 q =  5 AIC =  2097.021 BIC =  2127.52 
## p =  3 q =  1 AIC =  2117.307 BIC =  2138.745 
## p =  3 q =  2 AIC =  2119.247 BIC =  2143.748 
## p =  3 q =  3 AIC =  2119.696 BIC =  2147.259 
## p =  3 q =  4 AIC =  2108.537 BIC =  2139.1 
## p =  3 q =  5 AIC =  2097.832 BIC =  2131.38 
## p =  4 q =  1 AIC =  2105.916 BIC =  2130.366 
## p =  4 q =  2 AIC =  2107.774 BIC =  2135.28 
## p =  4 q =  3 AIC =  2108.608 BIC =  2139.17 
## p =  4 q =  4 AIC =  2110.085 BIC =  2143.704 
## p =  4 q =  5 AIC =  2099.454 BIC =  2136.052 
## p =  5 q =  1 AIC =  2095.118 BIC =  2122.566 
## p =  5 q =  2 AIC =  2096.96 BIC =  2127.459 
## p =  5 q =  3 AIC =  2097.887 BIC =  2131.436 
## p =  5 q =  4 AIC =  2099.497 BIC =  2136.095 
## p =  5 q =  5 AIC =  2101.419 BIC =  2141.067 
## p =  6 q =  1 AIC =  2084.49 BIC =  2114.924 
## p =  6 q =  2 AIC =  2086.331 BIC =  2119.809 
## p =  6 q =  3 AIC =  2087.163 BIC =  2123.684 
## p =  6 q =  4 AIC =  2088.704 BIC =  2128.268 
## p =  6 q =  5 AIC =  2090.603 BIC =  2133.211 
## p =  7 q =  1 AIC =  2072.833 BIC =  2106.239 
## p =  7 q =  2 AIC =  2074.698 BIC =  2111.141 
## p =  7 q =  3 AIC =  2075.535 BIC =  2115.016 
## p =  7 q =  4 AIC =  2077.211 BIC =  2119.729 
## p =  7 q =  5 AIC =  2079.174 BIC =  2124.729 
## p =  8 q =  1 AIC =  2062.338 BIC =  2098.703 
## p =  8 q =  2 AIC =  2064.181 BIC =  2103.577 
## p =  8 q =  3 AIC =  2065.007 BIC =  2107.433 
## p =  8 q =  4 AIC =  2066.679 BIC =  2112.135 
## p =  8 q =  5 AIC =  2068.654 BIC =  2117.141 
## p =  9 q =  1 AIC =  2049.983 BIC =  2089.293 
## p =  9 q =  2 AIC =  2051.863 BIC =  2094.197 
## p =  9 q =  3 AIC =  2052.445 BIC =  2097.803 
## p =  9 q =  4 AIC =  2054.13 BIC =  2102.512 
## p =  9 q =  5 AIC =  2056.102 BIC =  2107.508 
## p =  10 q =  1 AIC =  2034.551 BIC =  2076.793 
## p =  10 q =  2 AIC =  2036.144 BIC =  2081.403 
## p =  10 q =  3 AIC =  2036.502 BIC =  2084.779 
## p =  10 q =  4 AIC =  2037.935 BIC =  2089.229 
## p =  10 q =  5 AIC =  2039.913 BIC =  2094.224

## 
##  Breusch-Godfrey test for serial correlation of order up to 10
## 
## data:  Residuals
## LM test = 3.6178, df = 10, p-value = 0.9629

Discussion

In the tasks performed, we could infer how stationarity of series have faired because of the components of series. Different modelling techniques were applied and lots of results are obtained. The report doesnt deal with the Random walk and White noise to check with Stationarity. The forecasting techniques can be discussed further and generate better results for the dataset.

Conclusion