Effects of both climate and pollution on disease specific mortality between the years 2010-2020 is given on averaged weekly basis. The task is to give best 4 weeks ahead forecasts in terms of R squared, AIC, BIC, MASE.
Models used for identifying the problem are DLM, ARDL, polyck, koyck, dynamic, exponential smoothing and state-space model. Forecasting of each best model is to done.
mort <- read_csv("/Users/shubhamchougule/Downloads/mort .csv")
## Warning: Missing column names filled in: 'X1' [1]
## Parsed with column specification:
## cols(
## X1 = col_double(),
## mortality = col_double(),
## temp = col_double(),
## chem1 = col_double(),
## chem2 = col_double(),
## `particle size` = col_double()
## )
names(mort)[6] <- "Size"
#Checking the dataset
head(mort)
## # A tibble: 6 x 6
## X1 mortality temp chem1 chem2 Size
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 1 11.9 72.4 3.37 45.8 72.7
## 2 2 10.8 67.2 2.59 43.9 49.6
## 3 3 9.33 62.9 3.29 32.2 55.7
## 4 4 9.54 72.5 3.04 40.4 55.2
## 5 5 8.27 74.2 3.39 48.5 66.0
## 6 6 7.55 67.9 2.57 48.6 44.0
#Checking the class of dataset
class(mort)
## [1] "spec_tbl_df" "tbl_df" "tbl" "data.frame"
#Converting dataset to time series weekly from 2010
Mort<-ts(mort$mortality,start = 2010,frequency = 52)
Temp<-ts(mort$temp,start = 2010,frequency = 52)
Chem1<-ts(mort$chem1,start = 2010,frequency = 52)
Chem2<-ts(mort$chem2,start = 2010,frequency = 52)
Size<-ts(mort$Size,start = 2010,frequency = 52)
#Plotting Mortality series and check
plot(Mort,type='o',ylab="Weekely Mortality",xlab="YEAR",main="Mortality")
#Plotting Temprature series and check
plot(Temp,type='o',ylab="Weekely Temprature",xlab="YEAR",main="Temprature")
#Plotting Chemical 1 series and check
plot(Chem1,type='o',ylab="Weekely Chemical 1",xlab="YEAR",main="Chemical 1")
#Plotting Chemical 2 series and check
plot(Chem2,type='o',ylab="Weekely Chemical 2",xlab="YEAR",main="Chemical 2")
#Plotting Particle Size series and check
plot(Size,type='o',ylab="Weekely Particle Size",xlab="YEAR",main="Particle Size")
#ACF plots
par(mfrow=c(3,2))
acf(Mort,main="ACF for Mortality")
acf(Temp,main="ACF for Temprature")
acf(Chem1,main="ACF for Chemical 1")
acf(Chem2,main="ACF for Chemical 2")
acf(Size,main="ACF for Particle Size")
#PACF plots
par(mfrow=c(3,2))
pacf(Mort,main="PACF for Mortality")
pacf(Temp,main="PACF for Temprature")
pacf(Chem1,main="PACF for Chemical 1")
pacf(Chem2,main="PACF for Chemical 2")
pacf(Size,main="PACF for Particle Size")
Non-stationary can be check by adf test.
Assumptions are as follows
NULL hypothesis:
H0:Non-stationary
Alternative hypothesis:
HA:stationary
#ADF test for MORTALITY Series
adf.test(Mort)
## Warning in adf.test(Mort): p-value smaller than printed p-value
##
## Augmented Dickey-Fuller Test
##
## data: Mort
## Dickey-Fuller = -5.8365, Lag order = 7, p-value = 0.01
## alternative hypothesis: stationary
#ADF test for Temprature series
adf.test(Temp)
## Warning in adf.test(Temp): p-value smaller than printed p-value
##
## Augmented Dickey-Fuller Test
##
## data: Temp
## Dickey-Fuller = -4.4572, Lag order = 7, p-value = 0.01
## alternative hypothesis: stationary
#ADF test for Chem1 series
adf.test(Chem1)
## Warning in adf.test(Chem1): p-value smaller than printed p-value
##
## Augmented Dickey-Fuller Test
##
## data: Chem1
## Dickey-Fuller = -5.2791, Lag order = 7, p-value = 0.01
## alternative hypothesis: stationary
#ADF test for Chem2 series
adf.test(Chem2)
##
## Augmented Dickey-Fuller Test
##
## data: Chem2
## Dickey-Fuller = -3.9606, Lag order = 7, p-value = 0.01097
## alternative hypothesis: stationary
#ADF test for Size series
adf.test(Size)
## Warning in adf.test(Size): p-value smaller than printed p-value
##
## Augmented Dickey-Fuller Test
##
## data: Size
## Dickey-Fuller = -4.493, Lag order = 7, p-value = 0.01
## alternative hypothesis: stationary
Augmented Dickey-Fuller Test states tha t all the series is stationary as we get p-value less than 5% hence rejecting null hypothesis.
The individual effect of the existing components and past effects can be analyzed by using the decomposition technique. For decomposition, we will use the STL decomposition.
#Decomposition function giving output STL plot.
decompose <- function(x){
stldec=mstl(x, t.window=15, s.window="periodic", robust=TRUE)
plot(stldec)
}
#decomposition of Mortality
decompose(Mort)
#Decomposition of Temprature
decompose(Temp)
#Decomposition of Chemical 1
decompose(Chem1)
#Decomposition of chemical 2
decompose(Chem2)
#Decomposition of Particle Size
decompose(Size)
#Checking the correlation between variable
cor(mort[,2:6])
## mortality temp chem1 chem2 Size
## mortality 1.00000000 -0.33055755 0.00409079 0.2157476 0.26498535
## temp -0.33055755 1.00000000 0.40437401 0.1141372 -0.01723095
## chem1 0.00409079 0.40437401 1.00000000 0.6128658 0.46793404
## chem2 0.21574756 0.11413717 0.61286575 1.0000000 0.80750391
## Size 0.26498535 -0.01723095 0.46793404 0.8075039 1.00000000
From the correlation matrix we see that Size is has good correlation than other predictors.
To check amoung the Distributed Lag Model which best fits the data based on the AIC,BIC, ADJ RSQUAD and MASE scores. The model we are going to fit are ;
#Checking the q value on basis of AIC and BIC
for(i in 1:20){
model1 = dlm(formula = mortality~temp+chem1+chem2+Size,
data = data.frame(mort), q = i )
cat("q = ", i, "AIC = ", AIC(model1$model), "BIC = ", BIC(model1$model),"\n")
}
## q = 1 AIC = 2394.704 BIC = 2436.989
## q = 2 AIC = 2376.709 BIC = 2435.881
## q = 3 AIC = 2373.249 BIC = 2449.291
## q = 4 AIC = 2373.535 BIC = 2466.431
## q = 5 AIC = 2367.83 BIC = 2477.565
## q = 6 AIC = 2365.04 BIC = 2491.598
## q = 7 AIC = 2363.022 BIC = 2506.387
## q = 8 AIC = 2362.767 BIC = 2522.922
## q = 9 AIC = 2359.864 BIC = 2536.793
## q = 10 AIC = 2352.606 BIC = 2546.294
## q = 11 AIC = 2356.245 BIC = 2566.675
## q = 12 AIC = 2357.764 BIC = 2584.919
## q = 13 AIC = 2358.07 BIC = 2601.935
## q = 14 AIC = 2355.084 BIC = 2615.642
## q = 15 AIC = 2349.494 BIC = 2626.728
## q = 16 AIC = 2337.13 BIC = 2631.023
## q = 17 AIC = 2326.384 BIC = 2636.921
## q = 18 AIC = 2321.418 BIC = 2648.582
## q = 19 AIC = 2309.879 BIC = 2653.653
## q = 20 AIC = 2307.529 BIC = 2667.896
Lowest value of BIC is observed when q=2 hence using this vales for DLM model.
model1<-dlm(formula = mortality~temp+chem1
+chem2+Size,data = data.frame(mort) ,q=2)
summary(model1)
##
## Call:
## lm(formula = as.formula(model.formula), data = design)
##
## Residuals:
## Min 1Q Median 3Q Max
## -4.5157 -1.4321 -0.2730 0.9579 19.2294
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 14.505975 1.418392 10.227 < 2e-16 ***
## temp.t 0.030076 0.026134 1.151 0.250359
## temp.1 -0.058422 0.025287 -2.310 0.021280 *
## temp.2 -0.092827 0.024872 -3.732 0.000212 ***
## chem1.t 0.170174 0.202243 0.841 0.400515
## chem1.1 0.030633 0.197302 0.155 0.876680
## chem1.2 -0.333503 0.203332 -1.640 0.101604
## chem2.t -0.008407 0.020035 -0.420 0.674939
## chem2.1 -0.009923 0.019171 -0.518 0.604964
## chem2.2 0.034018 0.019728 1.724 0.085271 .
## Size.t -0.010873 0.017579 -0.619 0.536496
## Size.1 0.026200 0.017325 1.512 0.131110
## Size.2 0.036545 0.017731 2.061 0.039821 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.497 on 493 degrees of freedom
## Multiple R-squared: 0.2591, Adjusted R-squared: 0.2411
## F-statistic: 14.37 on 12 and 493 DF, p-value: < 2.2e-16
##
## AIC and BIC values for the model:
## AIC BIC
## 1 2376.709 2435.881
checkresiduals(model1$model)
##
## Breusch-Godfrey test for serial correlation of order up to 16
##
## data: Residuals
## LM test = 273.84, df = 16, p-value < 2.2e-16
vif(model1$model)
## temp.t temp.1 temp.2 chem1.t chem1.1 chem1.2 chem2.t chem2.1
## 4.507618 4.223892 4.086731 3.670122 3.483386 3.691544 5.976125 5.473079
## chem2.2 Size.t Size.1 Size.2
## 5.796867 5.728138 5.553133 5.843572
model2<-dlm(formula = mortality~temp+chem1
+chem2,data = data.frame(mort) ,q=2)
summary(model2)
##
## Call:
## lm(formula = as.formula(model.formula), data = design)
##
## Residuals:
## Min 1Q Median 3Q Max
## -4.2314 -1.5101 -0.2200 0.9374 20.2973
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 15.512440 1.405541 11.037 < 2e-16 ***
## temp.t 0.013119 0.025988 0.505 0.613913
## temp.1 -0.061376 0.025349 -2.421 0.015825 *
## temp.2 -0.086441 0.024954 -3.464 0.000578 ***
## chem1.t 0.086678 0.197753 0.438 0.661348
## chem1.1 0.044534 0.191274 0.233 0.815992
## chem1.2 -0.280459 0.197643 -1.419 0.156521
## chem2.t -0.003249 0.016770 -0.194 0.846461
## chem2.1 0.013070 0.016644 0.785 0.432676
## chem2.2 0.055409 0.017264 3.209 0.001416 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.523 on 496 degrees of freedom
## Multiple R-squared: 0.2388, Adjusted R-squared: 0.225
## F-statistic: 17.29 on 9 and 496 DF, p-value: < 2.2e-16
##
## AIC and BIC values for the model:
## AIC BIC
## 1 2384.412 2430.903
checkresiduals(model2$model)
##
## Breusch-Godfrey test for serial correlation of order up to 13
##
## data: Residuals
## LM test = 279.87, df = 13, p-value < 2.2e-16
vif(model2$model)
## temp.t temp.1 temp.2 chem1.t chem1.1 chem1.2 chem2.t chem2.1
## 4.364709 4.156352 4.027963 3.435998 3.205732 3.415321 4.099871 4.039932
## chem2.2
## 4.347239
model3<-dlm(formula = mortality~temp+chem1
+Size,data = data.frame(mort) ,q=2)
summary(model3)
##
## Call:
## lm(formula = as.formula(model.formula), data = design)
##
## Residuals:
## Min 1Q Median 3Q Max
## -4.6307 -1.4442 -0.3282 0.9719 18.9966
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 14.951540 1.352890 11.052 < 2e-16 ***
## temp.t 0.022904 0.024370 0.940 0.347748
## temp.1 -0.067062 0.023385 -2.868 0.004311 **
## temp.2 -0.079818 0.023297 -3.426 0.000663 ***
## chem1.t 0.138309 0.188651 0.733 0.463814
## chem1.1 0.003644 0.182598 0.020 0.984085
## chem1.2 -0.208746 0.190238 -1.097 0.273048
## Size.t -0.013668 0.014896 -0.918 0.359272
## Size.1 0.021351 0.015014 1.422 0.155636
## Size.2 0.051913 0.015324 3.388 0.000761 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.497 on 496 degrees of freedom
## Multiple R-squared: 0.2545, Adjusted R-squared: 0.241
## F-statistic: 18.81 on 9 and 496 DF, p-value: < 2.2e-16
##
## AIC and BIC values for the model:
## AIC BIC
## 1 2373.858 2420.35
checkresiduals(model3$model)
##
## Breusch-Godfrey test for serial correlation of order up to 13
##
## data: Residuals
## LM test = 271.13, df = 13, p-value < 2.2e-16
vif(model3$model)
## temp.t temp.1 temp.2 chem1.t chem1.1 chem1.2 Size.t Size.1
## 3.918870 3.611915 3.584805 3.192877 2.983078 3.230896 4.112329 4.169636
## Size.2
## 4.363823
model4<-dlm(formula = mortality~temp+Size
+chem2,data = data.frame(mort) ,q=2)
summary(model4)
##
## Call:
## lm(formula = as.formula(model.formula), data = design)
##
## Residuals:
## Min 1Q Median 3Q Max
## -4.6784 -1.5011 -0.2797 0.9744 19.3002
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 14.836392 1.351190 10.980 < 2e-16 ***
## temp.t 0.033372 0.025478 1.310 0.1909
## temp.1 -0.057842 0.024958 -2.318 0.0209 *
## temp.2 -0.102686 0.024118 -4.258 2.47e-05 ***
## Size.t -0.005059 0.016911 -0.299 0.7649
## Size.1 0.028062 0.016624 1.688 0.0920 .
## Size.2 0.029497 0.017117 1.723 0.0855 .
## chem2.t -0.003956 0.018655 -0.212 0.8321
## chem2.1 -0.008433 0.017731 -0.476 0.6346
## chem2.2 0.022229 0.018440 1.205 0.2286
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.496 on 496 degrees of freedom
## Multiple R-squared: 0.2548, Adjusted R-squared: 0.2413
## F-statistic: 18.85 on 9 and 496 DF, p-value: < 2.2e-16
##
## AIC and BIC values for the model:
## AIC BIC
## 1 2373.641 2420.133
checkresiduals(model4$model)
##
## Breusch-Godfrey test for serial correlation of order up to 13
##
## data: Residuals
## LM test = 273.51, df = 13, p-value < 2.2e-16
vif(model4$model)
## temp.t temp.1 temp.2 Size.t Size.1 Size.2 chem2.t chem2.1
## 4.285311 4.115821 3.843675 5.302566 5.114203 5.447196 5.182239 4.683008
## chem2.2
## 5.066343
model5<-dlm(formula = mortality~Size+chem1
+chem2,data = data.frame(mort) ,q=2)
summary(model5)
##
## Call:
## lm(formula = as.formula(model.formula), data = design)
##
## Residuals:
## Min 1Q Median 3Q Max
## -4.9929 -1.5320 -0.3496 0.9117 20.2764
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 5.472964 0.597508 9.160 < 2e-16 ***
## Size.t -0.019730 0.018599 -1.061 0.28930
## Size.1 0.031895 0.018252 1.748 0.08117 .
## Size.2 0.052757 0.018564 2.842 0.00467 **
## chem1.t 0.230757 0.209111 1.104 0.27034
## chem1.1 -0.238081 0.205771 -1.157 0.24782
## chem1.2 -0.689888 0.208869 -3.303 0.00103 **
## chem2.t 0.015645 0.019958 0.784 0.43348
## chem2.1 -0.005422 0.018972 -0.286 0.77516
## chem2.2 0.025727 0.019734 1.304 0.19294
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.655 on 496 degrees of freedom
## Multiple R-squared: 0.1573, Adjusted R-squared: 0.142
## F-statistic: 10.29 on 9 and 496 DF, p-value: 1.309e-14
##
## AIC and BIC values for the model:
## AIC BIC
## 1 2435.867 2482.359
checkresiduals(model5$model)
##
## Breusch-Godfrey test for serial correlation of order up to 13
##
## data: Residuals
## LM test = 284.78, df = 13, p-value < 2.2e-16
vif(model5$model)
## Size.t Size.1 Size.2 chem1.t chem1.1 chem1.2 chem2.t chem2.1
## 5.672128 5.451229 5.665487 3.470541 3.351339 3.445507 5.245539 4.741348
## chem2.2
## 5.130592
model6<-dlm(formula = mortality~temp+chem1
,data = data.frame(mort) ,q=2)
summary(model6)
##
## Call:
## lm(formula = as.formula(model.formula), data = design)
##
## Residuals:
## Min 1Q Median 3Q Max
## -4.3487 -1.6429 -0.3251 1.0210 20.2691
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 19.91093 1.11167 17.911 < 2e-16 ***
## temp.t -0.02561 0.02319 -1.104 0.269987
## temp.1 -0.08058 0.02249 -3.584 0.000372 ***
## temp.2 -0.06279 0.02308 -2.721 0.006740 **
## chem1.t 0.15149 0.16264 0.931 0.352050
## chem1.1 0.16111 0.15760 1.022 0.307146
## chem1.2 0.04404 0.16585 0.266 0.790701
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.581 on 499 degrees of freedom
## Multiple R-squared: 0.1987, Adjusted R-squared: 0.1891
## F-statistic: 20.62 on 6 and 499 DF, p-value: < 2.2e-16
##
## AIC and BIC values for the model:
## AIC BIC
## 1 2404.377 2438.19
checkresiduals(model6$model)
##
## Breusch-Godfrey test for serial correlation of order up to 10
##
## data: Residuals
## LM test = 283.3, df = 10, p-value < 2.2e-16
vif(model6$model)
## temp.t temp.1 temp.2 chem1.t chem1.1 chem1.2
## 3.322592 3.125705 3.292563 2.221128 2.079857 2.298481
model7<-dlm(formula = mortality~chem1
+chem2,data = data.frame(mort) ,q=2)
summary(model7)
##
## Call:
## lm(formula = as.formula(model.formula), data = design)
##
## Residuals:
## Min 1Q Median 3Q Max
## -4.7114 -1.4820 -0.4589 0.9419 21.8601
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 5.37076 0.60818 8.831 < 2e-16 ***
## chem1.t 0.05854 0.20449 0.286 0.774798
## chem1.1 -0.25129 0.19964 -1.259 0.208734
## chem1.2 -0.60503 0.20434 -2.961 0.003214 **
## chem2.t 0.01466 0.01634 0.897 0.370153
## chem2.1 0.02634 0.01542 1.708 0.088281 .
## chem2.2 0.06353 0.01625 3.908 0.000106 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.704 on 499 degrees of freedom
## Multiple R-squared: 0.1204, Adjusted R-squared: 0.1099
## F-statistic: 11.39 on 6 and 499 DF, p-value: 6.005e-12
##
## AIC and BIC values for the model:
## AIC BIC
## 1 2451.527 2485.339
checkresiduals(model7$model)
##
## Breusch-Godfrey test for serial correlation of order up to 10
##
## data: Residuals
## LM test = 295.59, df = 10, p-value < 2.2e-16
vif(model7$model)
## chem1.t chem1.1 chem1.2 chem2.t chem2.1 chem2.2
## 3.198939 3.040836 3.178795 3.390656 3.020739 3.355281
model8<-dlm(formula = mortality~chem2
+Size,data = data.frame(mort) ,q=2)
summary(model8)
##
## Call:
## lm(formula = as.formula(model.formula), data = design)
##
## Residuals:
## Min 1Q Median 3Q Max
## -4.4632 -1.5786 -0.4494 0.9479 20.5668
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.846512 0.590519 8.207 1.94e-15 ***
## chem2.t 0.022822 0.017972 1.270 0.2047
## chem2.1 -0.015153 0.017281 -0.877 0.3810
## chem2.2 -0.007032 0.017928 -0.392 0.6951
## Size.t -0.005318 0.018268 -0.291 0.7711
## Size.1 0.035100 0.017755 1.977 0.0486 *
## Size.2 0.044046 0.018160 2.425 0.0156 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.709 on 499 degrees of freedom
## Multiple R-squared: 0.1174, Adjusted R-squared: 0.1068
## F-statistic: 11.06 on 6 and 499 DF, p-value: 1.359e-11
##
## AIC and BIC values for the model:
## AIC BIC
## 1 2453.283 2487.096
checkresiduals(model8$model)
##
## Breusch-Godfrey test for serial correlation of order up to 10
##
## data: Residuals
## LM test = 291.21, df = 10, p-value < 2.2e-16
vif(model8$model)
## chem2.t chem2.1 chem2.2 Size.t Size.1 Size.2
## 4.085645 3.778780 4.067298 5.255701 4.955060 5.207794
model9<-dlm(formula = mortality~temp
+chem2,data = data.frame(mort) ,q=2)
summary(model9)
##
## Call:
## lm(formula = as.formula(model.formula), data = design)
##
## Residuals:
## Min 1Q Median 3Q Max
## -4.1650 -1.5321 -0.2366 0.9261 20.2709
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 15.842548 1.333592 11.880 < 2e-16 ***
## temp.t 0.014599 0.025127 0.581 0.56150
## temp.1 -0.060441 0.024842 -2.433 0.01532 *
## temp.2 -0.094901 0.024108 -3.936 9.44e-05 ***
## chem2.t 0.001594 0.013509 0.118 0.90613
## chem2.1 0.016317 0.013391 1.219 0.22361
## chem2.2 0.041231 0.014170 2.910 0.00378 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.521 on 499 degrees of freedom
## Multiple R-squared: 0.2354, Adjusted R-squared: 0.2262
## F-statistic: 25.61 on 6 and 499 DF, p-value: < 2.2e-16
##
## AIC and BIC values for the model:
## AIC BIC
## 1 2380.65 2414.463
checkresiduals(model9$model)
##
## Breusch-Godfrey test for serial correlation of order up to 10
##
## data: Residuals
## LM test = 279.54, df = 10, p-value < 2.2e-16
vif(model9$model)
## temp.t temp.1 temp.2 chem2.t chem2.1 chem2.2
## 4.086756 3.998172 3.765663 2.664692 2.619212 2.933393
model10<-dlm(formula = mortality~temp
+Size,data = data.frame(mort) ,q=2)
summary(model10)
##
## Call:
## lm(formula = as.formula(model.formula), data = design)
##
## Residuals:
## Min 1Q Median 3Q Max
## -4.7074 -1.4713 -0.3382 0.9513 19.1035
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 15.047803 1.321726 11.385 < 2e-16 ***
## temp.t 0.029065 0.022507 1.291 0.197176
## temp.1 -0.065774 0.022117 -2.974 0.003082 **
## temp.2 -0.090352 0.021303 -4.241 2.65e-05 ***
## Size.t -0.007118 0.012362 -0.576 0.565015
## Size.1 0.022468 0.012472 1.801 0.072237 .
## Size.2 0.043016 0.012977 3.315 0.000984 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.493 on 499 degrees of freedom
## Multiple R-squared: 0.2525, Adjusted R-squared: 0.2435
## F-statistic: 28.09 on 6 and 499 DF, p-value: < 2.2e-16
##
## AIC and BIC values for the model:
## AIC BIC
## 1 2369.232 2403.044
checkresiduals(model10$model)
##
## Breusch-Godfrey test for serial correlation of order up to 10
##
## data: Residuals
## LM test = 271.41, df = 10, p-value < 2.2e-16
vif(model10$model)
## temp.t temp.1 temp.2 Size.t Size.1 Size.2
## 3.353981 3.241355 3.007363 2.841613 2.886838 3.139802
model11<-dlm(formula = mortality~chem1
+Size,data = data.frame(mort) ,q=2)
summary(model11)
##
## Call:
## lm(formula = as.formula(model.formula), data = design)
##
## Residuals:
## Min 1Q Median 3Q Max
## -4.6941 -1.6333 -0.3852 0.9379 19.8749
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 5.913609 0.536400 11.025 < 2e-16 ***
## chem1.t 0.284537 0.184550 1.542 0.1238
## chem1.1 -0.286206 0.183573 -1.559 0.1196
## chem1.2 -0.572678 0.186034 -3.078 0.0022 **
## Size.t -0.009971 0.015192 -0.656 0.5119
## Size.1 0.029210 0.014833 1.969 0.0495 *
## Size.2 0.067309 0.015102 4.457 1.03e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.658 on 499 degrees of freedom
## Multiple R-squared: 0.1503, Adjusted R-squared: 0.1401
## F-statistic: 14.71 on 6 and 499 DF, p-value: 1.687e-15
##
## AIC and BIC values for the model:
## AIC BIC
## 1 2434.072 2467.884
checkresiduals(model11$model)
##
## Breusch-Godfrey test for serial correlation of order up to 10
##
## data: Residuals
## LM test = 282.73, df = 10, p-value < 2.2e-16
vif(model11$model)
## chem1.t chem1.1 chem1.2 Size.t Size.1 Size.2
## 2.696995 2.661208 2.727101 3.775366 3.592060 3.741038
pmodel1 = polyDlm(x = as.vector(Temp) , y = as.vector(Mort),q=2,k = 2 , show.beta = TRUE)
## Estimates and t-tests for beta coefficients:
## Estimate Std. Error t value P(>|t|)
## beta.0 -0.0210 0.0175 -1.20 0.229000
## beta.1 -0.0729 0.0172 -4.25 0.000026
## beta.2 -0.0642 0.0174 -3.68 0.000257
summary(pmodel1,diagnostics=TRUE)
##
## Call:
## "Y ~ (Intercept) + X.t"
##
## Residuals:
## Min 1Q Median 3Q Max
## -4.5618 -1.5319 -0.2664 0.9448 20.2897
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 20.12082 1.10886 18.145 <2e-16 ***
## z.t0 -0.02103 0.01746 -1.205 0.229
## z.t1 -0.08212 0.05133 -1.600 0.110
## z.t2 0.03026 0.02460 1.230 0.219
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.589 on 502 degrees of freedom
## Multiple R-squared: 0.1889, Adjusted R-squared: 0.1841
## F-statistic: 38.98 on 3 and 502 DF, p-value: < 2.2e-16
checkresiduals(pmodel1$model)
##
## Breusch-Godfrey test for serial correlation of order up to 10
##
## data: Residuals
## LM test = 282.83, df = 10, p-value < 2.2e-16
vif(pmodel1$model)
## z.t0 z.t1 z.t2
## 12.43870 119.94564 81.13779
pmodel2 = polyDlm(x = as.vector(Chem1) , y = as.vector(Mort),q=2,k = 2 , show.beta = TRUE)
## Estimates and t-tests for beta coefficients:
## Estimate Std. Error t value P(>|t|)
## beta.0 0.0888 0.139 0.639 0.523
## beta.1 -0.1100 0.135 -0.809 0.419
## beta.2 -0.0909 0.139 -0.653 0.514
summary(pmodel2,diagnostics=TRUE)
##
## Call:
## "Y ~ (Intercept) + X.t"
##
## Residuals:
## Min 1Q Median 3Q Max
## -4.1373 -1.7315 -0.6187 0.8281 22.1536
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 8.69310 0.46651 18.635 <2e-16 ***
## z.t0 0.08882 0.13902 0.639 0.523
## z.t1 -0.30689 0.38772 -0.792 0.429
## z.t2 0.10851 0.18529 0.586 0.558
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.87 on 502 degrees of freedom
## Multiple R-squared: 0.002869, Adjusted R-squared: -0.00309
## F-statistic: 0.4814 on 3 and 502 DF, p-value: 0.6954
checkresiduals(pmodel2$model)
##
## Breusch-Godfrey test for serial correlation of order up to 10
##
## data: Residuals
## LM test = 320.57, df = 10, p-value < 2.2e-16
vif(pmodel2$model)
## z.t0 z.t1 z.t2
## 7.003503 65.928697 46.345787
pmodel3 = polyDlm(x = as.vector(Chem2) , y = as.vector(Mort),q=2,k = 2 , show.beta = TRUE)
## Estimates and t-tests for beta coefficients:
## Estimate Std. Error t value P(>|t|)
## beta.0 0.0241 0.0107 2.26 0.02410
## beta.1 0.0188 0.0101 1.87 0.06250
## beta.2 0.0310 0.0106 2.91 0.00375
summary(pmodel3,diagnostics=TRUE)
##
## Call:
## "Y ~ (Intercept) + X.t"
##
## Residuals:
## Min 1Q Median 3Q Max
## -4.7736 -1.6750 -0.5331 0.8263 22.1107
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.641671 0.600839 7.725 6.11e-14 ***
## z.t0 0.024100 0.010652 2.263 0.0241 *
## z.t1 -0.013997 0.028819 -0.486 0.6274
## z.t2 0.008727 0.013706 0.637 0.5246
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.763 on 502 degrees of freedom
## Multiple R-squared: 0.076, Adjusted R-squared: 0.07048
## F-statistic: 13.76 on 3 and 502 DF, p-value: 1.222e-08
checkresiduals(pmodel3$model)
##
## Breusch-Godfrey test for serial correlation of order up to 10
##
## data: Residuals
## LM test = 303.67, df = 10, p-value < 2.2e-16
vif(pmodel3$model)
## z.t0 z.t1 z.t2
## 7.539326 65.706664 45.718196
pmodel4 = polyDlm(x = as.vector(Size) , y = as.vector(Mort),q=2,k = 2 , show.beta = TRUE)
## Estimates and t-tests for beta coefficients:
## Estimate Std. Error t value P(>|t|)
## beta.0 0.0143 0.0106 1.35 0.177000
## beta.1 0.0223 0.0101 2.20 0.028100
## beta.2 0.0379 0.0106 3.58 0.000372
summary(pmodel4,diagnostics=TRUE)
##
## Call:
## "Y ~ (Intercept) + X.t"
##
## Residuals:
## Min 1Q Median 3Q Max
## -4.5974 -1.6083 -0.4388 0.9131 20.6279
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.845598 0.462100 10.486 <2e-16 ***
## z.t0 0.014333 0.010595 1.353 0.177
## z.t1 0.004223 0.030073 0.140 0.888
## z.t2 0.003772 0.014343 0.263 0.793
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.706 on 502 degrees of freedom
## Multiple R-squared: 0.1139, Adjusted R-squared: 0.1086
## F-statistic: 21.51 on 3 and 502 DF, p-value: 4.023e-13
checkresiduals(pmodel4$model)
##
## Breusch-Godfrey test for serial correlation of order up to 10
##
## data: Residuals
## LM test = 290.65, df = 10, p-value < 2.2e-16
vif(pmodel4$model)
## z.t0 z.t1 z.t2
## 11.38679 103.09399 69.70257
kmodel1 = koyckDlm(x = as.vector(Temp) , y = as.vector(Mort))
summary(kmodel1,diagnostics=TRUE)
##
## Call:
## "Y ~ (Intercept) + Y.1 + X.t"
##
## Residuals:
## Min 1Q Median 3Q Max
## -6.4283 -1.2117 -0.1941 1.1714 11.1820
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 9.40056 1.58049 5.948 5.08e-09 ***
## Y.1 0.67086 0.03671 18.276 < 2e-16 ***
## X.t -0.08948 0.01853 -4.828 1.83e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.909 on 504 degrees of freedom
## Multiple R-Squared: 0.558, Adjusted R-squared: 0.5562
## Wald test: 355.5 on 2 and 504 DF, p-value: < 2.2e-16
##
## Diagnostic tests:
## df1 df2 statistic p-value
## Weak instruments 1 504 214.97822 8.527293e-41
## Wu-Hausman 1 503 27.01526 2.939989e-07
##
## alpha beta phi
## Geometric coefficients: 28.56104 -0.08947627 0.6708608
checkresiduals(kmodel1$model)
vif(kmodel1$model)
## Y.1 X.t
## 1.539691 1.539691
kmodel2 = koyckDlm(x = as.vector(Chem1) , y = as.vector(Mort))
summary(kmodel2,diagnostics=TRUE)
##
## Call:
## "Y ~ (Intercept) + Y.1 + X.t"
##
## Residuals:
## Min 1Q Median 3Q Max
## -6.7649 -1.1887 -0.2573 1.0264 10.8101
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.80765 0.66143 4.245 2.6e-05 ***
## Y.1 0.77292 0.02875 26.888 < 2e-16 ***
## X.t -0.31918 0.20925 -1.525 0.128
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.851 on 504 degrees of freedom
## Multiple R-Squared: 0.5844, Adjusted R-squared: 0.5827
## Wald test: 366.9 on 2 and 504 DF, p-value: < 2.2e-16
##
## Diagnostic tests:
## df1 df2 statistic p-value
## Weak instruments 1 504 81.999720 2.983840e-18
## Wu-Hausman 1 503 4.016999 4.557941e-02
##
## alpha beta phi
## Geometric coefficients: 12.36421 -0.3191788 0.7729215
checkresiduals(kmodel2$model)
vif(kmodel2$model)
## Y.1 X.t
## 1.004251 1.004251
kmodel3 = koyckDlm(x = as.vector(Chem2) , y = as.vector(Mort))
summary(kmodel3,diagnostics=TRUE)
##
## Call:
## "Y ~ (Intercept) + Y.1 + X.t"
##
## Residuals:
## Min 1Q Median 3Q Max
## -6.3503 -1.1438 -0.1824 1.0069 10.5000
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.34912 0.78405 1.721 0.0859 .
## Y.1 0.76870 0.02943 26.124 <2e-16 ***
## X.t 0.01161 0.01641 0.708 0.4794
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.786 on 504 degrees of freedom
## Multiple R-Squared: 0.613, Adjusted R-squared: 0.6115
## Wald test: 393.1 on 2 and 504 DF, p-value: < 2.2e-16
##
## Diagnostic tests:
## df1 df2 statistic p-value
## Weak instruments 1 504 75.1380380 6.022827e-17
## Wu-Hausman 1 503 0.7867766 3.755005e-01
##
## alpha beta phi
## Geometric coefficients: 5.832834 0.01161223 0.7687033
checkresiduals(kmodel3$model)
vif(kmodel3$model)
## Y.1 X.t
## 1.130304 1.130304
kmodel4 = koyckDlm(x = as.vector(Size) , y = as.vector(Mort))
summary(kmodel4,diagnostics=TRUE)
##
## Call:
## "Y ~ (Intercept) + Y.1 + X.t"
##
## Residuals:
## Min 1Q Median 3Q Max
## -6.0563 -1.1224 -0.1658 1.0735 10.2368
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.88911 0.46062 1.930 0.0541 .
## Y.1 0.75111 0.02920 25.721 <2e-16 ***
## X.t 0.02521 0.00998 2.526 0.0119 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.776 on 504 degrees of freedom
## Multiple R-Squared: 0.6174, Adjusted R-squared: 0.6159
## Wald test: 400.5 on 2 and 504 DF, p-value: < 2.2e-16
##
## Diagnostic tests:
## df1 df2 statistic p-value
## Weak instruments 1 504 199.64011000 2.004783e-38
## Wu-Hausman 1 503 0.06046356 8.058651e-01
##
## alpha beta phi
## Geometric coefficients: 3.572223 0.02520678 0.7511051
checkresiduals(kmodel4$model)
vif(kmodel4$model)
## Y.1 X.t
## 1.125962 1.125962
#Checking p and q vales on basis fo AIC and BIC
for (i in 1:10){
for(j in 1:10){
model4 = ardlDlm(formula = mortality~temp+chem1
+chem2+Size,data = data.frame(mort), p = i , q = j )
cat("p = ", i, "q = ", j, "AIC = ", AIC(model4$model), "BIC = ", BIC(model4$model),"\n")
}
}
## p = 1 q = 1 AIC = 2012.083 BIC = 2058.596
## p = 1 q = 2 AIC = 1996.118 BIC = 2046.837
## p = 1 q = 3 AIC = 1989.844 BIC = 2044.763
## p = 1 q = 4 AIC = 1983.625 BIC = 2042.741
## p = 1 q = 5 AIC = 1979.376 BIC = 2042.685
## p = 1 q = 6 AIC = 1976.376 BIC = 2043.873
## p = 1 q = 7 AIC = 1972.626 BIC = 2044.308
## p = 1 q = 8 AIC = 1971.408 BIC = 2047.271
## p = 1 q = 9 AIC = 1969.749 BIC = 2049.789
## p = 1 q = 10 AIC = 1968.839 BIC = 2053.051
## p = 2 q = 1 AIC = 2012.736 BIC = 2076.135
## p = 2 q = 2 AIC = 2000.277 BIC = 2067.901
## p = 2 q = 3 AIC = 1993.853 BIC = 2065.671
## p = 2 q = 4 AIC = 1986.892 BIC = 2062.899
## p = 2 q = 5 AIC = 1982.199 BIC = 2062.391
## p = 2 q = 6 AIC = 1978.804 BIC = 2063.176
## p = 2 q = 7 AIC = 1975.282 BIC = 2063.83
## p = 2 q = 8 AIC = 1973.978 BIC = 2066.699
## p = 2 q = 9 AIC = 1971.769 BIC = 2068.659
## p = 2 q = 10 AIC = 1970.9 BIC = 2071.954
## p = 3 q = 1 AIC = 2015.771 BIC = 2096.037
## p = 3 q = 2 AIC = 2002.505 BIC = 2086.997
## p = 3 q = 3 AIC = 1999.049 BIC = 2087.765
## p = 3 q = 4 AIC = 1992.295 BIC = 2085.192
## p = 3 q = 5 AIC = 1988.003 BIC = 2085.077
## p = 3 q = 6 AIC = 1984.71 BIC = 2085.957
## p = 3 q = 7 AIC = 1980.783 BIC = 2086.198
## p = 3 q = 8 AIC = 1979.262 BIC = 2088.842
## p = 3 q = 9 AIC = 1977.206 BIC = 2090.946
## p = 3 q = 10 AIC = 1976.297 BIC = 2094.194
## p = 4 q = 1 AIC = 2020.495 BIC = 2117.614
## p = 4 q = 2 AIC = 2006.361 BIC = 2107.703
## p = 4 q = 3 AIC = 2003.273 BIC = 2108.838
## p = 4 q = 4 AIC = 1999.217 BIC = 2109.004
## p = 4 q = 5 AIC = 1994.789 BIC = 2108.745
## p = 4 q = 6 AIC = 1991.713 BIC = 2109.834
## p = 4 q = 7 AIC = 1987.737 BIC = 2110.018
## p = 4 q = 8 AIC = 1986.041 BIC = 2112.479
## p = 4 q = 9 AIC = 1984.045 BIC = 2114.636
## p = 4 q = 10 AIC = 1983.1 BIC = 2117.839
## p = 5 q = 1 AIC = 2017.848 BIC = 2131.804
## p = 5 q = 2 AIC = 2004.835 BIC = 2123.012
## p = 5 q = 3 AIC = 1999.997 BIC = 2122.394
## p = 5 q = 4 AIC = 1995.162 BIC = 2121.78
## p = 5 q = 5 AIC = 1993.387 BIC = 2124.225
## p = 5 q = 6 AIC = 1989.598 BIC = 2124.593
## p = 5 q = 7 AIC = 1985.628 BIC = 2124.776
## p = 5 q = 8 AIC = 1983.601 BIC = 2126.898
## p = 5 q = 9 AIC = 1981.337 BIC = 2128.778
## p = 5 q = 10 AIC = 1980.331 BIC = 2131.913
## p = 6 q = 1 AIC = 2019.31 BIC = 2150.087
## p = 6 q = 2 AIC = 2005.457 BIC = 2140.452
## p = 6 q = 3 AIC = 2000.59 BIC = 2139.804
## p = 6 q = 4 AIC = 1994.587 BIC = 2138.02
## p = 6 q = 5 AIC = 1992.217 BIC = 2139.868
## p = 6 q = 6 AIC = 1991.785 BIC = 2143.655
## p = 6 q = 7 AIC = 1988.428 BIC = 2144.443
## p = 6 q = 8 AIC = 1986.389 BIC = 2146.545
## p = 6 q = 9 AIC = 1984.185 BIC = 2148.476
## p = 6 q = 10 AIC = 1983.335 BIC = 2151.759
## p = 7 q = 1 AIC = 2017.312 BIC = 2164.893
## p = 7 q = 2 AIC = 2004.901 BIC = 2156.698
## p = 7 q = 3 AIC = 1999.362 BIC = 2155.377
## p = 7 q = 4 AIC = 1993.007 BIC = 2153.238
## p = 7 q = 5 AIC = 1990.73 BIC = 2155.178
## p = 7 q = 6 AIC = 1990.208 BIC = 2158.872
## p = 7 q = 7 AIC = 1990.943 BIC = 2163.824
## p = 7 q = 8 AIC = 1988.413 BIC = 2165.426
## p = 7 q = 9 AIC = 1986.075 BIC = 2167.217
## p = 7 q = 10 AIC = 1985.262 BIC = 2170.529
## p = 8 q = 1 AIC = 2015.388 BIC = 2179.757
## p = 8 q = 2 AIC = 2002.328 BIC = 2170.912
## p = 8 q = 3 AIC = 1996.78 BIC = 2169.579
## p = 8 q = 4 AIC = 1989.376 BIC = 2166.389
## p = 8 q = 5 AIC = 1987.271 BIC = 2168.499
## p = 8 q = 6 AIC = 1987.734 BIC = 2173.177
## p = 8 q = 7 AIC = 1988.077 BIC = 2177.735
## p = 8 q = 8 AIC = 1989.874 BIC = 2183.746
## p = 8 q = 9 AIC = 1987.227 BIC = 2185.219
## p = 8 q = 10 AIC = 1986.432 BIC = 2188.54
## p = 9 q = 1 AIC = 2011.495 BIC = 2192.637
## p = 9 q = 2 AIC = 2000.428 BIC = 2185.783
## p = 9 q = 3 AIC = 1993.916 BIC = 2183.483
## p = 9 q = 4 AIC = 1985.931 BIC = 2179.71
## p = 9 q = 5 AIC = 1984.398 BIC = 2182.391
## p = 9 q = 6 AIC = 1984.654 BIC = 2186.859
## p = 9 q = 7 AIC = 1985.912 BIC = 2192.33
## p = 9 q = 8 AIC = 1987.857 BIC = 2198.487
## p = 9 q = 9 AIC = 1988.036 BIC = 2202.879
## p = 9 q = 10 AIC = 1987.238 BIC = 2206.189
## p = 10 q = 1 AIC = 2011.201 BIC = 2209.099
## p = 10 q = 2 AIC = 1999.353 BIC = 2201.461
## p = 10 q = 3 AIC = 1991.854 BIC = 2198.174
## p = 10 q = 4 AIC = 1982.626 BIC = 2193.156
## p = 10 q = 5 AIC = 1980.582 BIC = 2195.322
## p = 10 q = 6 AIC = 1981.092 BIC = 2200.043
## p = 10 q = 7 AIC = 1982.473 BIC = 2205.635
## p = 10 q = 8 AIC = 1984.466 BIC = 2211.838
## p = 10 q = 9 AIC = 1983.749 BIC = 2215.332
## p = 10 q = 10 AIC = 1985.65 BIC = 2221.444
We choose p=1 and q=5 because for this p and q values AIC and BIC are the least using same in the model.
armodel1<-ardlDlm(formula = mortality~temp+chem1
+chem2+Size,data = data.frame(mort) ,p=1,q=5)
summary(armodel1)
##
## Time series regression with "ts" data:
## Start = 6, End = 508
##
## Call:
## dynlm(formula = as.formula(model.text), data = data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -6.0216 -1.1190 -0.1695 1.0276 9.5246
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.062360 1.093079 3.716 0.000225 ***
## temp.t 0.019808 0.016009 1.237 0.216573
## temp.1 -0.053263 0.015683 -3.396 0.000739 ***
## chem1.t -0.062602 0.126214 -0.496 0.620116
## chem1.1 -0.047009 0.127521 -0.369 0.712559
## chem2.t 0.013854 0.012735 1.088 0.277182
## chem2.1 -0.003936 0.012578 -0.313 0.754453
## Size.t -0.002911 0.011095 -0.262 0.793139
## Size.1 0.019108 0.011234 1.701 0.089590 .
## mortality.1 0.594031 0.044789 13.263 < 2e-16 ***
## mortality.2 0.248031 0.051634 4.804 2.08e-06 ***
## mortality.3 -0.014240 0.052490 -0.271 0.786284
## mortality.4 -0.052457 0.051539 -1.018 0.309274
## mortality.5 -0.077428 0.044229 -1.751 0.080642 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.704 on 489 degrees of freedom
## Multiple R-squared: 0.6575, Adjusted R-squared: 0.6484
## F-statistic: 72.22 on 13 and 489 DF, p-value: < 2.2e-16
checkresiduals(armodel1$model)
##
## Breusch-Godfrey test for serial correlation of order up to 17
##
## data: Residuals
## LM test = 16.634, df = 17, p-value = 0.4794
armodel2<-ardlDlm(formula = mortality~temp+chem1
+chem2,data = data.frame(mort) ,p=1,q=5)
summary(armodel2)
##
## Time series regression with "ts" data:
## Start = 6, End = 508
##
## Call:
## dynlm(formula = as.formula(model.text), data = data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -5.7636 -1.1191 -0.1652 1.0607 9.8812
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.286752 1.082326 3.961 8.58e-05 ***
## temp.t 0.015148 0.015843 0.956 0.33949
## temp.1 -0.051708 0.015652 -3.304 0.00102 **
## chem1.t -0.102359 0.122850 -0.833 0.40513
## chem1.1 -0.015419 0.123489 -0.125 0.90068
## chem2.t 0.016892 0.010235 1.650 0.09948 .
## chem2.1 0.008767 0.010530 0.833 0.40551
## mortality.1 0.597963 0.044746 13.363 < 2e-16 ***
## mortality.2 0.252563 0.051661 4.889 1.38e-06 ***
## mortality.3 -0.014593 0.052545 -0.278 0.78134
## mortality.4 -0.050412 0.051399 -0.981 0.32718
## mortality.5 -0.087608 0.043895 -1.996 0.04650 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.707 on 491 degrees of freedom
## Multiple R-squared: 0.655, Adjusted R-squared: 0.6473
## F-statistic: 84.75 on 11 and 491 DF, p-value: < 2.2e-16
checkresiduals(armodel2$model)
##
## Breusch-Godfrey test for serial correlation of order up to 15
##
## data: Residuals
## LM test = 11.427, df = 15, p-value = 0.7218
armodel3<-ardlDlm(formula = mortality~temp+chem1
+Size,data = data.frame(mort) ,p=1,q=5)
summary(armodel3)
##
## Time series regression with "ts" data:
## Start = 6, End = 508
##
## Call:
## dynlm(formula = as.formula(model.text), data = data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -6.0890 -1.1348 -0.1512 1.0097 9.4598
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.192171 1.076229 3.895 0.000112 ***
## temp.t 0.024209 0.015036 1.610 0.108018
## temp.1 -0.058132 0.014707 -3.953 8.86e-05 ***
## chem1.t -0.008827 0.116172 -0.076 0.939467
## chem1.1 -0.064921 0.118008 -0.550 0.582470
## Size.t 0.003959 0.009165 0.432 0.665986
## Size.1 0.018484 0.009404 1.966 0.049909 *
## mortality.1 0.591261 0.044532 13.277 < 2e-16 ***
## mortality.2 0.250108 0.051387 4.867 1.53e-06 ***
## mortality.3 -0.015780 0.052415 -0.301 0.763498
## mortality.4 -0.050278 0.051453 -0.977 0.328963
## mortality.5 -0.076252 0.044080 -1.730 0.084285 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.703 on 491 degrees of freedom
## Multiple R-squared: 0.6567, Adjusted R-squared: 0.649
## F-statistic: 85.37 on 11 and 491 DF, p-value: < 2.2e-16
checkresiduals(armodel3$model)
##
## Breusch-Godfrey test for serial correlation of order up to 15
##
## data: Residuals
## LM test = 16.582, df = 15, p-value = 0.3444
armodel4<-ardlDlm(formula = mortality~temp+Size
+chem2,data = data.frame(mort) ,p=1,q=5)
summary(armodel4)
##
## Time series regression with "ts" data:
## Start = 6, End = 508
##
## Call:
## dynlm(formula = as.formula(model.text), data = data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -6.057 -1.133 -0.178 1.032 9.485
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.348350 1.048938 4.145 3.99e-05 ***
## temp.t 0.017220 0.015581 1.105 0.269612
## temp.1 -0.055248 0.015329 -3.604 0.000345 ***
## Size.t -0.002566 0.010748 -0.239 0.811419
## Size.1 0.019412 0.010877 1.785 0.074937 .
## chem2.t 0.010890 0.011703 0.931 0.352555
## chem2.1 -0.006518 0.011599 -0.562 0.574408
## mortality.1 0.593376 0.044481 13.340 < 2e-16 ***
## mortality.2 0.246956 0.051252 4.818 1.93e-06 ***
## mortality.3 -0.012651 0.052401 -0.241 0.809321
## mortality.4 -0.052621 0.051258 -1.027 0.305116
## mortality.5 -0.078092 0.044141 -1.769 0.077493 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.702 on 491 degrees of freedom
## Multiple R-squared: 0.6569, Adjusted R-squared: 0.6492
## F-statistic: 85.46 on 11 and 491 DF, p-value: < 2.2e-16
checkresiduals(armodel4$model)
##
## Breusch-Godfrey test for serial correlation of order up to 15
##
## data: Residuals
## LM test = 14.375, df = 15, p-value = 0.4973
armodel5<-ardlDlm(formula = mortality~Size+chem1
+chem2,data = data.frame(mort) ,p=1,q=5)
summary(armodel5)
##
## Time series regression with "ts" data:
## Start = 6, End = 508
##
## Call:
## dynlm(formula = as.formula(model.text), data = data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -6.3196 -1.1077 -0.1607 0.9820 10.0094
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.2545888 0.4431439 2.831 0.00483 **
## Size.t 0.0006906 0.0111941 0.062 0.95083
## Size.1 0.0185435 0.0112597 1.647 0.10022
## chem1.t -0.0883980 0.1237279 -0.714 0.47529
## chem1.1 -0.1550906 0.1258986 -1.232 0.21859
## chem2.t 0.0253594 0.0122037 2.078 0.03823 *
## chem2.1 -0.0124388 0.0121225 -1.026 0.30535
## mortality.1 0.6013339 0.0450767 13.340 < 2e-16 ***
## mortality.2 0.2653381 0.0520849 5.094 5e-07 ***
## mortality.3 -0.0114821 0.0530925 -0.216 0.82887
## mortality.4 -0.0572385 0.0519783 -1.101 0.27135
## mortality.5 -0.0514329 0.0441861 -1.164 0.24499
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.725 on 491 degrees of freedom
## Multiple R-squared: 0.6474, Adjusted R-squared: 0.6394
## F-statistic: 81.94 on 11 and 491 DF, p-value: < 2.2e-16
checkresiduals(armodel5$model)
##
## Breusch-Godfrey test for serial correlation of order up to 15
##
## data: Residuals
## LM test = 17.478, df = 15, p-value = 0.2911
armodel6<-ardlDlm(formula = mortality~temp+chem1
,data = data.frame(mort) ,p=1,q=5)
summary(armodel6)
##
## Time series regression with "ts" data:
## Start = 6, End = 508
##
## Call:
## dynlm(formula = as.formula(model.text), data = data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -6.1264 -1.1379 -0.2072 1.0732 9.7274
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 5.70795 0.97780 5.838 9.62e-09 ***
## temp.t 0.01149 0.01417 0.811 0.4178
## temp.1 -0.05808 0.01411 -4.117 4.51e-05 ***
## chem1.t 0.04213 0.09884 0.426 0.6701
## chem1.1 0.04399 0.10070 0.437 0.6624
## mortality.1 0.61109 0.04456 13.715 < 2e-16 ***
## mortality.2 0.25330 0.05185 4.885 1.40e-06 ***
## mortality.3 -0.01254 0.05289 -0.237 0.8127
## mortality.4 -0.05370 0.05175 -1.038 0.2999
## mortality.5 -0.09523 0.04412 -2.158 0.0314 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.719 on 493 degrees of freedom
## Multiple R-squared: 0.6487, Adjusted R-squared: 0.6423
## F-statistic: 101.2 on 9 and 493 DF, p-value: < 2.2e-16
checkresiduals(armodel6$model)
##
## Breusch-Godfrey test for serial correlation of order up to 13
##
## data: Residuals
## LM test = 9.2569, df = 13, p-value = 0.7533
armodel7<-ardlDlm(formula = mortality~chem1
+chem2,data = data.frame(mort) ,p=1,q=5)
summary(armodel7)
##
## Time series regression with "ts" data:
## Start = 6, End = 508
##
## Call:
## dynlm(formula = as.formula(model.text), data = data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -6.0654 -1.1076 -0.1560 0.9959 10.3685
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.223313 0.442784 2.763 0.00595 **
## chem1.t -0.136244 0.119324 -1.142 0.25409
## chem1.1 -0.133516 0.121220 -1.101 0.27124
## chem2.t 0.030628 0.009359 3.272 0.00114 **
## chem2.1 0.001830 0.009474 0.193 0.84691
## mortality.1 0.608377 0.044986 13.524 < 2e-16 ***
## mortality.2 0.270681 0.052132 5.192 3.05e-07 ***
## mortality.3 -0.012073 0.053177 -0.227 0.82049
## mortality.4 -0.055155 0.051845 -1.064 0.28792
## mortality.5 -0.061977 0.043965 -1.410 0.15926
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.729 on 493 degrees of freedom
## Multiple R-squared: 0.6444, Adjusted R-squared: 0.6379
## F-statistic: 99.25 on 9 and 493 DF, p-value: < 2.2e-16
checkresiduals(armodel7$model)
##
## Breusch-Godfrey test for serial correlation of order up to 13
##
## data: Residuals
## LM test = 11.012, df = 13, p-value = 0.6098
armodel8<-ardlDlm(formula = mortality~chem2
+Size,data = data.frame(mort) ,p=1,q=5)
summary(armodel8)
##
## Time series regression with "ts" data:
## Start = 6, End = 508
##
## Call:
## dynlm(formula = as.formula(model.text), data = data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -6.4478 -1.1145 -0.1605 1.0192 9.9682
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.979974 0.427586 2.292 0.0223 *
## chem2.t 0.019980 0.010795 1.851 0.0648 .
## chem2.1 -0.020761 0.010843 -1.915 0.0561 .
## Size.t 0.003622 0.010833 0.334 0.7383
## Size.1 0.018971 0.010853 1.748 0.0811 .
## mortality.1 0.606267 0.044970 13.481 < 2e-16 ***
## mortality.2 0.263325 0.051986 5.065 5.77e-07 ***
## mortality.3 -0.008591 0.053246 -0.161 0.8719
## mortality.4 -0.053528 0.051965 -1.030 0.3035
## mortality.5 -0.047096 0.044257 -1.064 0.2878
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.731 on 493 degrees of freedom
## Multiple R-squared: 0.6436, Adjusted R-squared: 0.6371
## F-statistic: 98.93 on 9 and 493 DF, p-value: < 2.2e-16
checkresiduals(armodel8$model)
##
## Breusch-Godfrey test for serial correlation of order up to 13
##
## data: Residuals
## LM test = 22.395, df = 13, p-value = 0.04954
armodel9<-ardlDlm(formula = mortality~temp
+chem2,data = data.frame(mort) ,p=1,q=5)
summary(armodel9)
##
## Time series regression with "ts" data:
## Start = 6, End = 508
##
## Call:
## dynlm(formula = as.formula(model.text), data = data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -5.8117 -1.1417 -0.1533 1.0531 9.8471
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.621347 1.034654 4.467 9.87e-06 ***
## temp.t 0.011229 0.015303 0.734 0.463426
## temp.1 -0.052961 0.015215 -3.481 0.000544 ***
## chem2.t 0.012249 0.008184 1.497 0.135126
## chem2.1 0.008025 0.008520 0.942 0.346692
## mortality.1 0.595798 0.044410 13.416 < 2e-16 ***
## mortality.2 0.253528 0.051224 4.949 1.02e-06 ***
## mortality.3 -0.012717 0.052473 -0.242 0.808614
## mortality.4 -0.051935 0.051220 -1.014 0.311103
## mortality.5 -0.088278 0.043822 -2.014 0.044504 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.705 on 493 degrees of freedom
## Multiple R-squared: 0.6542, Adjusted R-squared: 0.6479
## F-statistic: 103.6 on 9 and 493 DF, p-value: < 2.2e-16
checkresiduals(armodel9$model)
##
## Breusch-Godfrey test for serial correlation of order up to 13
##
## data: Residuals
## LM test = 9.4271, df = 13, p-value = 0.74
armodel10<-ardlDlm(formula = mortality~temp
+Size,data = data.frame(mort) ,p=1,q=5)
summary(armodel10)
##
## Time series regression with "ts" data:
## Start = 6, End = 508
##
## Call:
## dynlm(formula = as.formula(model.text), data = data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -6.038 -1.130 -0.167 1.040 9.488
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.348756 1.045759 4.158 3.78e-05 ***
## temp.t 0.023592 0.013936 1.693 0.0911 .
## temp.1 -0.060954 0.013763 -4.429 1.17e-05 ***
## Size.t 0.004426 0.007652 0.578 0.5632
## Size.1 0.015897 0.007942 2.002 0.0459 *
## mortality.1 0.591504 0.044321 13.346 < 2e-16 ***
## mortality.2 0.248433 0.051121 4.860 1.58e-06 ***
## mortality.3 -0.014906 0.052287 -0.285 0.7757
## mortality.4 -0.048766 0.051029 -0.956 0.3397
## mortality.5 -0.078475 0.043900 -1.788 0.0745 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.7 on 493 degrees of freedom
## Multiple R-squared: 0.6563, Adjusted R-squared: 0.65
## F-statistic: 104.6 on 9 and 493 DF, p-value: < 2.2e-16
checkresiduals(armodel10$model)
##
## Breusch-Godfrey test for serial correlation of order up to 13
##
## data: Residuals
## LM test = 14.431, df = 13, p-value = 0.3442
armodel11<-ardlDlm(formula = mortality~chem1
+Size,data = data.frame(mort) ,p=1,q=5)
summary(armodel11)
##
## Time series regression with "ts" data:
## Start = 6, End = 508
##
## Call:
## dynlm(formula = as.formula(model.text), data = data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -6.3973 -1.0879 -0.1576 1.0165 10.0757
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.374671 0.425675 3.229 0.00132 **
## chem1.t 0.033838 0.109342 0.309 0.75710
## chem1.1 -0.234295 0.112262 -2.087 0.03740 *
## Size.t 0.014943 0.008856 1.687 0.09216 .
## Size.1 0.012509 0.008936 1.400 0.16218
## mortality.1 0.592175 0.044820 13.212 < 2e-16 ***
## mortality.2 0.274676 0.051856 5.297 1.78e-07 ***
## mortality.3 -0.013574 0.053209 -0.255 0.79875
## mortality.4 -0.055495 0.052096 -1.065 0.28728
## mortality.5 -0.048544 0.044157 -1.099 0.27216
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.73 on 493 degrees of freedom
## Multiple R-squared: 0.6442, Adjusted R-squared: 0.6377
## F-statistic: 99.18 on 9 and 493 DF, p-value: < 2.2e-16
checkresiduals(armodel11$model)
##
## Breusch-Godfrey test for serial correlation of order up to 13
##
## data: Residuals
## LM test = 18.202, df = 13, p-value = 0.15
Dynamic Lag models are created using Y lag, step function,Intevention point, trend and seasonality. Best model is selected by adding and removing different points. Dynlm function allows us to use multiple predictors at the same time hence finding the best model to predict mortality.
From the observations we can see that
dynlmodel1=dynlm(Mort~(Temp+Chem1+Chem2+Size)+L(Mort , k = 1 ))
summary(dynlmodel1)
##
## Time series regression with "ts" data:
## Start = 2010(2), End = 2019(40)
##
## Call:
## dynlm(formula = Mort ~ (Temp + Chem1 + Chem2 + Size) + L(Mort,
## k = 1))
##
## Residuals:
## Min 1Q Median 3Q Max
## -5.8822 -1.1127 -0.1326 1.0354 10.4958
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.01746 0.88158 2.288 0.0225 *
## Temp -0.01455 0.01055 -1.379 0.1684
## Chem1 -0.16324 0.10458 -1.561 0.1192
## Chem2 0.02483 0.01111 2.235 0.0259 *
## Size 0.01102 0.00906 1.216 0.2245
## L(Mort, k = 1) 0.73136 0.03011 24.291 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.765 on 501 degrees of freedom
## Multiple R-squared: 0.6243, Adjusted R-squared: 0.6206
## F-statistic: 166.5 on 5 and 501 DF, p-value: < 2.2e-16
checkresiduals(dynlmodel1)
##
## Breusch-Godfrey test for serial correlation of order up to 101
##
## data: Residuals
## LM test = 106.76, df = 101, p-value = 0.3284
dynlmodel2=dynlm(Mort~(Temp+Chem1+Chem2+Size)+L(Mort , k = 1 )+season(Mort))
summary(dynlmodel2)
##
## Time series regression with "ts" data:
## Start = 2010(2), End = 2019(40)
##
## Call:
## dynlm(formula = Mort ~ (Temp + Chem1 + Chem2 + Size) + L(Mort,
## k = 1) + season(Mort))
##
## Residuals:
## Min 1Q Median 3Q Max
## -5.4734 -1.0237 -0.0681 0.9680 9.0449
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.045720 1.219846 0.857 0.3918
## Temp 0.032367 0.019313 1.676 0.0944 .
## Chem1 -0.104684 0.110829 -0.945 0.3454
## Chem2 0.013761 0.012271 1.121 0.2627
## Size -0.005003 0.011760 -0.425 0.6708
## L(Mort, k = 1) 0.683291 0.034671 19.708 <2e-16 ***
## season(Mort)2 -0.885068 0.795920 -1.112 0.2667
## season(Mort)3 -1.119209 0.797724 -1.403 0.1613
## season(Mort)4 -0.002287 0.804468 -0.003 0.9977
## season(Mort)5 0.725347 0.800375 0.906 0.3653
## season(Mort)6 -1.273788 0.809789 -1.573 0.1164
## season(Mort)7 -1.453315 0.826883 -1.758 0.0795 .
## season(Mort)8 -1.345844 0.826288 -1.629 0.1041
## season(Mort)9 -0.594067 0.829420 -0.716 0.4742
## season(Mort)10 -1.105684 0.837721 -1.320 0.1875
## season(Mort)11 -1.633435 0.846718 -1.929 0.0543 .
## season(Mort)12 -0.361124 0.857905 -0.421 0.6740
## season(Mort)13 -1.088927 0.850936 -1.280 0.2013
## season(Mort)14 -1.459009 0.872717 -1.672 0.0953 .
## season(Mort)15 -0.798299 0.883574 -0.903 0.3668
## season(Mort)16 -2.062829 0.891975 -2.313 0.0212 *
## season(Mort)17 -1.535285 0.895821 -1.714 0.0872 .
## season(Mort)18 -1.647601 0.908367 -1.814 0.0704 .
## season(Mort)19 -1.153750 0.929048 -1.242 0.2149
## season(Mort)20 -1.570183 0.931522 -1.686 0.0926 .
## season(Mort)21 -2.066937 0.929788 -2.223 0.0267 *
## season(Mort)22 -0.943522 0.939971 -1.004 0.3160
## season(Mort)23 -1.519198 0.947446 -1.603 0.1095
## season(Mort)24 -1.607843 0.945005 -1.701 0.0896 .
## season(Mort)25 -1.618182 0.956606 -1.692 0.0914 .
## season(Mort)26 -1.894144 0.946140 -2.002 0.0459 *
## season(Mort)27 -1.856066 0.932415 -1.991 0.0471 *
## season(Mort)28 -1.849089 0.924779 -1.999 0.0462 *
## season(Mort)29 -1.326310 0.914034 -1.451 0.1475
## season(Mort)30 -1.675274 0.925881 -1.809 0.0711 .
## season(Mort)31 -1.722876 0.884136 -1.949 0.0520 .
## season(Mort)32 -2.191138 0.885649 -2.474 0.0137 *
## season(Mort)33 -0.538146 0.894666 -0.602 0.5478
## season(Mort)34 -1.070088 0.866676 -1.235 0.2176
## season(Mort)35 -2.135282 0.843020 -2.533 0.0117 *
## season(Mort)36 -0.991696 0.833933 -1.189 0.2350
## season(Mort)37 -1.315493 0.822842 -1.599 0.1106
## season(Mort)38 -1.060887 0.813380 -1.304 0.1928
## season(Mort)39 -1.856942 0.816446 -2.274 0.0234 *
## season(Mort)40 -0.657955 0.812306 -0.810 0.4184
## season(Mort)41 -1.403180 0.828880 -1.693 0.0912 .
## season(Mort)42 -0.500213 0.828837 -0.604 0.5465
## season(Mort)43 -0.931873 0.834699 -1.116 0.2648
## season(Mort)44 -0.446714 0.831054 -0.538 0.5912
## season(Mort)45 0.602992 0.829718 0.727 0.4678
## season(Mort)46 -0.092958 0.824966 -0.113 0.9103
## season(Mort)47 1.449624 0.839947 1.726 0.0851 .
## season(Mort)48 1.591674 0.816623 1.949 0.0519 .
## season(Mort)49 1.649313 0.818426 2.015 0.0445 *
## season(Mort)50 0.002377 0.817859 0.003 0.9977
## season(Mort)51 0.118645 0.818265 0.145 0.8848
## season(Mort)52 -0.172411 0.813718 -0.212 0.8323
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.723 on 450 degrees of freedom
## Multiple R-squared: 0.6785, Adjusted R-squared: 0.6384
## F-statistic: 16.96 on 56 and 450 DF, p-value: < 2.2e-16
checkresiduals(dynlmodel2)
##
## Breusch-Godfrey test for serial correlation of order up to 101
##
## data: Residuals
## LM test = 113.9, df = 101, p-value = 0.1792
dynlmodel3=dynlm(Mort~(Temp+Chem1+Chem2+Size)+L(Mort , k = 1 )+season(Mort)+trend(Mort))
summary(dynlmodel3)
##
## Time series regression with "ts" data:
## Start = 2010(2), End = 2019(40)
##
## Call:
## dynlm(formula = Mort ~ (Temp + Chem1 + Chem2 + Size) + L(Mort,
## k = 1) + season(Mort) + trend(Mort))
##
## Residuals:
## Min 1Q Median 3Q Max
## -5.5012 -1.0346 -0.0693 0.9552 9.0128
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.990484 1.225933 0.808 0.4196
## Temp 0.035978 0.020654 1.742 0.0822 .
## Chem1 -0.143569 0.135810 -1.057 0.2910
## Chem2 0.013519 0.012291 1.100 0.2720
## Size -0.004433 0.011826 -0.375 0.7079
## L(Mort, k = 1) 0.683662 0.034708 19.697 <2e-16 ***
## season(Mort)2 -0.910442 0.798227 -1.141 0.2547
## season(Mort)3 -1.125382 0.798490 -1.409 0.1594
## season(Mort)4 -0.027241 0.806711 -0.034 0.9731
## season(Mort)5 0.707146 0.801886 0.882 0.3783
## season(Mort)6 -1.294444 0.811536 -1.595 0.1114
## season(Mort)7 -1.484744 0.829996 -1.789 0.0743 .
## season(Mort)8 -1.381662 0.830125 -1.664 0.0967 .
## season(Mort)9 -0.627841 0.832901 -0.754 0.4514
## season(Mort)10 -1.138641 0.841050 -1.354 0.1765
## season(Mort)11 -1.660769 0.849216 -1.956 0.0511 .
## season(Mort)12 -0.395767 0.861458 -0.459 0.6462
## season(Mort)13 -1.119044 0.853809 -1.311 0.1906
## season(Mort)14 -1.501709 0.877677 -1.711 0.0878 .
## season(Mort)15 -0.843641 0.889023 -0.949 0.3432
## season(Mort)16 -2.113696 0.898589 -2.352 0.0191 *
## season(Mort)17 -1.584233 0.901982 -1.756 0.0797 .
## season(Mort)18 -1.706590 0.916868 -1.861 0.0634 .
## season(Mort)19 -1.207122 0.936027 -1.290 0.1978
## season(Mort)20 -1.604010 0.934792 -1.716 0.0869 .
## season(Mort)21 -2.111005 0.934796 -2.258 0.0244 *
## season(Mort)22 -0.997386 0.947000 -1.053 0.2928
## season(Mort)23 -1.573477 0.954529 -1.648 0.1000 .
## season(Mort)24 -1.654664 0.950492 -1.741 0.0824 .
## season(Mort)25 -1.662045 0.961480 -1.729 0.0846 .
## season(Mort)26 -1.950245 0.953658 -2.045 0.0414 *
## season(Mort)27 -1.907901 0.939025 -2.032 0.0428 *
## season(Mort)28 -1.897715 0.930727 -2.039 0.0420 *
## season(Mort)29 -1.378486 0.920823 -1.497 0.1351
## season(Mort)30 -1.720579 0.931144 -1.848 0.0653 .
## season(Mort)31 -1.768110 0.889560 -1.988 0.0475 *
## season(Mort)32 -2.240157 0.891879 -2.512 0.0124 *
## season(Mort)33 -0.601371 0.904436 -0.665 0.5064
## season(Mort)34 -1.113884 0.871881 -1.278 0.2021
## season(Mort)35 -2.182746 0.849132 -2.571 0.0105 *
## season(Mort)36 -1.025890 0.837472 -1.225 0.2212
## season(Mort)37 -1.357604 0.827893 -1.640 0.1017
## season(Mort)38 -1.077544 0.814753 -1.323 0.1867
## season(Mort)39 -1.882339 0.818732 -2.299 0.0220 *
## season(Mort)40 -0.676704 0.813864 -0.831 0.4062
## season(Mort)41 -1.418385 0.830141 -1.709 0.0882 .
## season(Mort)42 -0.517018 0.830223 -0.623 0.5338
## season(Mort)43 -0.943789 0.835744 -1.129 0.2594
## season(Mort)44 -0.444551 0.831762 -0.534 0.5933
## season(Mort)45 0.596163 0.830528 0.718 0.4732
## season(Mort)46 -0.105205 0.826026 -0.127 0.8987
## season(Mort)47 1.457227 0.840791 1.733 0.0838 .
## season(Mort)48 1.583696 0.817466 1.937 0.0533 .
## season(Mort)49 1.638340 0.819410 1.999 0.0462 *
## season(Mort)50 -0.006666 0.818748 -0.008 0.9935
## season(Mort)51 0.118176 0.818952 0.144 0.8853
## season(Mort)52 -0.185337 0.814817 -0.227 0.8202
## trend(Mort) -0.017979 0.036231 -0.496 0.6200
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.724 on 449 degrees of freedom
## Multiple R-squared: 0.6786, Adjusted R-squared: 0.6378
## F-statistic: 16.63 on 57 and 449 DF, p-value: < 2.2e-16
checkresiduals(dynlmodel3)
##
## Breusch-Godfrey test for serial correlation of order up to 101
##
## data: Residuals
## LM test = 113.43, df = 101, p-value = 0.1874
dynlmodel4=dynlm(Mort~(Temp+Chem1+Chem2)+L(Mort , k = 1 )+season(Mort))
summary(dynlmodel4)
##
## Time series regression with "ts" data:
## Start = 2010(2), End = 2019(40)
##
## Call:
## dynlm(formula = Mort ~ (Temp + Chem1 + Chem2) + L(Mort, k = 1) +
## season(Mort))
##
## Residuals:
## Min 1Q Median 3Q Max
## -5.4562 -1.0505 -0.0828 0.9776 9.0294
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.08115 1.21589 0.889 0.3744
## Temp 0.02990 0.01840 1.625 0.1049
## Chem1 -0.11312 0.10894 -1.038 0.2997
## Chem2 0.01183 0.01139 1.039 0.2996
## L(Mort, k = 1) 0.68253 0.03459 19.730 <2e-16 ***
## season(Mort)2 -0.86259 0.79344 -1.087 0.2776
## season(Mort)3 -1.09334 0.79468 -1.376 0.1696
## season(Mort)4 0.02307 0.80153 0.029 0.9771
## season(Mort)5 0.74732 0.79798 0.937 0.3495
## season(Mort)6 -1.21869 0.79864 -1.526 0.1277
## season(Mort)7 -1.38400 0.80993 -1.709 0.0882 .
## season(Mort)8 -1.28614 0.81354 -1.581 0.1146
## season(Mort)9 -0.52612 0.81316 -0.647 0.5180
## season(Mort)10 -1.03755 0.82152 -1.263 0.2073
## season(Mort)11 -1.56937 0.83246 -1.885 0.0600 .
## season(Mort)12 -0.28802 0.83975 -0.343 0.7318
## season(Mort)13 -1.02172 0.83538 -1.223 0.2219
## season(Mort)14 -1.37616 0.84994 -1.619 0.1061
## season(Mort)15 -0.71311 0.85980 -0.829 0.4073
## season(Mort)16 -1.97482 0.86686 -2.278 0.0232 *
## season(Mort)17 -1.45080 0.87273 -1.662 0.0971 .
## season(Mort)18 -1.56841 0.88828 -1.766 0.0781 .
## season(Mort)19 -1.05410 0.89821 -1.174 0.2412
## season(Mort)20 -1.47800 0.90514 -1.633 0.1032
## season(Mort)21 -1.96411 0.89700 -2.190 0.0291 *
## season(Mort)22 -0.85319 0.91484 -0.933 0.3515
## season(Mort)23 -1.42414 0.91988 -1.548 0.1223
## season(Mort)24 -1.52785 0.92527 -1.651 0.0994 .
## season(Mort)25 -1.52737 0.93163 -1.639 0.1018
## season(Mort)26 -1.80169 0.92000 -1.958 0.0508 .
## season(Mort)27 -1.77237 0.91059 -1.946 0.0522 .
## season(Mort)28 -1.75631 0.89787 -1.956 0.0511 .
## season(Mort)29 -1.23841 0.88956 -1.392 0.1646
## season(Mort)30 -1.58511 0.90047 -1.760 0.0790 .
## season(Mort)31 -1.65003 0.86660 -1.904 0.0575 .
## season(Mort)32 -2.12845 0.87251 -2.439 0.0151 *
## season(Mort)33 -0.47094 0.87981 -0.535 0.5927
## season(Mort)34 -1.01830 0.85730 -1.188 0.2355
## season(Mort)35 -2.11798 0.84127 -2.518 0.0122 *
## season(Mort)36 -0.98575 0.83306 -1.183 0.2373
## season(Mort)37 -1.29313 0.82041 -1.576 0.1157
## season(Mort)38 -1.07489 0.81198 -1.324 0.1862
## season(Mort)39 -1.86810 0.81528 -2.291 0.0224 *
## season(Mort)40 -0.68792 0.80851 -0.851 0.3953
## season(Mort)41 -1.43284 0.82519 -1.736 0.0832 .
## season(Mort)42 -0.52346 0.82628 -0.634 0.5267
## season(Mort)43 -0.98896 0.82309 -1.202 0.2302
## season(Mort)44 -0.49707 0.82183 -0.605 0.5456
## season(Mort)45 0.55758 0.82208 0.678 0.4980
## season(Mort)46 -0.14586 0.81480 -0.179 0.8580
## season(Mort)47 1.37830 0.82229 1.676 0.0944 .
## season(Mort)48 1.55909 0.81228 1.919 0.0556 .
## season(Mort)49 1.61204 0.81298 1.983 0.0480 *
## season(Mort)50 -0.01880 0.81560 -0.023 0.9816
## season(Mort)51 0.08758 0.81426 0.108 0.9144
## season(Mort)52 -0.17040 0.81296 -0.210 0.8341
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.721 on 451 degrees of freedom
## Multiple R-squared: 0.6783, Adjusted R-squared: 0.6391
## F-statistic: 17.29 on 55 and 451 DF, p-value: < 2.2e-16
checkresiduals(dynlmodel4)
##
## Breusch-Godfrey test for serial correlation of order up to 101
##
## data: Residuals
## LM test = 113.72, df = 101, p-value = 0.1823
dynlmodel5=dynlm(Mort~(Temp+Chem2+Size)+L(Mort , k = 1 )+season(Mort))
summary(dynlmodel5)
##
## Time series regression with "ts" data:
## Start = 2010(2), End = 2019(40)
##
## Call:
## dynlm(formula = Mort ~ (Temp + Chem2 + Size) + L(Mort, k = 1) +
## season(Mort))
##
## Residuals:
## Min 1Q Median 3Q Max
## -5.5215 -1.0441 -0.0799 0.9330 9.0091
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.174325 1.212079 0.969 0.3331
## Temp 0.032394 0.019311 1.678 0.0941 .
## Chem2 0.008331 0.010841 0.769 0.4426
## Size -0.006989 0.011569 -0.604 0.5461
## L(Mort, k = 1) 0.681982 0.034639 19.688 <2e-16 ***
## season(Mort)2 -0.885161 0.795825 -1.112 0.2666
## season(Mort)3 -1.164274 0.796201 -1.462 0.1444
## season(Mort)4 -0.023261 0.804065 -0.029 0.9769
## season(Mort)5 0.698576 0.799778 0.873 0.3829
## season(Mort)6 -1.315586 0.808482 -1.627 0.1044
## season(Mort)7 -1.501904 0.825182 -1.820 0.0694 .
## season(Mort)8 -1.381657 0.825319 -1.674 0.0948 .
## season(Mort)9 -0.624790 0.828683 -0.754 0.4513
## season(Mort)10 -1.168570 0.834971 -1.400 0.1623
## season(Mort)11 -1.725676 0.840967 -2.052 0.0407 *
## season(Mort)12 -0.449255 0.852714 -0.527 0.5986
## season(Mort)13 -1.180401 0.845306 -1.396 0.1633
## season(Mort)14 -1.553096 0.866910 -1.792 0.0739 .
## season(Mort)15 -0.895383 0.877471 -1.020 0.3081
## season(Mort)16 -2.163743 0.885448 -2.444 0.0149 *
## season(Mort)17 -1.638186 0.889065 -1.843 0.0660 .
## season(Mort)18 -1.740496 0.902919 -1.928 0.0545 .
## season(Mort)19 -1.267961 0.921036 -1.377 0.1693
## season(Mort)20 -1.728773 0.916156 -1.887 0.0598 .
## season(Mort)21 -2.201089 0.918767 -2.396 0.0170 *
## season(Mort)22 -1.070923 0.930132 -1.151 0.2502
## season(Mort)23 -1.661344 0.935306 -1.776 0.0764 .
## season(Mort)24 -1.753274 0.932266 -1.881 0.0607 .
## season(Mort)25 -1.783373 0.940371 -1.896 0.0585 .
## season(Mort)26 -2.022256 0.936256 -2.160 0.0313 *
## season(Mort)27 -1.983099 0.922554 -2.150 0.0321 *
## season(Mort)28 -1.960337 0.917138 -2.137 0.0331 *
## season(Mort)29 -1.409914 0.909630 -1.550 0.1218
## season(Mort)30 -1.792961 0.917349 -1.955 0.0513 .
## season(Mort)31 -1.794343 0.880787 -2.037 0.0422 *
## season(Mort)32 -2.254393 0.883008 -2.553 0.0110 *
## season(Mort)33 -0.565529 0.894089 -0.633 0.5274
## season(Mort)34 -1.126724 0.864496 -1.303 0.1931
## season(Mort)35 -2.154653 0.842670 -2.557 0.0109 *
## season(Mort)36 -1.006729 0.833681 -1.208 0.2278
## season(Mort)37 -1.297318 0.822519 -1.577 0.1154
## season(Mort)38 -1.060119 0.813282 -1.304 0.1931
## season(Mort)39 -1.845330 0.816256 -2.261 0.0243 *
## season(Mort)40 -0.629407 0.811646 -0.775 0.4385
## season(Mort)41 -1.380966 0.828447 -1.667 0.0962 .
## season(Mort)42 -0.474708 0.828298 -0.573 0.5669
## season(Mort)43 -0.882232 0.832944 -1.059 0.2901
## season(Mort)44 -0.437610 0.830898 -0.527 0.5987
## season(Mort)45 0.654824 0.827803 0.791 0.4293
## season(Mort)46 -0.052909 0.823777 -0.064 0.9488
## season(Mort)47 1.487197 0.838904 1.773 0.0769 .
## season(Mort)48 1.629632 0.815536 1.998 0.0463 *
## season(Mort)49 1.685077 0.817451 2.061 0.0398 *
## season(Mort)50 0.028495 0.817294 0.035 0.9722
## season(Mort)51 0.152611 0.817377 0.187 0.8520
## season(Mort)52 -0.169987 0.813617 -0.209 0.8346
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.722 on 451 degrees of freedom
## Multiple R-squared: 0.6778, Adjusted R-squared: 0.6385
## F-statistic: 17.25 on 55 and 451 DF, p-value: < 2.2e-16
checkresiduals(dynlmodel5)
##
## Breusch-Godfrey test for serial correlation of order up to 101
##
## data: Residuals
## LM test = 114.97, df = 101, p-value = 0.1617
dynlmodel6=dynlm(Mort~(Temp+Chem1+Size)+L(Mort , k = 1 )+season(Mort))
summary(dynlmodel6)
##
## Time series regression with "ts" data:
## Start = 2010(2), End = 2019(40)
##
## Call:
## dynlm(formula = Mort ~ (Temp + Chem1 + Size) + L(Mort, k = 1) +
## season(Mort))
##
## Residuals:
## Min 1Q Median 3Q Max
## -5.5300 -1.0714 -0.1024 0.9564 8.9741
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.9642213 1.2180266 0.792 0.42900
## Temp 0.0394211 0.0182653 2.158 0.03144 *
## Chem1 -0.0464694 0.0979468 -0.474 0.63542
## Size -0.0001263 0.0109298 -0.012 0.99078
## L(Mort, k = 1) 0.6812115 0.0346314 19.670 < 2e-16 ***
## season(Mort)2 -0.9080294 0.7958839 -1.141 0.25451
## season(Mort)3 -1.1611951 0.7970726 -1.457 0.14586
## season(Mort)4 -0.0679431 0.8025633 -0.085 0.93257
## season(Mort)5 0.6740990 0.7992977 0.843 0.39947
## season(Mort)6 -1.3227028 0.8088437 -1.635 0.10268
## season(Mort)7 -1.5278997 0.8244386 -1.853 0.06450 .
## season(Mort)8 -1.4245088 0.8235397 -1.730 0.08436 .
## season(Mort)9 -0.6500931 0.8281499 -0.785 0.43287
## season(Mort)10 -1.2202327 0.8317069 -1.467 0.14303
## season(Mort)11 -1.7837689 0.8362755 -2.133 0.03346 *
## season(Mort)12 -0.5210183 0.8462140 -0.616 0.53840
## season(Mort)13 -1.2439540 0.8398697 -1.481 0.13927
## season(Mort)14 -1.6419833 0.8575718 -1.915 0.05616 .
## season(Mort)15 -0.9897669 0.8671671 -1.141 0.25432
## season(Mort)16 -2.2784389 0.8712539 -2.615 0.00922 **
## season(Mort)17 -1.7524264 0.8748914 -2.003 0.04577 *
## season(Mort)18 -1.8811182 0.8844274 -2.127 0.03397 *
## season(Mort)19 -1.3783835 0.9074536 -1.519 0.12947
## season(Mort)20 -1.8210339 0.9045208 -2.013 0.04468 *
## season(Mort)21 -2.2956459 0.9074018 -2.530 0.01175 *
## season(Mort)22 -1.2078555 0.9101930 -1.327 0.18517
## season(Mort)23 -1.8090974 0.9117535 -1.984 0.04784 *
## season(Mort)24 -1.8938560 0.9101939 -2.081 0.03802 *
## season(Mort)25 -1.9198684 0.9182578 -2.091 0.03711 *
## season(Mort)26 -2.1676061 0.9144329 -2.370 0.01819 *
## season(Mort)27 -2.1295245 0.9002176 -2.366 0.01842 *
## season(Mort)28 -2.0700275 0.9038044 -2.290 0.02246 *
## season(Mort)29 -1.5133646 0.8989405 -1.683 0.09297 .
## season(Mort)30 -1.9007795 0.9040357 -2.103 0.03606 *
## season(Mort)31 -1.8910427 0.8715733 -2.170 0.03055 *
## season(Mort)32 -2.3687225 0.8716237 -2.718 0.00683 **
## season(Mort)33 -0.6874380 0.8849574 -0.777 0.43768
## season(Mort)34 -1.2367806 0.8540761 -1.448 0.14829
## season(Mort)35 -2.2946795 0.8311871 -2.761 0.00600 **
## season(Mort)36 -1.1162038 0.8267442 -1.350 0.17765
## season(Mort)37 -1.3889455 0.8204652 -1.693 0.09117 .
## season(Mort)38 -1.1327438 0.8110829 -1.397 0.16323
## season(Mort)39 -1.9321300 0.8139200 -2.374 0.01802 *
## season(Mort)40 -0.7146984 0.8109593 -0.881 0.37862
## season(Mort)41 -1.4310504 0.8287435 -1.727 0.08489 .
## season(Mort)42 -0.5212510 0.8288611 -0.629 0.52975
## season(Mort)43 -0.9382023 0.8349184 -1.124 0.26174
## season(Mort)44 -0.4803113 0.8307503 -0.578 0.56344
## season(Mort)45 0.6291460 0.8296272 0.758 0.44864
## season(Mort)46 -0.1240427 0.8247350 -0.150 0.88051
## season(Mort)47 1.4461228 0.8401810 1.721 0.08590 .
## season(Mort)48 1.5989844 0.8168302 1.958 0.05090 .
## season(Mort)49 1.6371692 0.8185874 2.000 0.04610 *
## season(Mort)50 -0.0006682 0.8180879 -0.001 0.99935
## season(Mort)51 0.1391609 0.8182943 0.170 0.86504
## season(Mort)52 -0.2066273 0.8133776 -0.254 0.79958
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.723 on 451 degrees of freedom
## Multiple R-squared: 0.6776, Adjusted R-squared: 0.6382
## F-statistic: 17.23 on 55 and 451 DF, p-value: < 2.2e-16
checkresiduals(dynlmodel6)
##
## Breusch-Godfrey test for serial correlation of order up to 101
##
## data: Residuals
## LM test = 113.91, df = 101, p-value = 0.1791
dynlmodel7=dynlm(Mort~(Chem1+Chem2+Size)+L(Mort , k = 1 )+season(Mort))
summary(dynlmodel7)
##
## Time series regression with "ts" data:
## Start = 2010(2), End = 2019(40)
##
## Call:
## dynlm(formula = Mort ~ (Chem1 + Chem2 + Size) + L(Mort, k = 1) +
## season(Mort))
##
## Residuals:
## Min 1Q Median 3Q Max
## -5.5055 -1.0650 -0.0702 0.9719 9.1361
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.5126693 0.8513210 2.951 0.00333 **
## Chem1 -0.1049587 0.1110513 -0.945 0.34510
## Chem2 0.0204592 0.0116255 1.760 0.07911 .
## Size 0.0009281 0.0112376 0.083 0.93421
## L(Mort, k = 1) 0.6802569 0.0346932 19.608 < 2e-16 ***
## season(Mort)2 -0.7697063 0.7945265 -0.969 0.33318
## season(Mort)3 -1.0249372 0.7973326 -1.285 0.19929
## season(Mort)4 0.0872325 0.8043005 0.108 0.91368
## season(Mort)5 0.8697840 0.7973158 1.091 0.27590
## season(Mort)6 -1.0943728 0.8042890 -1.361 0.17430
## season(Mort)7 -1.1638804 0.8102663 -1.436 0.15158
## season(Mort)8 -1.0666921 0.8109465 -1.315 0.18905
## season(Mort)9 -0.3562771 0.8188306 -0.435 0.66369
## season(Mort)10 -0.8140866 0.8210943 -0.991 0.32199
## season(Mort)11 -1.2573253 0.8180704 -1.537 0.12501
## season(Mort)12 0.0121350 0.8301503 0.015 0.98834
## season(Mort)13 -0.6853489 0.8177855 -0.838 0.40244
## season(Mort)14 -0.9905169 0.8283905 -1.196 0.23244
## season(Mort)15 -0.2778122 0.8288513 -0.335 0.73765
## season(Mort)16 -1.5171262 0.8320817 -1.823 0.06892 .
## season(Mort)17 -0.9860629 0.8353952 -1.180 0.23848
## season(Mort)18 -1.0208886 0.8294809 -1.231 0.21906
## season(Mort)19 -0.4594090 0.8332193 -0.551 0.58166
## season(Mort)20 -0.8588476 0.8308647 -1.034 0.30184
## season(Mort)21 -1.3660411 0.8320853 -1.642 0.10135
## season(Mort)22 -0.2069180 0.8325457 -0.249 0.80383
## season(Mort)23 -0.7614114 0.8342558 -0.913 0.36190
## season(Mort)24 -0.8323498 0.8256144 -1.008 0.31392
## season(Mort)25 -0.8253997 0.8331248 -0.991 0.32235
## season(Mort)26 -1.1244881 0.8288656 -1.357 0.17557
## season(Mort)27 -1.1435349 0.8315037 -1.375 0.16973
## season(Mort)28 -1.1569254 0.8290880 -1.395 0.16358
## season(Mort)29 -0.6565755 0.8236926 -0.797 0.42581
## season(Mort)30 -0.9644805 0.8246766 -1.170 0.24281
## season(Mort)31 -1.1517250 0.8174478 -1.409 0.15955
## season(Mort)32 -1.6050172 0.8153013 -1.969 0.04961 *
## season(Mort)33 0.0797987 0.8167848 0.098 0.92222
## season(Mort)34 -0.5383868 0.8081345 -0.666 0.50562
## season(Mort)35 -1.7087565 0.8052962 -2.122 0.03439 *
## season(Mort)36 -0.6508256 0.8103691 -0.803 0.42233
## season(Mort)37 -1.0279220 0.8063644 -1.275 0.20305
## season(Mort)38 -0.8899488 0.8085755 -1.101 0.27164
## season(Mort)39 -1.6386634 0.8076046 -2.029 0.04304 *
## season(Mort)40 -0.5949456 0.8130604 -0.732 0.46471
## season(Mort)41 -1.3806313 0.8304308 -1.663 0.09710 .
## season(Mort)42 -0.4824302 0.8304293 -0.581 0.56157
## season(Mort)43 -1.0069590 0.8351657 -1.206 0.22857
## season(Mort)44 -0.5557324 0.8301634 -0.669 0.50357
## season(Mort)45 0.5024209 0.8292032 0.606 0.54488
## season(Mort)46 -0.2020466 0.8240410 -0.245 0.80642
## season(Mort)47 1.1759552 0.8255715 1.424 0.15502
## season(Mort)48 1.5255204 0.8173025 1.867 0.06262 .
## season(Mort)49 1.6202106 0.8198803 1.976 0.04875 *
## season(Mort)50 0.0062646 0.8194941 0.008 0.99390
## season(Mort)51 0.0152261 0.8175697 0.019 0.98515
## season(Mort)52 -0.1154633 0.8146367 -0.142 0.88735
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.726 on 451 degrees of freedom
## Multiple R-squared: 0.6765, Adjusted R-squared: 0.637
## F-statistic: 17.14 on 55 and 451 DF, p-value: < 2.2e-16
checkresiduals(dynlmodel7)
##
## Breusch-Godfrey test for serial correlation of order up to 101
##
## data: Residuals
## LM test = 116.45, df = 101, p-value = 0.1395
dynlmodel8=dynlm(Mort~(Temp+Chem2)+L(Mort , k = 1 )+season(Mort))
summary(dynlmodel8)
##
## Time series regression with "ts" data:
## Start = 2010(2), End = 2019(40)
##
## Call:
## dynlm(formula = Mort ~ (Temp + Chem2) + L(Mort, k = 1) + season(Mort))
##
## Residuals:
## Min 1Q Median 3Q Max
## -5.5024 -1.0465 -0.0749 0.9407 8.9826
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.2404115 1.2062844 1.028 0.3044
## Temp 0.0288292 0.0183743 1.569 0.1173
## Chem2 0.0049143 0.0092416 0.532 0.5952
## L(Mort, k = 1) 0.6807370 0.0345536 19.701 <2e-16 ***
## season(Mort)2 -0.8527302 0.7934546 -1.075 0.2831
## season(Mort)3 -1.1321722 0.7938679 -1.426 0.1545
## season(Mort)4 0.0108988 0.8015111 0.014 0.9892
## season(Mort)5 0.7271778 0.7978144 0.911 0.3625
## season(Mort)6 -1.2409271 0.7984200 -1.554 0.1208
## season(Mort)7 -1.4075122 0.8096864 -1.738 0.0828 .
## season(Mort)8 -1.2996454 0.8135064 -1.598 0.1108
## season(Mort)9 -0.5302940 0.8132154 -0.652 0.5147
## season(Mort)10 -1.0775362 0.8206854 -1.313 0.1899
## season(Mort)11 -1.6439335 0.8294275 -1.982 0.0481 *
## season(Mort)12 -0.3539824 0.8374163 -0.423 0.6727
## season(Mort)13 -1.0940371 0.8325449 -1.314 0.1895
## season(Mort)14 -1.4444596 0.8474591 -1.704 0.0890 .
## season(Mort)15 -0.7837135 0.8571787 -0.914 0.3610
## season(Mort)16 -2.0484513 0.8640310 -2.371 0.0182 *
## season(Mort)17 -1.5282029 0.8696159 -1.757 0.0795 .
## season(Mort)18 -1.6369973 0.8858954 -1.848 0.0653 .
## season(Mort)19 -1.1374082 0.8946975 -1.271 0.2043
## season(Mort)20 -1.6141620 0.8956693 -1.802 0.0722 .
## season(Mort)21 -2.0682705 0.8914496 -2.320 0.0208 *
## season(Mort)22 -0.9553559 0.9096093 -1.050 0.2941
## season(Mort)23 -1.5406691 0.9130863 -1.687 0.0922 .
## season(Mort)24 -1.6547284 0.9172404 -1.804 0.0719 .
## season(Mort)25 -1.6715009 0.9213115 -1.814 0.0703 .
## season(Mort)26 -1.9036997 0.9148156 -2.081 0.0380 *
## season(Mort)27 -1.8770698 0.9050706 -2.074 0.0386 *
## season(Mort)28 -1.8393610 0.8943822 -2.057 0.0403 *
## season(Mort)29 -1.2927630 0.8880957 -1.456 0.1462
## season(Mort)30 -1.6765017 0.8962367 -1.871 0.0620 .
## season(Mort)31 -1.6975077 0.8654714 -1.961 0.0504 .
## season(Mort)32 -2.1712641 0.8716078 -2.491 0.0131 *
## season(Mort)33 -0.4717089 0.8798809 -0.536 0.5921
## season(Mort)34 -1.0585650 0.8565002 -1.236 0.2171
## season(Mort)35 -2.1319331 0.8412390 -2.534 0.0116 *
## season(Mort)36 -0.9999001 0.8330190 -1.200 0.2306
## season(Mort)37 -1.2629231 0.8199697 -1.540 0.1242
## season(Mort)38 -1.0802350 0.8120290 -1.330 0.1841
## season(Mort)39 -1.8600914 0.8153165 -2.281 0.0230 *
## season(Mort)40 -0.6693369 0.8083821 -0.828 0.4081
## season(Mort)41 -1.4211882 0.8251872 -1.722 0.0857 .
## season(Mort)42 -0.5053029 0.8261676 -0.612 0.5411
## season(Mort)43 -0.9588626 0.8226507 -1.166 0.2444
## season(Mort)44 -0.5092373 0.8218182 -0.620 0.5358
## season(Mort)45 0.5953096 0.8213428 0.725 0.4689
## season(Mort)46 -0.1246126 0.8146091 -0.153 0.8785
## season(Mort)47 1.3886233 0.8223059 1.689 0.0920 .
## season(Mort)48 1.5870170 0.8119090 1.955 0.0512 .
## season(Mort)49 1.6354433 0.8127410 2.012 0.0448 *
## season(Mort)50 0.0009682 0.8154492 0.001 0.9991
## season(Mort)51 0.1117243 0.8139981 0.137 0.8909
## season(Mort)52 -0.1667990 0.8130277 -0.205 0.8375
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.721 on 452 degrees of freedom
## Multiple R-squared: 0.6776, Adjusted R-squared: 0.639
## F-statistic: 17.59 on 54 and 452 DF, p-value: < 2.2e-16
checkresiduals(dynlmodel8)
##
## Breusch-Godfrey test for serial correlation of order up to 101
##
## data: Residuals
## LM test = 114.7, df = 101, p-value = 0.1661
dynlmodel9=dynlm(Mort~(Temp+Chem1)+L(Mort , k = 1 )+season(Mort))
summary(dynlmodel9)
##
## Time series regression with "ts" data:
## Start = 2010(2), End = 2019(40)
##
## Call:
## dynlm(formula = Mort ~ (Temp + Chem1) + L(Mort, k = 1) + season(Mort))
##
## Residuals:
## Min 1Q Median 3Q Max
## -5.5292 -1.0713 -0.1025 0.9566 8.9740
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.965592 1.210898 0.797 0.42563
## Temp 0.039320 0.016009 2.456 0.01442 *
## Chem1 -0.046955 0.088383 -0.531 0.59550
## L(Mort, k = 1) 0.681198 0.034573 19.703 < 2e-16 ***
## season(Mort)2 -0.907278 0.792344 -1.145 0.25279
## season(Mort)3 -1.160266 0.792132 -1.465 0.14369
## season(Mort)4 -0.066932 0.796898 -0.084 0.93310
## season(Mort)5 0.674952 0.795002 0.849 0.39633
## season(Mort)6 -1.320890 0.792622 -1.666 0.09631 .
## season(Mort)7 -1.525566 0.798450 -1.911 0.05668 .
## season(Mort)8 -1.422439 0.802954 -1.772 0.07715 .
## season(Mort)9 -0.647876 0.804730 -0.805 0.42119
## season(Mort)10 -1.217769 0.803051 -1.516 0.13011
## season(Mort)11 -1.781278 0.807137 -2.207 0.02782 *
## season(Mort)12 -0.518224 0.810039 -0.640 0.52266
## season(Mort)13 -1.241352 0.808241 -1.536 0.12527
## season(Mort)14 -1.638809 0.811510 -2.019 0.04403 *
## season(Mort)15 -0.986489 0.818584 -1.205 0.22879
## season(Mort)16 -2.274980 0.817335 -2.783 0.00560 **
## season(Mort)17 -1.749064 0.824195 -2.122 0.03437 *
## season(Mort)18 -1.877843 0.836893 -2.244 0.02533 *
## season(Mort)19 -1.374547 0.843626 -1.629 0.10394
## season(Mort)20 -1.817308 0.844196 -2.153 0.03187 *
## season(Mort)21 -2.291700 0.839784 -2.729 0.00660 **
## season(Mort)22 -1.204128 0.850219 -1.416 0.15739
## season(Mort)23 -1.805127 0.843641 -2.140 0.03291 *
## season(Mort)24 -1.890343 0.856984 -2.206 0.02790 *
## season(Mort)25 -1.915974 0.853262 -2.245 0.02522 *
## season(Mort)26 -2.163779 0.851449 -2.541 0.01138 *
## season(Mort)27 -2.125954 0.844627 -2.517 0.01218 *
## season(Mort)28 -2.066407 0.846849 -2.440 0.01507 *
## season(Mort)29 -1.510026 0.850321 -1.776 0.07643 .
## season(Mort)30 -1.897217 0.848918 -2.235 0.02591 *
## season(Mort)31 -1.888222 0.835777 -2.259 0.02434 *
## season(Mort)32 -2.366160 0.842024 -2.810 0.00517 **
## season(Mort)33 -0.684859 0.855428 -0.801 0.42378
## season(Mort)34 -1.234582 0.831699 -1.484 0.13840
## season(Mort)35 -2.293519 0.824191 -2.783 0.00562 **
## season(Mort)36 -1.115519 0.823707 -1.354 0.17633
## season(Mort)37 -1.387990 0.815385 -1.702 0.08940 .
## season(Mort)38 -1.132858 0.810125 -1.398 0.16269
## season(Mort)39 -1.932148 0.813018 -2.377 0.01789 *
## season(Mort)40 -0.715342 0.808149 -0.885 0.37654
## season(Mort)41 -1.431804 0.825263 -1.735 0.08343 .
## season(Mort)42 -0.521845 0.826352 -0.632 0.52803
## season(Mort)43 -0.939846 0.821802 -1.144 0.25338
## season(Mort)44 -0.481647 0.821768 -0.586 0.55809
## season(Mort)45 0.627710 0.819369 0.766 0.44402
## season(Mort)46 -0.125463 0.814630 -0.154 0.87767
## season(Mort)47 1.444051 0.819926 1.761 0.07888 .
## season(Mort)48 1.598001 0.811490 1.969 0.04954 *
## season(Mort)49 1.636129 0.812723 2.013 0.04469 *
## season(Mort)50 -0.001275 0.815497 -0.002 0.99875
## season(Mort)51 0.138168 0.812872 0.170 0.86511
## season(Mort)52 -0.206428 0.812295 -0.254 0.79951
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.721 on 452 degrees of freedom
## Multiple R-squared: 0.6776, Adjusted R-squared: 0.639
## F-statistic: 17.59 on 54 and 452 DF, p-value: < 2.2e-16
checkresiduals(dynlmodel9)
##
## Breusch-Godfrey test for serial correlation of order up to 101
##
## data: Residuals
## LM test = 113.9, df = 101, p-value = 0.1792
dynlmodel10=dynlm(Mort~(Chem1+Chem2)+L(Mort , k = 1 )+season(Mort))
summary(dynlmodel10)
##
## Time series regression with "ts" data:
## Start = 2010(2), End = 2019(40)
##
## Call:
## dynlm(formula = Mort ~ (Chem1 + Chem2) + L(Mort, k = 1) + season(Mort))
##
## Residuals:
## Min 1Q Median 3Q Max
## -5.5095 -1.0639 -0.0686 0.9702 9.1406
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.528298 0.829110 3.049 0.00243 **
## Chem1 -0.103243 0.108970 -0.947 0.34392
## Chem2 0.020957 0.009928 2.111 0.03532 *
## L(Mort, k = 1) 0.680364 0.034631 19.646 < 2e-16 ***
## season(Mort)2 -0.772494 0.792937 -0.974 0.33047
## season(Mort)3 -1.028746 0.795123 -1.294 0.19639
## season(Mort)4 0.083455 0.802116 0.104 0.91718
## season(Mort)5 0.867552 0.795982 1.090 0.27633
## season(Mort)6 -1.102816 0.796888 -1.384 0.16707
## season(Mort)7 -1.173510 0.800951 -1.465 0.14358
## season(Mort)8 -1.074522 0.804500 -1.336 0.18234
## season(Mort)9 -0.366433 0.808655 -0.453 0.65067
## season(Mort)10 -0.823443 0.812347 -1.014 0.31129
## season(Mort)11 -1.264534 0.812506 -1.556 0.12033
## season(Mort)12 0.003037 0.821904 0.004 0.99705
## season(Mort)13 -0.692770 0.811940 -0.853 0.39398
## season(Mort)14 -1.000118 0.819291 -1.221 0.22283
## season(Mort)15 -0.287081 0.820315 -0.350 0.72653
## season(Mort)16 -1.526577 0.823270 -1.854 0.06435 .
## season(Mort)17 -0.994741 0.827849 -1.202 0.23015
## season(Mort)18 -1.027279 0.824957 -1.245 0.21368
## season(Mort)19 -0.468919 0.824317 -0.569 0.56973
## season(Mort)20 -0.866569 0.824680 -1.051 0.29391
## season(Mort)21 -1.376097 0.822224 -1.674 0.09490 .
## season(Mort)22 -0.213869 0.827371 -0.258 0.79615
## season(Mort)23 -0.768996 0.828274 -0.928 0.35368
## season(Mort)24 -0.836585 0.823115 -1.016 0.31000
## season(Mort)25 -0.831574 0.828852 -1.003 0.31626
## season(Mort)26 -1.131358 0.823775 -1.373 0.17031
## season(Mort)27 -1.149506 0.827444 -1.389 0.16545
## season(Mort)28 -1.165067 0.822301 -1.417 0.15722
## season(Mort)29 -0.664072 0.817776 -0.812 0.41719
## season(Mort)30 -0.971800 0.819000 -1.187 0.23602
## season(Mort)31 -1.157687 0.813359 -1.423 0.15533
## season(Mort)32 -1.608674 0.813203 -1.978 0.04851 *
## season(Mort)33 0.075716 0.814392 0.093 0.92597
## season(Mort)34 -0.540667 0.806775 -0.670 0.50310
## season(Mort)35 -1.705640 0.803528 -2.123 0.03432 *
## season(Mort)36 -0.646727 0.807959 -0.800 0.42387
## season(Mort)37 -1.028004 0.805477 -1.276 0.20252
## season(Mort)38 -0.884430 0.804923 -1.099 0.27245
## season(Mort)39 -1.632985 0.803789 -2.032 0.04278 *
## season(Mort)40 -0.587851 0.807621 -0.728 0.46706
## season(Mort)41 -1.374230 0.825897 -1.664 0.09682 .
## season(Mort)42 -0.477410 0.827291 -0.577 0.56418
## season(Mort)43 -0.996482 0.824569 -1.208 0.22749
## season(Mort)44 -0.547158 0.822740 -0.665 0.50636
## season(Mort)45 0.510117 0.823044 0.620 0.53571
## season(Mort)46 -0.192954 0.815755 -0.237 0.81313
## season(Mort)47 1.186241 0.815227 1.455 0.14633
## season(Mort)48 1.531137 0.813573 1.882 0.06048 .
## season(Mort)49 1.627360 0.814401 1.998 0.04629 *
## season(Mort)50 0.010645 0.816877 0.013 0.98961
## season(Mort)51 0.019952 0.814668 0.024 0.98047
## season(Mort)52 -0.114987 0.813721 -0.141 0.88769
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.724 on 452 degrees of freedom
## Multiple R-squared: 0.6764, Adjusted R-squared: 0.6378
## F-statistic: 17.5 on 54 and 452 DF, p-value: < 2.2e-16
checkresiduals(dynlmodel10)
##
## Breusch-Godfrey test for serial correlation of order up to 101
##
## data: Residuals
## LM test = 116.5, df = 101, p-value = 0.1389
In our series we do not see any trend and have a seasonal effect. The holt’s-Winter method will be the best method for our series to deal with the seasonal effects.
Model created using Holt’s-Winter method are:
1.Seasonality=Additive,damped=False 2.Seasonality=Additive,damped=True 3.Seasonality=multiplicative,damped=False 4.Seasonality=multiplicative,damped=True 5.Seasonality=multiplicative,damped=False,Exponential =True
From the observation we see that:
Mort1<-ts(mort$mortality,start = 2010,frequency = 12)
hw1 <- hw(Mort1)
summary(hw1,)
##
## Forecast method: Holt-Winters' additive method
##
## Model Information:
## Holt-Winters' additive method
##
## Call:
## hw(y = Mort1)
##
## Smoothing parameters:
## alpha = 0.7332
## beta = 1e-04
## gamma = 1e-04
##
## Initial states:
## l = 10.3348
## b = 0.0143
## s = -0.4341 -0.0346 0.2245 0.6352 0.1044 0.127
## 0.1967 -8e-04 -0.0835 -0.5546 -0.1484 -0.0318
##
## sigma: 1.8421
##
## AIC AICc BIC
## 3803.535 3804.784 3875.453
##
## Error measures:
## ME RMSE MAE MPE MAPE MASE
## Training set -0.0195681 1.812906 1.386783 -2.906073 16.87891 0.5079491
## ACF1
## Training set -0.01676383
##
## Forecasts:
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## May 2052 9.940752 7.579943 12.30156 6.33020669 13.55130
## Jun 2052 10.151914 7.224431 13.07940 5.67471441 14.62911
## Jul 2052 10.095634 6.694499 13.49677 4.89404627 15.29722
## Aug 2052 10.086580 6.270024 13.90314 4.24966064 15.92350
## Sep 2052 10.630301 6.439203 14.82140 4.22056995 17.04003
## Oct 2052 10.232184 5.697284 14.76708 3.29665297 17.16771
## Nov 2052 9.987131 5.132633 14.84163 2.56281699 17.41144
## Dec 2052 9.601246 4.446850 14.75564 1.71827779 17.48422
## Jan 2053 10.017018 4.579163 15.45487 1.70053593 18.33350
## Feb 2053 9.912765 4.205440 15.62009 1.18416464 18.64136
## Mar 2053 9.520023 3.555321 15.48472 0.39779900 18.64225
## Apr 2053 10.004449 3.792961 16.21594 0.50479760 19.50410
## May 2053 10.100255 3.651290 16.54922 0.23741371 19.96310
## Jun 2053 10.311417 3.633415 16.98942 0.09829453 20.52454
## Jul 2053 10.255137 3.355638 17.15464 -0.29673666 20.80701
## Aug 2053 10.246083 3.131922 17.36024 -0.63408808 21.12625
## Sep 2053 10.789804 3.467215 18.11239 -0.40912993 21.98874
## Oct 2053 10.391687 2.866386 17.91699 -1.11726765 21.90064
## Nov 2053 10.146634 2.423888 17.86938 -1.66428736 21.95755
## Dec 2053 9.760750 1.845430 17.67607 -2.34468727 21.86619
## Jan 2054 10.176521 2.073152 18.27989 -2.21651189 22.56955
## Feb 2054 10.072268 1.785067 18.35947 -2.60191216 22.74645
## Mar 2054 9.679526 1.212435 18.14662 -3.26977287 22.62882
## Apr 2054 10.163952 1.520667 18.80724 -3.05481257 23.38272
checkresiduals(hw1)
##
## Ljung-Box test
##
## data: Residuals from Holt-Winters' additive method
## Q* = 33.437, df = 8, p-value = 5.137e-05
##
## Model df: 16. Total lags used: 24
hw2 <- hw(Mort1,seasonal="multiplicative")
summary(hw2)
##
## Forecast method: Holt-Winters' multiplicative method
##
## Model Information:
## Holt-Winters' multiplicative method
##
## Call:
## hw(y = Mort1, seasonal = "multiplicative")
##
## Smoothing parameters:
## alpha = 0.7038
## beta = 1e-04
## gamma = 0.0491
##
## Initial states:
## l = 10.4633
## b = -0.0029
## s = 0.8223 0.9679 0.9472 1.2003 1.1166 0.9794
## 1.0108 1.0093 1.0572 0.9468 0.9657 0.9765
##
## sigma: 0.2199
##
## AIC AICc BIC
## 3766.418 3767.667 3838.336
##
## Error measures:
## ME RMSE MAE MPE MAPE MASE
## Training set -0.01424617 1.79207 1.391516 -2.818327 17.18849 0.5096827
## ACF1
## Training set 0.004153088
##
## Forecasts:
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## May 2052 9.867256 7.08633550 12.64818 5.6142050 14.12031
## Jun 2052 10.275770 6.70555186 13.84599 4.8155923 15.73595
## Jul 2052 10.463877 6.23895597 14.68880 4.0024181 16.92534
## Aug 2052 10.091908 5.50721360 14.67660 3.0802230 17.10359
## Sep 2052 11.219417 5.60053916 16.83830 2.6260847 19.81275
## Oct 2052 10.983644 5.00430998 16.96298 1.8390419 20.12825
## Nov 2052 10.389083 4.30439177 16.47377 1.0833507 19.69482
## Dec 2052 10.079810 3.77813310 16.38149 0.4422266 19.71739
## Jan 2053 9.915896 3.33948411 16.49231 -0.1418578 19.97365
## Feb 2053 9.893707 2.96749316 16.81992 -0.6990230 20.48644
## Mar 2053 9.233924 2.43859699 16.02925 -1.1586316 19.62648
## Apr 2053 9.830663 2.25203466 17.40929 -1.7598489 21.42117
## May 2053 9.851306 1.87265631 17.82996 -2.3509859 22.05360
## Jun 2053 10.259151 1.60530059 18.91300 -2.9757710 23.49407
## Jul 2053 10.446943 1.28873627 19.60515 -3.5593257 24.45321
## Aug 2053 10.075567 0.91359069 19.23754 -3.9364668 24.08760
## Sep 2053 11.201241 0.65362549 21.74886 -4.9299450 27.33243
## Oct 2053 10.965840 0.28886789 21.64281 -5.3631795 27.29486
## Nov 2053 10.372233 -0.05606606 20.80053 -5.5764744 26.32094
## Dec 2053 10.063453 -0.37167494 20.49858 -5.8956980 26.02260
## Jan 2054 9.899795 -0.67594135 20.47553 -6.2743981 26.07399
## Feb 2054 9.877634 -0.98257343 20.73784 -6.7316199 26.48689
## Mar 2054 9.218914 -1.20354974 19.64138 -6.7208687 25.15870
## Apr 2054 9.814674 -1.58545001 21.21480 -7.6203113 27.24966
checkresiduals(hw2)
##
## Ljung-Box test
##
## data: Residuals from Holt-Winters' multiplicative method
## Q* = 46.492, df = 8, p-value = 1.916e-07
##
## Model df: 16. Total lags used: 24
hw3 <- hw(Mort1,seasonal="additive",damped = TRUE, h=5*frequency(Mort1))
summary(hw3)
##
## Forecast method: Damped Holt-Winters' additive method
##
## Model Information:
## Damped Holt-Winters' additive method
##
## Call:
## hw(y = Mort1, h = 5 * frequency(Mort1), seasonal = "additive",
##
## Call:
## damped = TRUE)
##
## Smoothing parameters:
## alpha = 0.7284
## beta = 0.021
## gamma = 1e-04
## phi = 0.8
##
## Initial states:
## l = 10.1948
## b = -0.2669
## s = -0.4294 -0.1769 0.1122 0.7035 0.1411 0.0842
## 0.1535 -0.0453 -0.0086 -0.5943 -0.0715 0.1313
##
## sigma: 1.8471
##
## AIC AICc BIC
## 3807.213 3808.612 3883.362
##
## Error measures:
## ME RMSE MAE MPE MAPE MASE
## Training set 0.002137124 1.815903 1.388437 -2.542581 16.90013 0.5085548
## ACF1
## Training set -0.02483175
##
## Forecasts:
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## May 2052 9.852696 7.48557816 12.21981 6.2325015 13.47289
## Jun 2052 10.073857 7.12171110 13.02600 5.5589392 14.58878
## Jul 2052 10.022375 6.56688460 13.47787 4.7376582 15.30709
## Aug 2052 10.093481 6.18735921 13.99960 4.1195831 16.06738
## Sep 2052 10.667067 6.34852596 14.98561 4.0624285 17.27171
## Oct 2052 10.085157 5.38386955 14.78645 2.8951581 17.27516
## Nov 2052 9.803698 4.74375279 14.86364 2.0651796 17.54222
## Dec 2052 9.556563 4.15812561 14.95500 1.3003653 17.81276
## Jan 2053 10.121805 4.40212901 15.84148 1.3743156 18.86929
## Feb 2053 9.922826 3.89692110 15.94873 0.7069998 19.13865
## Mar 2053 9.403507 3.08459490 15.72242 -0.2604353 19.06745
## Apr 2053 9.990776 3.39062007 16.59093 -0.1032913 20.08484
## May 2053 9.956627 3.08571705 16.82754 -0.5515230 20.46478
## Jun 2053 10.157003 3.02494136 17.28906 -0.7505439 21.06455
## Jul 2053 10.088892 2.70434300 17.47344 -1.2048013 21.38259
## Aug 2053 10.146695 2.51757067 17.77582 -1.5210439 21.81443
## Sep 2053 10.709638 2.84319809 18.57608 -1.3210439 22.74032
## Oct 2053 10.119215 2.02214609 18.21628 -2.2641832 22.50261
## Nov 2053 9.830944 1.50942980 18.15246 -2.8957138 22.55760
## Dec 2053 9.578360 1.03813605 18.11858 -3.4827857 22.63951
## Jan 2054 10.139242 1.38564502 18.89284 -3.2482296 23.52671
## Feb 2054 9.936776 0.97478616 18.89877 -3.7694048 23.64296
## Mar 2054 9.414668 0.24894498 18.58039 -4.6030956 23.43243
## Apr 2054 9.999704 0.63461935 19.36479 -4.3229571 24.32237
## May 2054 9.963770 0.40338456 19.52416 -4.6575777 24.58512
## Jun 2054 10.162717 0.41095153 19.91448 -4.7513213 25.07676
## Jul 2054 10.093464 0.15397318 20.03295 -5.1076753 25.29460
## Aug 2054 10.150352 0.02659433 20.27411 -5.3325995 25.63330
## Sep 2054 10.712564 0.40781514 21.01731 -5.0471895 26.47232
## Oct 2054 10.121555 -0.36107414 20.60419 -5.9102430 26.15335
## Nov 2054 9.832817 -0.82473609 20.49037 -6.4665037 26.13214
## Dec 2054 9.579859 -1.24980114 20.40952 -6.9826767 26.14239
## Jan 2055 10.140441 -0.85863982 21.13952 -6.6812014 26.96208
## Feb 2055 9.937735 -1.22820187 21.10367 -7.1390918 27.01456
## Mar 2055 9.415435 -1.91490554 20.74578 -7.9128255 26.74370
## Apr 2055 10.000318 -1.49207788 21.49271 -7.5757847 27.57642
## May 2055 9.964261 -1.68797842 21.61650 -7.8563012 27.78482
## Jun 2055 10.163110 -1.64677313 21.97299 -7.8985475 28.22477
## Jul 2055 10.093778 -1.87167361 22.05923 -8.2058010 28.39336
## Aug 2055 10.150604 -1.96842091 22.26963 -8.3838450 28.68505
## Sep 2055 10.712765 -1.55791169 22.98344 -8.0536157 29.47915
## Oct 2055 10.121716 -2.29876218 22.54219 -8.8737663 29.11720
## Nov 2055 9.832945 -2.73555003 22.40144 -9.3889096 29.05480
## Dec 2055 9.579961 -3.13482834 22.29475 -9.8656315 29.02555
## Jan 2056 10.140523 -2.71889713 22.99994 -9.5262631 29.80731
## Feb 2056 9.937801 -3.06464174 22.94024 -9.9477191 29.82332
## Mar 2056 9.415488 -3.72842140 22.55940 -10.6863865 29.51736
## Apr 2056 10.000360 -3.28350910 23.28423 -10.3155646 30.31628
## May 2056 9.964294 -3.45810947 23.38670 -10.5635009 30.49209
## Jun 2056 10.163137 -3.39635325 23.72263 -10.5743137 30.90059
## Jul 2056 10.093800 -3.60140453 23.78900 -10.8512076 31.03881
## Aug 2056 10.150621 -3.67896539 23.98021 -10.9999062 31.30115
## Sep 2056 10.712779 -3.24989651 24.67545 -10.6412905 32.06685
## Oct 2056 10.121727 -3.97278073 24.21624 -11.4339626 31.67742
## Nov 2056 9.832954 -4.39216476 24.05807 -11.9224879 31.58840
## Dec 2056 9.579969 -4.77457295 23.93451 -12.3734082 31.53335
## Jan 2057 10.140529 -4.34227859 24.62334 -12.0090138 32.29007
## Feb 2057 9.937805 -4.67214207 24.54775 -12.4061811 32.28179
## Mar 2057 9.415491 -5.32049942 24.15148 -13.1212617 31.95224
## Apr 2057 10.000363 -4.86060189 24.86133 -12.7275214 32.72825
checkresiduals(hw3)
##
## Ljung-Box test
##
## data: Residuals from Damped Holt-Winters' additive method
## Q* = 33.628, df = 7, p-value = 2.022e-05
##
## Model df: 17. Total lags used: 24
hw4 <- hw(Mort1,seasonal="multiplicative",damped = TRUE, h=5*frequency(Mort1))
summary(hw4)
##
## Forecast method: Damped Holt-Winters' multiplicative method
##
## Model Information:
## Damped Holt-Winters' multiplicative method
##
## Call:
## hw(y = Mort1, h = 5 * frequency(Mort1), seasonal = "multiplicative",
##
## Call:
## damped = TRUE)
##
## Smoothing parameters:
## alpha = 0.7225
## beta = 0.0266
## gamma = 0.0095
## phi = 0.8
##
## Initial states:
## l = 10.4413
## b = -0.638
## s = 0.9054 0.9989 0.9947 1.15 1.0652 1.0002
## 1.0274 0.9999 0.9919 0.921 0.9741 0.9713
##
## sigma: 0.2189
##
## AIC AICc BIC
## 3760.799 3762.198 3836.948
##
## Error measures:
## ME RMSE MAE MPE MAPE MASE
## Training set -0.001760619 1.7757 1.379873 -2.582379 17.01104 0.505418
## ACF1
## Training set -0.03024627
##
## Forecasts:
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## May 2052 10.035850 7.22006421 12.85164 5.7294770 14.34222
## Jun 2052 10.409853 6.73430731 14.08540 4.7885910 16.03111
## Jul 2052 10.309720 6.00585608 14.61358 3.7275284 16.89191
## Aug 2052 10.673745 5.58490173 15.76259 2.8910307 18.45646
## Sep 2052 11.591296 5.41860003 17.76399 2.1509720 21.03162
## Oct 2052 10.569319 4.37940076 16.75924 1.1026560 20.03598
## Nov 2052 10.279041 3.73427973 16.82380 0.2696922 20.28839
## Dec 2052 9.588644 3.00970932 16.16758 -0.4729686 19.65026
## Jan 2053 10.045989 2.67044443 17.42153 -1.2339330 21.32591
## Feb 2053 9.935423 2.17459158 17.69625 -1.9337443 21.80459
## Mar 2053 9.446201 1.63273357 17.25967 -2.5034663 21.39587
## Apr 2053 10.092607 1.28766968 18.89754 -3.3733826 23.55860
## May 2053 10.216719 0.83799967 19.59544 -4.1267943 24.56023
## Jun 2053 10.560192 0.40066042 20.71972 -4.9774707 26.09785
## Jul 2053 10.429282 -0.05960779 20.91817 -5.6120907 26.47066
## Aug 2053 10.773367 -0.52821343 22.07495 -6.5109087 28.05764
## Sep 2053 11.678580 -1.07531545 24.43247 -7.8268197 31.18398
## Oct 2053 10.633711 -1.43470580 22.70213 -7.8233400 29.09076
## Nov 2053 10.329875 -1.83482281 22.49457 -8.2744248 28.93417
## Dec 2053 9.627284 -2.12028425 21.37485 -8.3390711 27.59364
## Jan 2054 10.079125 -2.64891272 22.80716 -9.3867288 29.54498
## Feb 2054 9.962390 -3.04243582 22.96722 -9.9267746 29.85155
## Mar 2054 9.467430 -3.29485116 22.22971 -10.0507946 28.98565
## Apr 2054 10.111522 -3.95089932 24.17394 -11.3950956 31.61814
## May 2054 10.232853 -4.44578130 24.91149 -12.2161808 32.68189
## Jun 2054 10.574350 -5.04871962 26.19742 -13.3190733 34.46777
## Jul 2054 10.441276 -5.43598606 26.31854 -13.8409011 34.72345
## Aug 2054 10.784114 -6.08241302 27.65064 -15.0110131 36.57924
## Sep 2054 11.688806 -7.10271972 30.48033 -17.0503523 40.42796
## Oct 2054 10.641985 -6.93386436 28.21783 -16.2379570 37.52193
## Nov 2054 10.337106 -7.19213606 27.86635 -16.4715563 37.14577
## Dec 2054 9.633422 -7.13143724 26.39828 -16.0062177 35.27306
## Jan 2055 10.085048 -7.91823070 28.08833 -17.4485909 37.61869
## Feb 2055 9.967846 -8.27705928 28.21275 -17.9353290 37.87102
## Mar 2055 9.472313 -8.29768407 27.24231 -17.7045523 36.64918
## Apr 2055 10.116479 -9.32758866 29.56055 -19.6206564 39.85361
## May 2055 10.237662 -9.92486691 30.40019 -20.5982651 41.07359
## Jun 2055 10.579147 -10.75217551 31.91047 -22.0442958 43.20259
## Jul 2055 10.445877 -11.11163301 32.00339 -22.5234893 43.41524
## Aug 2055 10.788752 -11.99278347 33.57029 -24.0526001 45.63010
## Sep 2055 11.693735 -13.56443307 36.95190 -26.9352996 50.32277
## Oct 2055 10.646402 -12.87015557 34.16296 -25.3190691 46.61187
## Nov 2055 10.341341 -13.01268439 33.69537 -25.3755586 46.05824
## Dec 2055 9.637327 -12.60872766 31.88338 -24.3850779 43.65973
## Jan 2056 10.089102 -13.71015022 33.88835 -26.3087133 46.48692
## Feb 2056 9.971826 -14.06116567 34.00482 -26.7834628 46.72711
## Mar 2056 9.476074 -13.85295059 32.80510 -26.2025900 45.15474
## Apr 2056 10.120478 -15.32562050 35.56658 -28.7959713 49.03693
## May 2056 10.241695 -16.06422281 36.54761 -29.9897343 50.47312
## Jun 2056 10.583302 -17.16898611 38.33559 -31.8601602 53.02676
## Jul 2056 10.449970 -17.52164039 38.42158 -32.3289164 53.22886
## Aug 2056 10.792972 -18.69198904 40.27793 -34.3003847 55.88633
## Sep 2056 11.698302 -20.91350130 44.31011 -38.1771472 61.57375
## Oct 2056 10.650555 -19.64333865 40.94445 -35.6799572 56.98107
## Nov 2056 10.345371 -19.67396154 40.36470 -35.5652364 56.25598
## Dec 2056 9.641081 -18.89515263 38.17731 -34.0013220 53.28348
## Jan 2057 10.093029 -20.37573382 40.56179 -36.5049223 56.69098
## Feb 2057 9.975705 -20.73487812 40.68629 -36.9920787 56.94349
## Mar 2057 9.479759 -20.27825480 39.23777 -36.0311955 54.99071
## Apr 2057 10.124412 -22.27908071 42.52790 -39.4324536 59.68128
checkresiduals(hw4)
##
## Ljung-Box test
##
## data: Residuals from Damped Holt-Winters' multiplicative method
## Q* = 52.029, df = 7, p-value = 5.763e-09
##
## Model df: 17. Total lags used: 24
hw5 <- hw(Mort1,seasonal="multiplicative",exponential = TRUE, h=5*frequency(Mort1))
summary(hw5)
##
## Forecast method: Holt-Winters' multiplicative method with exponential trend
##
## Model Information:
## Holt-Winters' multiplicative method with exponential trend
##
## Call:
## hw(y = Mort1, h = 5 * frequency(Mort1), seasonal = "multiplicative",
##
## Call:
## exponential = TRUE)
##
## Smoothing parameters:
## alpha = 0.734
## beta = 1e-04
## gamma = 0.0203
##
## Initial states:
## l = 9.5591
## b = 0.9861
## s = 0.869 1.0012 0.9899 1.1666 1.0748 0.9819
## 1.0467 0.9977 0.9929 0.9413 0.9672 0.9709
##
## sigma: 0.2251
##
## AIC AICc BIC
## 3771.528 3772.777 3843.446
##
## Error measures:
## ME RMSE MAE MPE MAPE MASE
## Training set 0.1370831 1.770864 1.382927 -0.9562288 16.8864 0.5065367
## ACF1
## Training set -0.0300085
##
## Forecasts:
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## May 2052 9.782264 6.8834549 12.60040 5.3677617 14.13399
## Jun 2052 10.099140 6.5921866 13.92261 5.1044064 16.26269
## Jul 2052 9.888758 6.0267732 14.13192 4.3573549 17.51170
## Aug 2052 9.865911 5.4981898 14.67966 3.9545495 18.20315
## Sep 2052 10.675645 5.6839994 16.65501 4.1307933 21.22187
## Oct 2052 9.920280 4.9827779 15.96508 3.4470042 20.96677
## Nov 2052 9.353399 4.4727630 15.26101 3.1411755 21.19129
## Dec 2052 8.660648 3.9063144 14.75243 2.5788779 19.92589
## Jan 2053 8.812655 3.7249090 15.08359 2.4162861 21.66174
## Feb 2053 8.587766 3.5690771 15.11285 2.1829168 21.71613
## Mar 2053 8.127915 3.1570834 14.56321 1.9697247 21.22866
## Apr 2053 8.521118 3.1536470 15.75636 1.9438647 22.99767
## May 2053 8.469764 2.9399118 15.77660 1.8504522 23.55921
## Jun 2053 8.744124 2.9705780 16.66560 1.7884982 25.17393
## Jul 2053 8.561969 2.7523095 16.53559 1.6225067 25.56638
## Aug 2053 8.542188 2.6267482 17.14498 1.4888340 26.77771
## Sep 2053 9.243279 2.7701302 18.47016 1.5253978 30.36861
## Oct 2053 8.589262 2.4487391 17.48884 1.3869327 28.35948
## Nov 2053 8.098440 2.2550596 16.17095 1.2499693 27.28364
## Dec 2053 7.498637 2.0108068 15.16605 1.0870146 25.47348
## Jan 2054 7.630249 1.9365036 15.37565 1.0382371 26.18644
## Feb 2054 7.435533 1.8230576 15.35468 1.0048142 26.45863
## Mar 2054 7.037381 1.6630532 14.37769 0.8893759 24.99451
## Apr 2054 7.377828 1.6592474 15.40041 0.8515725 26.40482
## May 2054 7.333364 1.5817883 15.43269 0.8033472 26.82172
## Jun 2054 7.570913 1.5648897 16.14796 0.7989978 27.80697
## Jul 2054 7.413198 1.4725698 15.66391 0.7355094 27.28017
## Aug 2054 7.396071 1.4309254 15.45370 0.7235557 27.72251
## Sep 2054 8.003096 1.4735950 16.93730 0.7414531 30.60460
## Oct 2054 7.436829 1.3390253 15.92013 0.6989787 29.00800
## Nov 2054 7.011862 1.2177025 15.06192 0.6347474 28.34551
## Dec 2054 6.492535 1.0775737 13.77293 0.5636204 25.75291
## Jan 2055 6.606488 1.0863485 14.63887 0.5264507 27.37791
## Feb 2055 6.437898 0.9899155 14.13247 0.4981759 27.06357
## Mar 2055 6.093166 0.9051108 13.48336 0.4389459 25.80990
## Apr 2055 6.387935 0.9239169 14.16951 0.4484036 28.12826
## May 2055 6.349437 0.8798165 13.92125 0.4141422 28.27622
## Jun 2055 6.555113 0.8780489 14.55306 0.4129561 28.69613
## Jul 2055 6.418559 0.8418761 14.10403 0.4100251 28.42011
## Aug 2055 6.403730 0.8002065 14.19049 0.3719546 29.37558
## Sep 2055 6.929309 0.8468131 15.52278 0.3708811 31.77293
## Oct 2055 6.439019 0.7734333 14.54235 0.3362747 29.26852
## Nov 2055 6.071070 0.6966886 13.56630 0.3119209 27.80356
## Dec 2055 5.621422 0.6258523 12.48144 0.2714903 26.28401
## Jan 2056 5.720087 0.6178842 12.71488 0.2757512 26.63332
## Feb 2056 5.574116 0.5858447 12.30649 0.2574969 25.64532
## Mar 2056 5.275638 0.5420437 11.85018 0.2320336 25.15668
## Apr 2056 5.530857 0.5675995 12.57449 0.2356413 26.99966
## May 2056 5.497524 0.5505646 12.32867 0.2323563 27.06896
## Jun 2056 5.675605 0.5451036 12.67542 0.2226996 28.84138
## Jul 2056 5.557372 0.5088869 12.51005 0.2145685 28.35356
## Aug 2056 5.544532 0.5130357 12.69941 0.2134391 29.52073
## Sep 2056 5.999594 0.5276998 13.67470 0.2185773 31.90816
## Oct 2056 5.575087 0.4786856 12.98000 0.1939394 31.01336
## Nov 2056 5.256507 0.4379496 12.14491 0.1822048 29.14852
## Dec 2056 4.867188 0.3954898 11.38645 0.1568184 25.95751
## Jan 2057 4.952615 0.3935028 11.43968 0.1601437 26.79852
## Feb 2057 4.826229 0.3669196 11.13461 0.1467209 26.71679
## Mar 2057 4.567798 0.3497067 10.76778 0.1384799 25.67349
## Apr 2057 4.788774 0.3496993 11.22615 0.1387660 26.69329
checkresiduals(hw5)
##
## Ljung-Box test
##
## data: Residuals from Holt-Winters' multiplicative method with exponential trend
## Q* = 52.172, df = 8, p-value = 1.559e-08
##
## Model df: 16. Total lags used: 24
The state-space model considers error, trend, and seasonality of the series denoted by (E, T, S). Here we are going to check all the possibility of ETS.
From the observation we can see that:
ssm1=ets(Mort,model = "ANN")
summary(ssm1)
## ETS(A,N,N)
##
## Call:
## ets(y = Mort, model = "ANN")
##
## Smoothing parameters:
## alpha = 0.7365
##
## Initial states:
## l = 11.495
##
## sigma: 1.8425
##
## AIC AICc BIC
## 3789.973 3790.021 3802.665
##
## Training set error measures:
## ME RMSE MAE MPE MAPE MASE
## Training set -0.004666777 1.838854 1.399065 -2.741033 16.90323 0.6641341
## ACF1
## Training set -0.02284784
ssm2=ets(Mort,model = "MNN")
summary(ssm2)
## ETS(M,N,N)
##
## Call:
## ets(y = Mort, model = "MNN")
##
## Smoothing parameters:
## alpha = 0.5226
##
## Initial states:
## l = 10.5622
##
## sigma: 0.2044
##
## AIC AICc BIC
## 3682.655 3682.703 3695.347
##
## Training set error measures:
## ME RMSE MAE MPE MAPE MASE
## Training set -0.004236778 1.895384 1.394516 -3.079152 16.62011 0.6619746
## ACF1
## Training set 0.2188059
ssm3=ets(Mort,model = "AAN")
summary(ssm3)
## ETS(A,A,N)
##
## Call:
## ets(y = Mort, model = "AAN")
##
## Smoothing parameters:
## alpha = 0.7377
## beta = 1e-04
##
## Initial states:
## l = 10.7616
## b = -0.0047
##
## sigma: 1.8466
##
## AIC AICc BIC
## 3794.216 3794.335 3815.368
##
## Training set error measures:
## ME RMSE MAE MPE MAPE MASE
## Training set 0.003842306 1.839292 1.399981 -2.637078 16.90144 0.6645686
## ACF1
## Training set -0.02465578
ssm4=ets(Mort,model = "MAN",damped = TRUE)
summary(ssm4)
## ETS(M,Ad,N)
##
## Call:
## ets(y = Mort, model = "MAN", damped = TRUE)
##
## Smoothing parameters:
## alpha = 0.5196
## beta = 0.0016
## phi = 0.8
##
## Initial states:
## l = 12.402
## b = -1.5934
##
## sigma: 0.205
##
## AIC AICc BIC
## 3686.498 3686.666 3711.881
##
## Training set error measures:
## ME RMSE MAE MPE MAPE MASE
## Training set 0.01278801 1.894084 1.386713 -2.872955 16.51742 0.6582705
## ACF1
## Training set 0.2203053
ssm5=ets(Mort,model = "MAN")
summary(ssm5)
## ETS(M,A,N)
##
## Call:
## ets(y = Mort, model = "MAN")
##
## Smoothing parameters:
## alpha = 0.5396
## beta = 1e-04
##
## Initial states:
## l = 11.398
## b = 0.0882
##
## sigma: 0.2
##
## AIC AICc BIC
## 3682.020 3682.139 3703.172
##
## Training set error measures:
## ME RMSE MAE MPE MAPE MASE
## Training set -0.1618487 1.893448 1.404443 -5.065489 17.01295 0.6666867
## ACF1
## Training set 0.1998776
dlmodels <- c("Model1", "Model2", "Model3", "Model4", "Model5", "Model6", "Model7","Model8","Model9","Model10","Model1")
dlaic <- AIC(model1$model, model2$model, model3$model, model4$model, model5$model, model6$model, model7$model,model8$model,model9$model,model10$model,model11$model)$AIC
dlbic <- BIC(model1$model, model2$model, model3$model, model4$model, model5$model, model6$model, model7$model,model8$model,model9$model,model10$model,model11$model)$BIC
dlMASE <- MASE(model1, model2, model3, model4, model5, model6, model7,model8,model9,model10,model11)$MASE
dlaccuracy <- data.frame(dlmodels, dlMASE, dlaic, dlbic)
colnames(dlaccuracy) <- c("Model", "MASE", "AIC", "BIC")
dlaccuracy
## Model MASE AIC BIC
## 1 Model1 1.1291691 2376.709 2435.881
## 2 Model2 1.1385137 2384.412 2430.903
## 3 Model3 1.1374161 2373.858 2420.350
## 4 Model4 0.8118071 1985.650 2221.444
## 5 Model5 1.1817064 2435.867 2482.359
## 6 Model6 1.1964736 2404.377 2438.190
## 7 Model7 1.1859150 2451.527 2485.339
## 8 Model8 1.2192989 2453.283 2487.096
## 9 Model9 1.1489895 2380.650 2414.463
## 10 Model10 1.1437982 2369.232 2403.044
## 11 Model1 1.1960319 2434.072 2467.884
pmodels <- c("PModel1", "PModel2", "PModel3", "PModel4")
paic <- c(AIC(pmodel1), AIC(pmodel2), AIC(pmodel3), AIC(pmodel4))
## [1] 2404.504
## [1] 2509.014
## [1] 2470.471
## [1] 2449.273
pbic <- c(BIC(pmodel1), BIC(pmodel2), BIC(pmodel3), BIC(pmodel4))
## [1] 2425.636
## [1] 2530.147
## [1] 2491.604
## [1] 2470.406
pMASE <- MASE(pmodel1, pmodel2, pmodel3, pmodel4)$MASE
paccuracy <- data.frame(pmodels, pMASE, paic, pbic)
colnames(paccuracy) <- c("Model", "MASE", "AIC", "BIC")
paccuracy
## Model MASE AIC BIC
## 1 PModel1 1.182639 2404.504 2425.636
## 2 PModel2 1.294809 2509.014 2530.147
## 3 PModel3 1.239707 2470.471 2491.604
## 4 PModel4 1.222464 2449.273 2470.406
kmodels <- c("Model1", "Model2", "Model3", "Model4")
kaic <- c(AIC(kmodel1), AIC(kmodel2), AIC(kmodel3), AIC(kmodel4))
## [1] 2099.204
## [1] 2067.979
## [1] 2031.724
## [1] 2025.937
kbic <- c(BIC(kmodel1), BIC(kmodel2), BIC(kmodel3), BIC(kmodel4))
## [1] 2116.118
## [1] 2084.893
## [1] 2048.638
## [1] 2042.851
kMASE <- MASE(kmodel1, kmodel2, kmodel3, kmodel4)$MASE
kaccuracy <- data.frame(kmodels, kMASE, kaic, kbic)
colnames(kaccuracy) <- c("Model", "MASE", "AIC", "BIC")
kaccuracy
## Model MASE AIC BIC
## 1 Model1 1.0024611 2099.204 2116.118
## 2 Model2 0.9718873 2067.979 2084.893
## 3 Model3 0.9255483 2031.724 2048.638
## 4 Model4 0.9221834 2025.937 2042.851
armodels <- c("armodel1", "armodel2", "armodel3", "armodel4", "armodel5", "armodel6", "armodel7","armodel8","armodel9","armodel10","armodel11")
araic <- AIC(armodel1$model, armodel2$model, armodel3$model, armodel4$model, armodel5$model, armodel6$model, armodel7$model,armodel8$model,armodel9$model,armodel10$model,armodel11$model)$AIC
arbic <- BIC(armodel1$model, armodel2$model, armodel3$model, armodel4$model, armodel5$model, armodel6$model, armodel7$model,armodel8$model,armodel9$model,armodel10$model,armodel11$model)$BIC
arMASE <- MASE(armodel1, armodel2, armodel3, armodel4, armodel5, armodel6, armodel7,armodel8,armodel9,armodel10,armodel11)$MASE
araccuracy <- data.frame(armodels, arMASE, araic, arbic)
colnames(araccuracy) <- c("armodel", "MASE", "AIC", "BIC")
araccuracy
## armodel MASE AIC BIC
## 1 armodel1 0.8754705 1979.376 2042.685
## 2 armodel2 0.8757380 1979.038 2033.906
## 3 armodel3 0.8764530 1976.627 2031.494
## 4 armodel4 0.8782479 1976.295 2031.163
## 5 armodel5 0.8833953 1990.090 2044.957
## 6 armodel6 0.8904077 1984.126 2030.553
## 7 armodel7 0.8857359 1990.328 2036.755
## 8 armodel8 0.8911127 1991.364 2037.791
## 9 armodel9 0.8794090 1976.258 2022.685
## 10 armodel10 0.8771338 1973.203 2019.629
## 11 armodel11 0.8859041 1990.559 2036.985
dynlmodels <- c("dynlmodel1", "dynlmodel2", "dynlmodel3", "dynlmodel4", "dynlmodel5", "dynlmodel6", "dynlmodel7","dynlmodel8","dynlmodel9","dynlmodel10")
dyaic <- AIC(dynlmodel1, dynlmodel2, dynlmodel3, dynlmodel4, dynlmodel5, dynlmodel6, dynlmodel7,dynlmodel8,dynlmodel9,dynlmodel10)$AIC
dybic <- BIC(dynlmodel1, dynlmodel2, dynlmodel3, dynlmodel4, dynlmodel5, dynlmodel6, dynlmodel7,dynlmodel8,dynlmodel9,dynlmodel10)$BIC
dyMASE <- c( accuracy(dynlmodel1)[6],accuracy(dynlmodel2)[6], accuracy(dynlmodel3)[6], accuracy(dynlmodel4)[6], accuracy(dynlmodel5)[6], accuracy(dynlmodel6)[6], accuracy(dynlmodel7)[6],accuracy(dynlmodel8)[6],accuracy(dynlmodel9)[6],accuracy(dynlmodel10)[6])
dyaccuracy <- data.frame(dynlmodels, dyMASE, dyaic, dybic)
colnames(dyaccuracy) <- c("dynlmodel", "MASE", "AIC", "BIC")
dyaccuracy
## dynlmodel MASE AIC BIC
## 1 dynlmodel1 0.9092406 2022.744 2052.343
## 2 dynlmodel2 0.8438473 2045.836 2291.089
## 3 dynlmodel3 0.8443752 2047.558 2297.040
## 4 dynlmodel4 0.8441037 2044.039 2285.065
## 5 dynlmodel5 0.8453048 2044.840 2285.865
## 6 dynlmodel6 0.8459142 2045.250 2286.276
## 7 dynlmodel7 0.8475035 2046.990 2288.015
## 8 dynlmodel8 0.8459396 2043.250 2280.047
## 9 dynlmodel9 0.8459198 2043.251 2280.047
## 10 dynlmodel10 0.8475631 2044.998 2281.795
HWmodel=c("HW1","HW2","HW3","HW4","HW5")
HWAIC=AIC(hw1$model,hw2$model,hw3$model,hw4$model,hw5$model)
HWBIC=BIC(hw1$model,hw2$model,hw3$model,hw4$model,hw5$model)
HWMASE=c(accuracy(hw1)[6],accuracy(hw2)[6],accuracy(hw3)[6],
accuracy(hw4)[6],accuracy(hw5)[6])
hwaccuracy <- data.frame(HWmodel, HWMASE, HWAIC, HWBIC)
colnames(hwaccuracy) <- c("HWmodel", "MASE", "AIC", "BIC")
hwaccuracy
## HWmodel MASE AIC BIC NA NA
## hw1$model HW1 0.5079491 17 3803.535 17 3875.453
## hw2$model HW2 0.5096827 17 3766.418 17 3838.336
## hw3$model HW3 0.5085548 18 3807.213 18 3883.362
## hw4$model HW4 0.5054180 18 3760.799 18 3836.948
## hw5$model HW5 0.5065367 17 3771.528 17 3843.446
ssmodels <- c("ssm1", "ssm2", "ssm3", "ssm4","ssm5")
ssaic <- c(AIC(ssm1), AIC(ssm2), AIC(ssm3), AIC(ssm4),AIC(ssm5))
ssbic <- c(BIC(ssm1), BIC(ssm2), BIC(ssm3), BIC(ssm4),BIC(ssm5))
ssMASE <- c(accuracy(ssm1)[6], accuracy(ssm2)[6], accuracy(ssm3)[6], accuracy(ssm4)[6],accuracy(ssm5)[6])
ssaccuracy <- data.frame(ssmodels, ssMASE, ssaic, ssbic)
colnames(ssaccuracy) <- c("Model", "MASE", "AIC", "BIC")
ssaccuracy
## Model MASE AIC BIC
## 1 ssm1 0.6641341 3789.973 3802.665
## 2 ssm2 0.6619746 3682.655 3695.347
## 3 ssm3 0.6645686 3794.216 3815.368
## 4 ssm4 0.6582705 3686.498 3711.881
## 5 ssm5 0.6666867 3682.020 3703.172
From the above comparision we can see that best models for every method DLM, ARDL, polyck, koyck, dynamic, exponential smoothing and state-space model are plotted.
Forecasting of next 4 week is done for the selected models.
dlmfore=forecast(model4, x= as.vector(Mort), h = 4)$forecast
polfore = forecast(pmodel1, x= as.vector(Mort), h = 4)$forecast
koyfore = forecast(kmodel4, x= as.vector(Mort), h = 4)$forecast
arfore = forecast(armodel1, x= as.vector(Mort), h = 4)$forecast
hwforecast=hw4$mean
etsforecast = as.vector(forecast(ssm4,h=4)$mean)
ets = c(Mort,etsforecast)
hw=c(Mort,hwforecast)
dlm = c(Mort,dlmfore)
poly=c(Mort,polfore)
koyn=c(Mort,koyfore)
ardlm=c(Mort,arfore)
Dataforecast = ts.intersect(
ts(dlm,start=2010,frequency = 52),
ts(poly,start=2010,frequency = 52),
ts(koyn,start=2010,frequency = 52),
ts(ardlm,start=2010,frequency = 52),
ts(hw,start=2010,frequency = 52),
ts(ets,start=2010,frequency = 52))
ts.plot(Dataforecast,xlim=c(2019.75,2019.85),
plot.type = c("single"),gpars=list(col=c("red","blue","gray","green","black","brown")),main = "Forecasting of next 4 Weeks of Mortality")
legend("topleft", col=c("red","blue","gray","green","black","brown"), lty=1, cex=.65,c("DLM","Poly","koyn","ardlm","HW","ETS"))
Data focuses on one species (of the 81) and contains 5 time series FFD,rainfall (rain), temperature (temp), radiation level (rad), and relative humidity (RH) from 1984 – 2014 (31 years).
Task is to give best FFD 4 years ahead forecasts for the FFD series. Methods used are DLM, ARDL, polyck, koyck and dynamic.
#Data loading
FFD<- read_csv("/Users/shubhamchougule/Downloads/FFD .csv")
## Parsed with column specification:
## cols(
## Year = col_double(),
## Temperature = col_double(),
## Rainfall = col_double(),
## Radiation = col_double(),
## RelHumidity = col_double(),
## FFD = col_double()
## )
#class and head of dataset
head(FFD)
## # A tibble: 6 x 6
## Year Temperature Rainfall Radiation RelHumidity FFD
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 1984 18.7 2.49 14.9 93.9 310
## 2 1985 19.3 2.48 14.7 94.9 322
## 3 1986 18.6 2.42 14.5 94.1 306
## 4 1987 19.1 2.32 14.7 94.5 306
## 5 1988 20.4 2.47 14.7 94.1 306
## 6 1989 19.6 2.74 14.8 96.1 293
class(FFD)
## [1] "spec_tbl_df" "tbl_df" "tbl" "data.frame"
Converting data into timeseries.
Temprature<-ts(FFD$Temperature,start = 1984,frequency = 1)
Rain<-ts(FFD$Rainfall,start = 1984,frequency = 1)
Rad<-ts(FFD$Radiation,start = 1984,frequency = 1)
Humid<-ts(FFD$RelHumidity,start = 1984,frequency = 1)
Ffd<-ts(FFD$FFD,start = 1984,frequency = 1)
plot(Temprature,type="o",ylab="Yearly Temprature",xlab="YEAR",main="Temprature")
abline(reg=lm(Temprature~time(Temprature)))
acf(Temprature)
Pacf(Temprature)
adf.test(Temprature)
##
## Augmented Dickey-Fuller Test
##
## data: Temprature
## Dickey-Fuller = -3.3034, Lag order = 3, p-value = 0.08928
## alternative hypothesis: stationary
summary(Temprature)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 18.43 19.19 19.69 19.60 19.96 20.83
plot(Rain,type="o",ylab="Yearly Rainfall",xlab="YEAR",main="Rainfall")
abline(reg=lm(Rain~time(Rain)))
acf(Rain)
Pacf(Rain)
adf.test(Rain)
##
## Augmented Dickey-Fuller Test
##
## data: Rain
## Dickey-Fuller = -2.3024, Lag order = 3, p-value = 0.4563
## alternative hypothesis: stationary
summary(Rain)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 1.403 2.210 2.421 2.370 2.628 2.886
plot(Rad,type="o",ylab="Yearly Radiations",xlab="YEAR",main="Radiation")
abline(reg=lm(Rad~time(Rad)))
acf(Rad)
Pacf(Rad)
adf.test(Rad)
##
## Augmented Dickey-Fuller Test
##
## data: Rad
## Dickey-Fuller = -2.6949, Lag order = 3, p-value = 0.3052
## alternative hypothesis: stationary
summary(Rad)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 13.40 14.41 14.64 14.59 14.78 15.41
plot(Humid,type="o",ylab="Yearly Humidity",xlab="YEAR",main="Humidity")
abline(reg=lm(Humid~time(Humid)))
acf(Humid)
Pacf(Humid)
adf.test(Humid)
##
## Augmented Dickey-Fuller Test
##
## data: Humid
## Dickey-Fuller = -2.7992, Lag order = 3, p-value = 0.2651
## alternative hypothesis: stationary
summary(Humid)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 93.16 94.09 94.47 94.54 94.91 96.23
plot(Ffd,type="o",ylab="Yearly FFD",xlab="YEAR",main="FFD")
abline(reg=lm(Ffd~time(Ffd)))
acf(Ffd)
Pacf(Ffd)
adf.test(Ffd)
##
## Augmented Dickey-Fuller Test
##
## data: Ffd
## Dickey-Fuller = -2.3272, Lag order = 3, p-value = 0.4468
## alternative hypothesis: stationary
summary(Ffd)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 293.0 305.5 310.0 311.8 322.0 329.0
From the above observation we can see that series are non-stationary. To make it stationary we need to apply transformation.
TempratureL=BoxCox.lambda(Temprature)
RainL=BoxCox.lambda(Rain)
RadL=BoxCox.lambda(Rad)
HumidL=BoxCox.lambda(Humid)
FfdL=BoxCox.lambda(Ffd)
cbind(TempratureL,RainL,RadL,HumidL,FfdL)
## TempratureL RainL RadL HumidL FfdL
## [1,] 0.3670229 1.999924 1.999924 -0.9999242 1.999924
We see that Rainfall, Radiation, Humidity and FFD has values more than 1 or negative hence need transformation and also apply differencing.
#Need to apply transformation to Rain,Rad,Humid and Ffd
TempratureD =diff(Temprature,differences=3)
plot(TempratureD,type="o",ylab="Yearly Temprature",xlab="YEAR",main="Temprature")
RainT=BoxCox(Rain,lambda = RainL)
plot(RainT,type="o",ylab="Yearly Rainfall",xlab="YEAR",main="Rainfall")
RainTD =diff(RainT,differences=3)
plot(RainTD,type="o",ylab="Yearly Rainfall",xlab="YEAR",main="Rainfall")
RadT=BoxCox(Rad,lambda = RadL)
plot(RadT,type="o",ylab="Yearly Radiations",xlab="YEAR",main="Radiation")
RadTD =diff(RadT,differences=3)
plot(RadTD,type="o",ylab="Yearly Radiations",xlab="YEAR",main="Radiation")
HumidT=BoxCox(Humid,lambda = HumidL)
plot(HumidT,type="o",ylab="Yearly Humidity",xlab="YEAR",main="Humidity")
HumidTD =diff(HumidT,differences=3)
plot(HumidTD,type="o",ylab="Yearly Humidity",xlab="YEAR",main="Humidity")
FfdT=BoxCox(Ffd,lambda = FfdL)
plot(FfdT,type="o",ylab="Yearly FFD",xlab="YEAR",main="FFD")
FfdTD =diff(FfdT,differences=3)
plot(FfdTD,type="o",ylab="Yearly FFD",xlab="YEAR",main="FFD")
We see that all the series looks good after applying differencing. To check the stationarity we use adf test.
adf.test(TempratureD)
##
## Augmented Dickey-Fuller Test
##
## data: TempratureD
## Dickey-Fuller = -4.0851, Lag order = 3, p-value = 0.01979
## alternative hypothesis: stationary
adf.test(RainTD)
##
## Augmented Dickey-Fuller Test
##
## data: RainTD
## Dickey-Fuller = -6.4196, Lag order = 3, p-value = 0.01
## alternative hypothesis: stationary
adf.test(RadTD)
##
## Augmented Dickey-Fuller Test
##
## data: RadTD
## Dickey-Fuller = -4.0888, Lag order = 3, p-value = 0.01966
## alternative hypothesis: stationary
adf.test(HumidTD)
##
## Augmented Dickey-Fuller Test
##
## data: HumidTD
## Dickey-Fuller = -4.6446, Lag order = 3, p-value = 0.01
## alternative hypothesis: stationary
adf.test(FfdTD)
##
## Augmented Dickey-Fuller Test
##
## data: FfdTD
## Dickey-Fuller = -8.3214, Lag order = 3, p-value = 0.01
## alternative hypothesis: stationary
From the adf test it is clear that all the series are stationary.
For decomposition we use STL to see the trend, seasonality in the series.
decompose <- function(x){
stldec=mstl(x, t.window=15, s.window="periodic", robust=TRUE)
plot(stldec)
}
decompose(TempratureD)
decompose(RainTD)
decompose(RadTD)
decompose(HumidTD)
decompose(FfdTD)
From the decomposition we see that trend is observed in all series except radiation.
FFD have the highest correlation with rainfall.
cor(FFD[,2:6])
## Temperature Rainfall Radiation RelHumidity FFD
## Temperature 1.00000000 -0.3915072 0.51935760 0.09350562 -0.05387003
## Rainfall -0.39150719 1.0000000 -0.58131610 0.33846101 -0.22125196
## Radiation 0.51935760 -0.5813161 1.00000000 -0.05520965 0.13759174
## RelHumidity 0.09350562 0.3384610 -0.05520965 1.00000000 -0.22660091
## FFD -0.05387003 -0.2212520 0.13759174 -0.22660091 1.00000000
#DLM model
#selection of "q" value on basis of AIC and BIC for fitting of DLM model
for(i in 1:10){
model1 = dlm( x = as.vector(Temprature) , y = as.vector(Ffd), q = i )
cat("q = ", i, "AIC = ", AIC(model1$model), "BIC = ", BIC(model1$model),"\n")
}
## q = 1 AIC = 237.5506 BIC = 243.1553
## q = 2 AIC = 231.9415 BIC = 238.778
## q = 3 AIC = 227.0429 BIC = 235.0361
## q = 4 AIC = 221.3675 BIC = 230.4383
## q = 5 AIC = 216.3322 BIC = 226.397
## q = 6 AIC = 204.9194 BIC = 215.8892
## q = 7 AIC = 197.5201 BIC = 209.3006
## q = 8 AIC = 184.1658 BIC = 196.6562
## q = 9 AIC = 177.7726 BIC = 190.8651
## q = 10 AIC = 170.8439 BIC = 184.4227
tmodel1<- dlm(x = as.vector(Temprature) , y = as.vector(Ffd), q = 10)
summary(tmodel1)
##
## Call:
## lm(formula = model.formula, data = design)
##
## Residuals:
## Min 1Q Median 3Q Max
## -15.2573 -6.1028 0.7676 6.0231 12.1405
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 676.7850 177.0553 3.822 0.00407 **
## x.t 4.2181 5.7446 0.734 0.48147
## x.1 -1.1130 6.1495 -0.181 0.86039
## x.2 -3.2529 5.6091 -0.580 0.57619
## x.3 0.6511 5.5122 0.118 0.90857
## x.4 4.3362 5.4686 0.793 0.44822
## x.5 -2.8434 5.5249 -0.515 0.61919
## x.6 -7.8096 5.4542 -1.432 0.18598
## x.7 5.1447 5.1412 1.001 0.34313
## x.8 -8.4599 5.2283 -1.618 0.14010
## x.9 -3.6416 5.5408 -0.657 0.52748
## x.10 -6.0333 5.4143 -1.114 0.29401
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 11.63 on 9 degrees of freedom
## Multiple R-squared: 0.5055, Adjusted R-squared: -0.09888
## F-statistic: 0.8364 on 11 and 9 DF, p-value: 0.6165
##
## AIC and BIC values for the model:
## AIC BIC
## 1 170.8439 184.4227
vif(tmodel1$model)
## x.t x.1 x.2 x.3 x.4 x.5 x.6 x.7
## 1.882817 1.925625 1.781877 1.739787 1.730817 1.757883 1.682573 1.517274
## x.8 x.9 x.10
## 1.373584 1.508769 1.414382
tmodel2 = polyDlm(x = as.vector(Temprature) , y = as.vector(Ffd) , q = 10 , k = 2 , show.beta = TRUE)
## Estimates and t-tests for beta coefficients:
## Estimate Std. Error t value P(>|t|)
## beta.0 1.1300 2.33 0.485 0.6370
## beta.1 0.8120 1.55 0.522 0.6120
## beta.2 0.4260 1.11 0.383 0.7090
## beta.3 -0.0247 1.03 -0.024 0.9810
## beta.4 -0.5400 1.12 -0.480 0.6410
## beta.5 -1.1200 1.22 -0.915 0.3800
## beta.6 -1.7600 1.27 -1.390 0.1930
## beta.7 -2.4700 1.31 -1.890 0.0859
## beta.8 -3.2500 1.46 -2.220 0.0487
## beta.9 -4.0800 1.86 -2.190 0.0508
## beta.10 -4.9900 2.55 -1.950 0.0765
summary(tmodel2)
##
## Call:
## "Y ~ (Intercept) + X.t"
##
## Residuals:
## Min 1Q Median 3Q Max
## -20.255 -6.869 1.408 7.403 15.024
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 620.15980 154.98624 4.001 0.000924 ***
## z.t0 1.13278 2.33331 0.485 0.633533
## z.t1 -0.28897 1.06870 -0.270 0.790111
## z.t2 -0.03228 0.09924 -0.325 0.748925
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 10.45 on 17 degrees of freedom
## Multiple R-squared: 0.2449, Adjusted R-squared: 0.1117
## F-statistic: 1.838 on 3 and 17 DF, p-value: 0.1785
checkresiduals(tmodel2$model)
##
## Breusch-Godfrey test for serial correlation of order up to 7
##
## data: Residuals
## LM test = 6.2597, df = 7, p-value = 0.5098
vif(tmodel2$model)
## z.t0 z.t1 z.t2
## 11.37663 55.54151 26.28493
tmodel3 = koyckDlm(x = as.vector(Temprature) , y = as.vector(Ffd))
summary(tmodel3,diagnostics=TRUE)
##
## Call:
## "Y ~ (Intercept) + Y.1 + X.t"
##
## Residuals:
## Min 1Q Median 3Q Max
## -22.404 -10.511 1.279 9.314 19.283
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 539.4292 203.3384 2.653 0.0132 *
## Y.1 -0.2009 0.2301 -0.873 0.3903
## X.t -8.3987 8.1530 -1.030 0.3121
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 12.65 on 27 degrees of freedom
## Multiple R-Squared: -0.117, Adjusted R-squared: -0.1998
## Wald test: 0.6315 on 2 and 27 DF, p-value: 0.5395
##
## Diagnostic tests:
## df1 df2 statistic p-value
## Weak instruments 1 27 7.3858184 0.01133857
## Wu-Hausman 1 26 0.9984189 0.32690267
##
## alpha beta phi
## Geometric coefficients: 449.1922 -8.39867 -0.2008874
checkresiduals(tmodel3$model)
vif(tmodel3$model)
## Y.1 X.t
## 1.269024 1.269024
#Checking p and q vales on basis fo AIC and BIC
for (i in 1:5){
for(j in 1:5){
model4 = ardlDlm(x = as.vector(Temprature) , y = as.vector(Ffd), p = i , q = j )
cat("p = ", i, "q = ", j, "AIC = ", AIC(model4$model), "BIC = ", BIC(model4$model),"\n")
}
}
## p = 1 q = 1 AIC = 239.2912 BIC = 246.2972
## p = 1 q = 2 AIC = 232.1732 BIC = 240.377
## p = 1 q = 3 AIC = 224.8471 BIC = 234.1725
## p = 1 q = 4 AIC = 214.1608 BIC = 224.5275
## p = 1 q = 5 AIC = 208.9515 BIC = 220.2744
## p = 2 q = 1 AIC = 233.8023 BIC = 242.006
## p = 2 q = 2 AIC = 233.8822 BIC = 243.4533
## p = 2 q = 3 AIC = 226.4394 BIC = 237.097
## p = 2 q = 4 AIC = 216.1331 BIC = 227.7956
## p = 2 q = 5 AIC = 210.9272 BIC = 223.5082
## p = 3 q = 1 AIC = 228.9066 BIC = 238.232
## p = 3 q = 2 AIC = 228.9529 BIC = 239.6106
## p = 3 q = 3 AIC = 228.2994 BIC = 240.2892
## p = 3 q = 4 AIC = 218.111 BIC = 231.0693
## p = 3 q = 5 AIC = 212.9123 BIC = 226.7513
## p = 4 q = 1 AIC = 223.1523 BIC = 233.519
## p = 4 q = 2 AIC = 223.1783 BIC = 234.8409
## p = 4 q = 3 AIC = 222.318 BIC = 235.2764
## p = 4 q = 4 AIC = 219.5892 BIC = 233.8434
## p = 4 q = 5 AIC = 214.5814 BIC = 229.6786
## p = 5 q = 1 AIC = 218.0365 BIC = 229.3593
## p = 5 q = 2 AIC = 218.2282 BIC = 230.8091
## p = 5 q = 3 AIC = 217.4182 BIC = 231.2573
## p = 5 q = 4 AIC = 214.3612 BIC = 229.4584
## p = 5 q = 5 AIC = 216.3587 BIC = 232.7139
tmodel4 = ardlDlm(x = as.vector(Temprature) , y = as.vector(Ffd), p = 1 , q = 5 )
summary(tmodel4)
##
## Time series regression with "ts" data:
## Start = 6, End = 31
##
## Call:
## dynlm(formula = as.formula(model.text), data = data, start = 1)
##
## Residuals:
## Min 1Q Median 3Q Max
## -17.558 -8.392 2.557 6.333 16.766
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 251.407572 154.184874 1.631 0.1204
## X.t 2.812604 5.075321 0.554 0.5863
## X.1 -2.010772 4.767891 -0.422 0.6782
## Y.1 0.007879 0.236666 0.033 0.9738
## Y.2 0.451474 0.247798 1.822 0.0851 .
## Y.3 0.183243 0.237717 0.771 0.4508
## Y.4 -0.482604 0.276065 -1.748 0.0975 .
## Y.5 -0.014061 0.306140 -0.046 0.9639
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 11.44 on 18 degrees of freedom
## Multiple R-squared: 0.3561, Adjusted R-squared: 0.1057
## F-statistic: 1.422 on 7 and 18 DF, p-value: 0.2568
checkresiduals(tmodel4$model)
##
## Breusch-Godfrey test for serial correlation of order up to 11
##
## data: Residuals
## LM test = 17.149, df = 11, p-value = 0.1035
vif(tmodel4$model)
## X.t L(X.t, 1) L(y.t, 1) L(y.t, 2) L(y.t, 3) L(y.t, 4) L(y.t, 5)
## 1.920998 1.585346 1.565702 1.710155 1.514202 1.921000 2.349353
#selection of "q" value on basis of AIC and BIC for fitting of DLM model
for(i in 1:10){
model1 = dlm( x = as.vector(Rain) , y = as.vector(Ffd), q = i )
cat("q = ", i, "AIC = ", AIC(model1$model), "BIC = ", BIC(model1$model),"\n")
}
## q = 1 AIC = 236.0701 BIC = 241.6749
## q = 2 AIC = 227.892 BIC = 234.7284
## q = 3 AIC = 220.7923 BIC = 228.7855
## q = 4 AIC = 215.4913 BIC = 224.5622
## q = 5 AIC = 210.6108 BIC = 220.6755
## q = 6 AIC = 202.8934 BIC = 213.8633
## q = 7 AIC = 194.4994 BIC = 206.2799
## q = 8 AIC = 183.4408 BIC = 195.9313
## q = 9 AIC = 176.4695 BIC = 189.562
## q = 10 AIC = 159.5287 BIC = 173.1074
rmodel1<- dlm(x = as.vector(Rain) , y = as.vector(Ffd), q = 10)
summary(rmodel1)
##
## Call:
## lm(formula = model.formula, data = design)
##
## Residuals:
## Min 1Q Median 3Q Max
## -9.111 -4.963 2.345 4.420 9.723
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 300.5030 36.1662 8.309 1.63e-05 ***
## x.t 0.3192 5.4279 0.059 0.9544
## x.1 -15.5139 4.9690 -3.122 0.0123 *
## x.2 13.8425 5.1287 2.699 0.0244 *
## x.3 -11.7657 5.0646 -2.323 0.0453 *
## x.4 5.8327 5.6224 1.037 0.3266
## x.5 -4.7269 5.5761 -0.848 0.4186
## x.6 0.6737 5.4036 0.125 0.9035
## x.7 -7.4183 5.9759 -1.241 0.2458
## x.8 4.7096 5.7053 0.825 0.4304
## x.9 3.4915 6.0550 0.577 0.5783
## x.10 14.9904 6.3404 2.364 0.0423 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 8.881 on 9 degrees of freedom
## Multiple R-squared: 0.7115, Adjusted R-squared: 0.3589
## F-statistic: 2.018 on 11 and 9 DF, p-value: 0.1507
##
## AIC and BIC values for the model:
## AIC BIC
## 1 159.5287 173.1074
vif(rmodel1$model)
## x.t x.1 x.2 x.3 x.4 x.5 x.6 x.7
## 1.242349 1.147054 1.282021 1.257098 1.420090 1.381663 1.279639 1.407959
## x.8 x.9 x.10
## 1.274726 1.277607 1.399164
rmodel2 = polyDlm(x = as.vector(Rain) , y = as.vector(Ffd) , q = 10 , k = 2 ,show.beta = TRUE)
## Estimates and t-tests for beta coefficients:
## Estimate Std. Error t value P(>|t|)
## beta.0 -4.870 4.60 -1.060 0.313
## beta.1 -4.350 3.06 -1.420 0.183
## beta.2 -3.700 2.39 -1.550 0.150
## beta.3 -2.910 2.41 -1.210 0.253
## beta.4 -1.970 2.57 -0.768 0.459
## beta.5 -0.895 2.54 -0.353 0.731
## beta.6 0.322 2.27 0.142 0.890
## beta.7 1.680 1.97 0.853 0.412
## beta.8 3.180 2.28 1.390 0.191
## beta.9 4.820 3.62 1.330 0.210
## beta.10 6.600 5.75 1.150 0.275
summary(rmodel2)
##
## Call:
## "Y ~ (Intercept) + X.t"
##
## Residuals:
## Min 1Q Median 3Q Max
## -24.4369 -5.2292 0.6989 6.8761 20.2704
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 315.9005 42.7527 7.389 1.06e-06 ***
## z.t0 -4.8668 4.6046 -1.057 0.305
## z.t1 0.4423 2.3184 0.191 0.851
## z.t2 0.0704 0.2419 0.291 0.775
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 10.76 on 17 degrees of freedom
## Multiple R-squared: 0.1995, Adjusted R-squared: 0.05829
## F-statistic: 1.413 on 3 and 17 DF, p-value: 0.2735
checkresiduals(rmodel2$model)
##
## Breusch-Godfrey test for serial correlation of order up to 7
##
## data: Residuals
## LM test = 9.9642, df = 7, p-value = 0.1906
vif(rmodel2$model)
## z.t0 z.t1 z.t2
## 8.346588 77.158308 47.720427
rmodel3 = koyckDlm(x = as.vector(Rain) , y = as.vector(Ffd))
summary(rmodel3,diagnostics=TRUE)
##
## Call:
## "Y ~ (Intercept) + Y.1 + X.t"
##
## Residuals:
## Min 1Q Median 3Q Max
## -38.893 -11.648 -1.294 14.025 38.952
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 432.8198 151.1337 2.864 0.008 **
## Y.1 -0.0234 0.3335 -0.070 0.945
## X.t -48.0143 58.5785 -0.820 0.420
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 20 on 27 degrees of freedom
## Multiple R-Squared: -1.792, Adjusted R-squared: -1.999
## Wald test: 0.3763 on 2 and 27 DF, p-value: 0.6899
##
## Diagnostic tests:
## df1 df2 statistic p-value
## Weak instruments 1 27 0.7776697 0.3856384
## Wu-Hausman 1 26 1.5510936 0.2240816
##
## alpha beta phi
## Geometric coefficients: 422.924 -48.01431 -0.02339849
checkresiduals(rmodel3$model)
vif(rmodel3$model)
## Y.1 X.t
## 1.066721 1.066721
#Checking p and q vales on basis fo AIC and BIC
for (i in 1:5){
for(j in 1:5){
model4 = ardlDlm(x = as.vector(Rain) , y = as.vector(Ffd), p = i , q = j )
cat("p = ", i, "q = ", j, "AIC = ", AIC(model4$model), "BIC = ", BIC(model4$model),"\n")
}
}
## p = 1 q = 1 AIC = 237.4664 BIC = 244.4724
## p = 1 q = 2 AIC = 229.8029 BIC = 238.0067
## p = 1 q = 3 AIC = 223.5479 BIC = 232.8734
## p = 1 q = 4 AIC = 208.0121 BIC = 218.3788
## p = 1 q = 5 AIC = 201.1726 BIC = 212.4955
## p = 2 q = 1 AIC = 229.6602 BIC = 237.8639
## p = 2 q = 2 AIC = 227.5462 BIC = 237.1173
## p = 2 q = 3 AIC = 221.8552 BIC = 232.5128
## p = 2 q = 4 AIC = 209.0101 BIC = 220.6726
## p = 2 q = 5 AIC = 202.4954 BIC = 215.0764
## p = 3 q = 1 AIC = 222.7896 BIC = 232.115
## p = 3 q = 2 AIC = 221.0143 BIC = 231.6719
## p = 3 q = 3 AIC = 222.7141 BIC = 234.7039
## p = 3 q = 4 AIC = 210.8068 BIC = 223.7651
## p = 3 q = 5 AIC = 204.0461 BIC = 217.8852
## p = 4 q = 1 AIC = 217.4564 BIC = 227.8231
## p = 4 q = 2 AIC = 215.7074 BIC = 227.3699
## p = 4 q = 3 AIC = 217.3898 BIC = 230.3482
## p = 4 q = 4 AIC = 211.9798 BIC = 226.234
## p = 4 q = 5 AIC = 205.6727 BIC = 220.7698
## p = 5 q = 1 AIC = 212.5999 BIC = 223.9227
## p = 5 q = 2 AIC = 210.8767 BIC = 223.4577
## p = 5 q = 3 AIC = 212.6008 BIC = 226.4399
## p = 5 q = 4 AIC = 207.1404 BIC = 222.2376
## p = 5 q = 5 AIC = 207.6224 BIC = 223.9776
rmodel4 = ardlDlm(x = as.vector(Rain) , y = as.vector(Ffd), p = 1 , q = 5 )
summary(rmodel4)
##
## Time series regression with "ts" data:
## Start = 6, End = 31
##
## Call:
## dynlm(formula = as.formula(model.text), data = data, start = 1)
##
## Residuals:
## Min 1Q Median 3Q Max
## -15.4035 -5.1383 0.7345 4.1100 19.3053
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 564.6571 171.4107 3.294 0.00403 **
## X.t -12.8951 6.0664 -2.126 0.04763 *
## X.1 -9.5973 6.6952 -1.433 0.16887
## Y.1 -0.1387 0.2215 -0.626 0.53916
## Y.2 0.4147 0.1840 2.254 0.03690 *
## Y.3 0.1649 0.1980 0.833 0.41565
## Y.4 -0.7298 0.2249 -3.244 0.00450 **
## Y.5 -0.3454 0.2716 -1.272 0.21968
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 9.85 on 18 degrees of freedom
## Multiple R-squared: 0.5226, Adjusted R-squared: 0.3369
## F-statistic: 2.815 on 7 and 18 DF, p-value: 0.03631
checkresiduals(rmodel4$model)
##
## Breusch-Godfrey test for serial correlation of order up to 11
##
## data: Residuals
## LM test = 15.311, df = 11, p-value = 0.1687
vif(rmodel4$model)
## X.t L(X.t, 1) L(y.t, 1) L(y.t, 2) L(y.t, 3) L(y.t, 4) L(y.t, 5)
## 1.570663 1.911042 1.849801 1.271771 1.416188 1.720255 2.493931
#selection of "q" value on basis of AIC and BIC for fitting of DLM model
for(i in 1:10){
model1 = dlm( x = as.vector(Rad) , y = as.vector(Ffd), q = i )
cat("q = ", i, "AIC = ", AIC(model1$model), "BIC = ", BIC(model1$model),"\n")
}
## q = 1 AIC = 238.2644 BIC = 243.8691
## q = 2 AIC = 231.5493 BIC = 238.3857
## q = 3 AIC = 226.6139 BIC = 234.6072
## q = 4 AIC = 221.5765 BIC = 230.6474
## q = 5 AIC = 212.4087 BIC = 222.4735
## q = 6 AIC = 204.5765 BIC = 215.5464
## q = 7 AIC = 195.3695 BIC = 207.15
## q = 8 AIC = 185.2035 BIC = 197.694
## q = 9 AIC = 170.8262 BIC = 183.9187
## q = 10 AIC = 134.8487 BIC = 148.4275
model1<- dlm(x = as.vector(Rad) , y = as.vector(Ffd), q = 10)
summary(model1)
##
## Call:
## lm(formula = model.formula, data = design)
##
## Residuals:
## Min 1Q Median 3Q Max
## -6.6469 -2.4028 0.3735 1.6333 5.7969
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 736.33179 99.15460 7.426 3.99e-05 ***
## x.t -0.08165 5.96616 -0.014 0.989379
## x.1 17.47280 7.12240 2.453 0.036563 *
## x.2 -7.46471 4.27694 -1.745 0.114883
## x.3 -13.78589 4.08428 -3.375 0.008187 **
## x.4 6.92619 4.27792 1.619 0.139888
## x.5 -12.07987 4.06633 -2.971 0.015684 *
## x.6 7.77051 4.21777 1.842 0.098546 .
## x.7 5.73213 4.13563 1.386 0.199112
## x.8 -12.61493 4.20313 -3.001 0.014924 *
## x.9 7.47535 5.19309 1.439 0.183874
## x.10 -28.58673 5.21824 -5.478 0.000391 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 4.935 on 9 degrees of freedom
## Multiple R-squared: 0.9109, Adjusted R-squared: 0.8021
## F-statistic: 8.367 on 11 and 9 DF, p-value: 0.001773
##
## AIC and BIC values for the model:
## AIC BIC
## 1 134.8487 148.4275
model2 = polyDlm(x = as.vector(Rad) , y = as.vector(Ffd) , q = 10 , k = 2 , show.beta = TRUE)
## Estimates and t-tests for beta coefficients:
## Estimate Std. Error t value P(>|t|)
## beta.0 1.890 3.31 0.571 0.5800
## beta.1 1.010 2.12 0.479 0.6410
## beta.2 0.192 1.47 0.131 0.8990
## beta.3 -0.582 1.38 -0.423 0.6810
## beta.4 -1.310 1.50 -0.870 0.4030
## beta.5 -1.980 1.55 -1.280 0.2270
## beta.6 -2.600 1.46 -1.780 0.1020
## beta.7 -3.180 1.37 -2.310 0.0412
## beta.8 -3.700 1.64 -2.250 0.0459
## beta.9 -4.180 2.50 -1.670 0.1230
## beta.10 -4.600 3.85 -1.190 0.2580
summary(model2)
##
## Call:
## "Y ~ (Intercept) + X.t"
##
## Residuals:
## Min 1Q Median 3Q Max
## -23.051 -3.964 2.555 5.979 18.374
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 589.3348 194.2721 3.034 0.0075 **
## z.t0 1.8875 3.3075 0.571 0.5757
## z.t1 -0.8977 1.5925 -0.564 0.5803
## z.t2 0.0249 0.1612 0.154 0.8791
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 10.35 on 17 degrees of freedom
## Multiple R-squared: 0.2605, Adjusted R-squared: 0.1301
## F-statistic: 1.997 on 3 and 17 DF, p-value: 0.1527
checkresiduals(model2$model)
##
## Breusch-Godfrey test for serial correlation of order up to 7
##
## data: Residuals
## LM test = 8.8103, df = 7, p-value = 0.2666
vif(model2$model)
## z.t0 z.t1 z.t2
## 9.16423 69.99257 40.54527
model3 = koyckDlm(x = as.vector(Rad) , y = as.vector(Ffd))
summary(model3,diagnostics=TRUE)
##
## Call:
## "Y ~ (Intercept) + Y.1 + X.t"
##
## Residuals:
## Min 1Q Median 3Q Max
## -20.3177 -7.7263 0.2059 9.4379 18.2406
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 297.541 165.304 1.800 0.0831 .
## Y.1 -0.118 0.212 -0.557 0.5824
## X.t 3.509 12.595 0.279 0.7827
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 11.76 on 27 degrees of freedom
## Multiple R-Squared: 0.03382, Adjusted R-squared: -0.03775
## Wald test: 0.1555 on 2 and 27 DF, p-value: 0.8567
##
## Diagnostic tests:
## df1 df2 statistic p-value
## Weak instruments 1 27 6.30587988 0.01832201
## Wu-Hausman 1 26 0.01250576 0.91181777
##
## alpha beta phi
## Geometric coefficients: 266.1391 3.50942 -0.1179891
checkresiduals(model3$model)
vif(model3$model)
## Y.1 X.t
## 1.245589 1.245589
#Checking p and q vales on basis fo AIC and BIC
for (i in 1:5){
for(j in 1:5){
model4 = ardlDlm(x = as.vector(Rad) , y = as.vector(Ffd), p = i , q = j )
cat("p = ", i, "q = ", j, "AIC = ", AIC(model4$model), "BIC = ", BIC(model4$model),"\n")
}
}
## p = 1 q = 1 AIC = 239.7969 BIC = 246.8029
## p = 1 q = 2 AIC = 231.9906 BIC = 240.1944
## p = 1 q = 3 AIC = 224.9528 BIC = 234.2782
## p = 1 q = 4 AIC = 212.8182 BIC = 223.1849
## p = 1 q = 5 AIC = 207.439 BIC = 218.7618
## p = 2 q = 1 AIC = 233.0845 BIC = 241.2883
## p = 2 q = 2 AIC = 232.439 BIC = 242.0101
## p = 2 q = 3 AIC = 224.207 BIC = 234.8646
## p = 2 q = 4 AIC = 211.6293 BIC = 223.2919
## p = 2 q = 5 AIC = 206.361 BIC = 218.942
## p = 3 q = 1 AIC = 228.0292 BIC = 237.3546
## p = 3 q = 2 AIC = 227.6194 BIC = 238.2771
## p = 3 q = 3 AIC = 226.0447 BIC = 238.0345
## p = 3 q = 4 AIC = 213.5508 BIC = 226.5091
## p = 3 q = 5 AIC = 208.2714 BIC = 222.1105
## p = 4 q = 1 AIC = 222.9547 BIC = 233.3214
## p = 4 q = 2 AIC = 221.2968 BIC = 232.9593
## p = 4 q = 3 AIC = 219.7407 BIC = 232.6991
## p = 4 q = 4 AIC = 214.6715 BIC = 228.9257
## p = 4 q = 5 AIC = 209.1419 BIC = 224.239
## p = 5 q = 1 AIC = 213.8698 BIC = 225.1927
## p = 5 q = 2 AIC = 211.9758 BIC = 224.5567
## p = 5 q = 3 AIC = 211.9972 BIC = 225.8363
## p = 5 q = 4 AIC = 204.6511 BIC = 219.7483
## p = 5 q = 5 AIC = 206.4543 BIC = 222.8096
model4 = ardlDlm(x = as.vector(Rad) , y = as.vector(Ffd), p = 1 , q = 5 )
summary(model4)
##
## Time series regression with "ts" data:
## Start = 6, End = 31
##
## Call:
## dynlm(formula = as.formula(model.text), data = data, start = 1)
##
## Residuals:
## Min 1Q Median 3Q Max
## -17.529 -8.225 2.369 6.572 16.422
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 266.13514 131.79416 2.019 0.0586 .
## X.t 7.26429 6.85871 1.059 0.3035
## X.1 3.59328 6.97018 0.516 0.6125
## Y.1 -0.09128 0.23272 -0.392 0.6995
## Y.2 0.43121 0.20033 2.152 0.0452 *
## Y.3 0.10807 0.24254 0.446 0.6612
## Y.4 -0.64989 0.28197 -2.305 0.0333 *
## Y.5 -0.15416 0.28714 -0.537 0.5979
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 11.11 on 18 degrees of freedom
## Multiple R-squared: 0.3925, Adjusted R-squared: 0.1562
## F-statistic: 1.661 on 7 and 18 DF, p-value: 0.1819
checkresiduals(model4$model)
##
## Breusch-Godfrey test for serial correlation of order up to 11
##
## data: Residuals
## LM test = 12.61, df = 11, p-value = 0.3196
vif(model4$model)
## X.t L(X.t, 1) L(y.t, 1) L(y.t, 2) L(y.t, 3) L(y.t, 4) L(y.t, 5)
## 1.816130 1.887343 1.604577 1.184705 1.670673 2.124131 2.190626
#HUMIDITY
#selection of "q" value on basis of AIC and BIC for fitting of DLM model
for(i in 1:10){
model1 = dlm( x = as.vector(Humid) , y = as.vector(Ffd), q = i )
cat("q = ", i, "AIC = ", AIC(model1$model), "BIC = ", BIC(model1$model),"\n")
}
## q = 1 AIC = 237.0601 BIC = 242.6649
## q = 2 AIC = 230.2895 BIC = 237.126
## q = 3 AIC = 224.7782 BIC = 232.7714
## q = 4 AIC = 219.9171 BIC = 228.988
## q = 5 AIC = 212.2332 BIC = 222.298
## q = 6 AIC = 205.9846 BIC = 216.9545
## q = 7 AIC = 199.2327 BIC = 211.0132
## q = 8 AIC = 187.0559 BIC = 199.5463
## q = 9 AIC = 177.5658 BIC = 190.6583
## q = 10 AIC = 172.2492 BIC = 185.828
hmodel1<- dlm(x = as.vector(Humid) , y = as.vector(Ffd), q = 10)
summary(hmodel1)
##
## Call:
## lm(formula = model.formula, data = design)
##
## Residuals:
## Min 1Q Median 3Q Max
## -13.196 -7.296 1.857 3.802 15.733
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1953.5997 1450.1455 1.347 0.211
## x.t -4.3427 4.7777 -0.909 0.387
## x.1 -7.1724 4.9955 -1.436 0.185
## x.2 2.6629 4.9442 0.539 0.603
## x.3 -2.0269 4.7975 -0.422 0.683
## x.4 0.3730 4.6862 0.080 0.938
## x.5 3.2934 4.4259 0.744 0.476
## x.6 0.9742 4.1028 0.237 0.818
## x.7 -1.3147 4.0681 -0.323 0.754
## x.8 -2.0399 4.0357 -0.505 0.625
## x.9 -5.8663 4.1183 -1.424 0.188
## x.10 -1.8948 4.2936 -0.441 0.669
##
## Residual standard error: 12.02 on 9 degrees of freedom
## Multiple R-squared: 0.4713, Adjusted R-squared: -0.1749
## F-statistic: 0.7293 on 11 and 9 DF, p-value: 0.694
##
## AIC and BIC values for the model:
## AIC BIC
## 1 172.2492 185.828
hmodel2 = polyDlm(x = as.vector(Humid) , y = as.vector(Ffd) , q = 10 , k = 2 , show.beta = TRUE)
## Estimates and t-tests for beta coefficients:
## Estimate Std. Error t value P(>|t|)
## beta.0 -4.8100 2.20 -2.1800 0.0515
## beta.1 -2.8800 1.59 -1.8200 0.0964
## beta.2 -1.3700 1.30 -1.0500 0.3150
## beta.3 -0.2590 1.28 -0.2030 0.8430
## beta.4 0.4350 1.35 0.3230 0.7530
## beta.5 0.7180 1.39 0.5160 0.6160
## beta.6 0.5900 1.38 0.4280 0.6770
## beta.7 0.0493 1.35 0.0365 0.9720
## beta.8 -0.9030 1.42 -0.6340 0.5390
## beta.9 -2.2700 1.75 -1.3000 0.2220
## beta.10 -4.0400 2.38 -1.7000 0.1180
summary(hmodel2)
##
## Call:
## "Y ~ (Intercept) + X.t"
##
## Residuals:
## Min 1Q Median 3Q Max
## -19.308 -7.705 1.703 9.525 13.306
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1706.61136 1204.92164 1.416 0.1747
## z.t0 -4.81352 2.20413 -2.184 0.0433 *
## z.t1 2.13561 0.96618 2.210 0.0411 *
## z.t2 -0.20585 0.09435 -2.182 0.0435 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 10.4 on 17 degrees of freedom
## Multiple R-squared: 0.2528, Adjusted R-squared: 0.1209
## F-statistic: 1.917 on 3 and 17 DF, p-value: 0.1651
checkresiduals(hmodel2$model)
##
## Breusch-Godfrey test for serial correlation of order up to 7
##
## data: Residuals
## LM test = 5.9961, df = 7, p-value = 0.5402
vif(hmodel2$model)
## z.t0 z.t1 z.t2
## 3.722479 30.423970 21.359926
hmodel3 = koyckDlm(x = as.vector(Humid) , y = as.vector(Ffd))
summary(hmodel3,diagnostics=TRUE)
##
## Call:
## "Y ~ (Intercept) + Y.1 + X.t"
##
## Residuals:
## Min 1Q Median 3Q Max
## -34.9581 -10.6588 0.6521 12.6009 21.9222
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1578.8374 2107.4944 0.749 0.460
## Y.1 -0.1303 0.2345 -0.556 0.583
## X.t -12.9676 22.0575 -0.588 0.561
##
## Residual standard error: 13.94 on 27 degrees of freedom
## Multiple R-Squared: -0.3573, Adjusted R-squared: -0.4579
## Wald test: 0.2559 on 2 and 27 DF, p-value: 0.7761
##
## Diagnostic tests:
## df1 df2 statistic p-value
## Weak instruments 1 27 0.6089990 0.4419532
## Wu-Hausman 1 26 0.2675014 0.6093852
##
## alpha beta phi
## Geometric coefficients: 1396.798 -12.96757 -0.1303262
checkresiduals(hmodel3$model)
vif(hmodel3$model)
## Y.1 X.t
## 1.084896 1.084896
#Checking p and q vales on basis fo AIC and BIC
for (i in 1:5){
for(j in 1:5){
model4 = ardlDlm(x = as.vector(Humid) , y = as.vector(Ffd), p = i , q = j )
cat("p = ", i, "q = ", j, "AIC = ", AIC(model4$model), "BIC = ", BIC(model4$model),"\n")
}
}
## p = 1 q = 1 AIC = 238.5857 BIC = 245.5917
## p = 1 q = 2 AIC = 230.5606 BIC = 238.7643
## p = 1 q = 3 AIC = 221.8807 BIC = 231.2061
## p = 1 q = 4 AIC = 211.5113 BIC = 221.878
## p = 1 q = 5 AIC = 206.1062 BIC = 217.429
## p = 2 q = 1 AIC = 231.7414 BIC = 239.9452
## p = 2 q = 2 AIC = 231.9902 BIC = 241.5613
## p = 2 q = 3 AIC = 223.2643 BIC = 233.922
## p = 2 q = 4 AIC = 212.9183 BIC = 224.5809
## p = 2 q = 5 AIC = 206.9438 BIC = 219.5247
## p = 3 q = 1 AIC = 226.4844 BIC = 235.8098
## p = 3 q = 2 AIC = 226.8153 BIC = 237.4729
## p = 3 q = 3 AIC = 224.5585 BIC = 236.5483
## p = 3 q = 4 AIC = 214.4635 BIC = 227.4218
## p = 3 q = 5 AIC = 208.1743 BIC = 222.0134
## p = 4 q = 1 AIC = 221.5074 BIC = 231.8741
## p = 4 q = 2 AIC = 221.4308 BIC = 233.0933
## p = 4 q = 3 AIC = 219.0246 BIC = 231.983
## p = 4 q = 4 AIC = 216.3559 BIC = 230.6101
## p = 4 q = 5 AIC = 210.1692 BIC = 225.2664
## p = 5 q = 1 AIC = 213.3737 BIC = 224.6966
## p = 5 q = 2 AIC = 214.1519 BIC = 226.7328
## p = 5 q = 3 AIC = 209.813 BIC = 223.6521
## p = 5 q = 4 AIC = 206.7858 BIC = 221.8829
## p = 5 q = 5 AIC = 208.052 BIC = 224.4073
hmodel4 = ardlDlm(x = as.vector(Humid) , y = as.vector(Ffd), p = 1 , q = 5 )
summary(hmodel4)
##
## Time series regression with "ts" data:
## Start = 6, End = 31
##
## Call:
## dynlm(formula = as.formula(model.text), data = data, start = 1)
##
## Residuals:
## Min 1Q Median 3Q Max
## -17.4126 -5.0250 0.8542 7.8752 13.2115
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 619.45561 359.56112 1.723 0.1021
## X.t -4.23934 2.68003 -1.582 0.1311
## X.1 0.11576 2.78944 0.041 0.9674
## Y.1 -0.04990 0.23061 -0.216 0.8311
## Y.2 0.41070 0.19665 2.088 0.0512 .
## Y.3 0.26669 0.21937 1.216 0.2398
## Y.4 -0.39968 0.21716 -1.840 0.0822 .
## Y.5 0.03854 0.23223 0.166 0.8700
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 10.83 on 18 degrees of freedom
## Multiple R-squared: 0.4228, Adjusted R-squared: 0.1984
## F-statistic: 1.884 on 7 and 18 DF, p-value: 0.132
checkresiduals(hmodel4$model)
##
## Breusch-Godfrey test for serial correlation of order up to 11
##
## data: Residuals
## LM test = 12.953, df = 11, p-value = 0.2964
vif(hmodel4$model)
## X.t L(X.t, 1) L(y.t, 1) L(y.t, 2) L(y.t, 3) L(y.t, 4) L(y.t, 5)
## 1.073701 1.170699 1.658542 1.201622 1.438656 1.326154 1.508301
dynlm1 =dynlm(Ffd ~ Temprature)
summary(dynlm1)
##
## Time series regression with "ts" data:
## Start = 1984, End = 2014
##
## Call:
## dynlm(formula = Ffd ~ Temprature)
##
## Residuals:
## Min 1Q Median 3Q Max
## -19.149 -6.550 -1.746 9.770 17.422
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 330.2933 63.5564 5.197 1.47e-05 ***
## Temprature -0.9417 3.2413 -0.291 0.773
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 11.54 on 29 degrees of freedom
## Multiple R-squared: 0.002902, Adjusted R-squared: -0.03148
## F-statistic: 0.0844 on 1 and 29 DF, p-value: 0.7735
checkresiduals(dynlm1)
##
## Breusch-Godfrey test for serial correlation of order up to 6
##
## data: Residuals
## LM test = 13.451, df = 6, p-value = 0.03641
dynlm2 =dynlm(Ffd ~ Temprature+L(Ffd , k = 1 ))
summary(dynlm2)
##
## Time series regression with "ts" data:
## Start = 1985, End = 2014
##
## Call:
## dynlm(formula = Ffd ~ Temprature + L(Ffd, k = 1))
##
## Residuals:
## Min 1Q Median 3Q Max
## -19.6323 -7.3177 -0.1908 10.5933 17.8971
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 378.9706 103.1325 3.675 0.00104 **
## Temprature -1.6231 3.5465 -0.458 0.65085
## L(Ffd, k = 1) -0.1129 0.1972 -0.572 0.57179
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 11.87 on 27 degrees of freedom
## Multiple R-squared: 0.01598, Adjusted R-squared: -0.05691
## F-statistic: 0.2193 on 2 and 27 DF, p-value: 0.8045
checkresiduals(dynlm2)
##
## Breusch-Godfrey test for serial correlation of order up to 6
##
## data: Residuals
## LM test = 14.369, df = 6, p-value = 0.02577
dynlm3 =dynlm(Ffd ~ Temprature+trend(Ffd))
summary(dynlm3)
##
## Time series regression with "ts" data:
## Start = 1984, End = 2014
##
## Call:
## dynlm(formula = Ffd ~ Temprature + trend(Ffd))
##
## Residuals:
## Min 1Q Median 3Q Max
## -19.537 -6.983 -1.837 10.050 16.634
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 320.04478 77.64673 4.122 0.000303 ***
## Temprature -0.36181 4.09797 -0.088 0.930275
## trend(Ffd) -0.06971 0.29286 -0.238 0.813591
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 11.73 on 28 degrees of freedom
## Multiple R-squared: 0.004916, Adjusted R-squared: -0.06616
## F-statistic: 0.06916 on 2 and 28 DF, p-value: 0.9333
checkresiduals(dynlm3)
##
## Breusch-Godfrey test for serial correlation of order up to 6
##
## data: Residuals
## LM test = 13.347, df = 6, p-value = 0.03784
dynlm4 =dynlm(Ffd ~ Temprature+trend(Ffd)+L(Ffd , k = 1)+L(Ffd , k = 2))
summary(dynlm4)
##
## Time series regression with "ts" data:
## Start = 1986, End = 2014
##
## Call:
## dynlm(formula = Ffd ~ Temprature + trend(Ffd) + L(Ffd, k = 1) +
## L(Ffd, k = 2))
##
## Residuals:
## Min 1Q Median 3Q Max
## -19.8296 -9.2895 -0.1077 8.5086 18.1550
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 232.42272 149.94929 1.550 0.134
## Temprature 0.34342 4.49878 0.076 0.940
## trend(Ffd) -0.05982 0.32424 -0.185 0.855
## L(Ffd, k = 1) -0.05432 0.20259 -0.268 0.791
## L(Ffd, k = 2) 0.28934 0.20204 1.432 0.165
##
## Residual standard error: 11.94 on 24 degrees of freedom
## Multiple R-squared: 0.09018, Adjusted R-squared: -0.06146
## F-statistic: 0.5947 on 4 and 24 DF, p-value: 0.6699
checkresiduals(dynlm4)
##
## Breusch-Godfrey test for serial correlation of order up to 8
##
## data: Residuals
## LM test = 11.897, df = 8, p-value = 0.1559
dynlm5 =dynlm(Ffd ~ Rain)
summary(dynlm5)
##
## Time series regression with "ts" data:
## Start = 1984, End = 2014
##
## Call:
## dynlm(formula = Ffd ~ Rain)
##
## Residuals:
## Min 1Q Median 3Q Max
## -19.481 -6.450 -1.097 10.858 19.344
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 327.788 13.210 24.813 <2e-16 ***
## Rain -6.729 5.508 -1.222 0.232
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 11.27 on 29 degrees of freedom
## Multiple R-squared: 0.04895, Adjusted R-squared: 0.01616
## F-statistic: 1.493 on 1 and 29 DF, p-value: 0.2316
checkresiduals(dynlm5)
##
## Breusch-Godfrey test for serial correlation of order up to 6
##
## data: Residuals
## LM test = 14.062, df = 6, p-value = 0.02896
dynlm6 =dynlm(Ffd ~ Rain+L(Ffd , k = 1 )+L(Ffd , k = 2))
summary(dynlm6)
##
## Time series regression with "ts" data:
## Start = 1986, End = 2014
##
## Call:
## dynlm(formula = Ffd ~ Rain + L(Ffd, k = 1) + L(Ffd, k = 2))
##
## Residuals:
## Min 1Q Median 3Q Max
## -20.258 -8.363 -0.418 7.376 18.712
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 266.17212 94.45801 2.818 0.00931 **
## Rain -4.46449 6.05670 -0.737 0.46791
## L(Ffd, k = 1) -0.05551 0.18817 -0.295 0.77044
## L(Ffd, k = 2) 0.23457 0.20164 1.163 0.25569
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 11.58 on 25 degrees of freedom
## Multiple R-squared: 0.1082, Adjusted R-squared: 0.001204
## F-statistic: 1.011 on 3 and 25 DF, p-value: 0.4043
checkresiduals(dynlm6)
##
## Breusch-Godfrey test for serial correlation of order up to 7
##
## data: Residuals
## LM test = 12.367, df = 7, p-value = 0.08913
dynlm7 =dynlm(Ffd ~ Rain+trend(Ffd))
summary(dynlm7)
##
## Time series regression with "ts" data:
## Start = 1984, End = 2014
##
## Call:
## dynlm(formula = Ffd ~ Rain + trend(Ffd))
##
## Residuals:
## Min 1Q Median 3Q Max
## -19.624 -7.559 -2.605 9.834 19.071
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 331.3846 14.6741 22.583 <2e-16 ***
## Rain -7.3164 5.6577 -1.293 0.207
## trend(Ffd) -0.1377 0.2324 -0.593 0.558
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 11.39 on 28 degrees of freedom
## Multiple R-squared: 0.06074, Adjusted R-squared: -0.006354
## F-statistic: 0.9053 on 2 and 28 DF, p-value: 0.4159
checkresiduals(dynlm7)
##
## Breusch-Godfrey test for serial correlation of order up to 6
##
## data: Residuals
## LM test = 14.371, df = 6, p-value = 0.02575
dynlm8 =dynlm(Ffd ~ Rain+trend(Ffd)+L(Ffd , k = 1)+L(Ffd , k = 2))
summary(dynlm8)
##
## Time series regression with "ts" data:
## Start = 1986, End = 2014
##
## Call:
## dynlm(formula = Ffd ~ Rain + trend(Ffd) + L(Ffd, k = 1) + L(Ffd,
## k = 2))
##
## Residuals:
## Min 1Q Median 3Q Max
## -20.3701 -9.3916 -0.9438 7.4308 18.2587
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 270.58403 97.34289 2.780 0.0104 *
## Rain -4.78066 6.25940 -0.764 0.4525
## trend(Ffd) -0.07983 0.26609 -0.300 0.7668
## L(Ffd, k = 1) -0.05863 0.19197 -0.305 0.7627
## L(Ffd, k = 2) 0.23030 0.20591 1.118 0.2744
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 11.8 on 24 degrees of freedom
## Multiple R-squared: 0.1115, Adjusted R-squared: -0.03653
## F-statistic: 0.7533 on 4 and 24 DF, p-value: 0.5657
checkresiduals(dynlm8)
##
## Breusch-Godfrey test for serial correlation of order up to 8
##
## data: Residuals
## LM test = 13.055, df = 8, p-value = 0.11
dynlm9 =dynlm(Ffd ~ Rad)
summary(dynlm9)
##
## Time series regression with "ts" data:
## Start = 1984, End = 2014
##
## Call:
## dynlm(formula = Ffd ~ Rad)
##
## Residuals:
## Min 1Q Median 3Q Max
## -19.580 -6.330 -1.574 9.857 18.820
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 255.425 75.441 3.386 0.00206 **
## Rad 3.866 5.168 0.748 0.46044
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 11.44 on 29 degrees of freedom
## Multiple R-squared: 0.01893, Adjusted R-squared: -0.0149
## F-statistic: 0.5596 on 1 and 29 DF, p-value: 0.4604
checkresiduals(dynlm9)
##
## Breusch-Godfrey test for serial correlation of order up to 6
##
## data: Residuals
## LM test = 12.962, df = 6, p-value = 0.04365
dynlm10 =dynlm(Ffd ~ Rad+L(Ffd , k = 1 ))
summary(dynlm10)
##
## Time series regression with "ts" data:
## Start = 1985, End = 2014
##
## Call:
## dynlm(formula = Ffd ~ Rad + L(Ffd, k = 1))
##
## Residuals:
## Min 1Q Median 3Q Max
## -20.6355 -7.7413 0.0541 9.0782 19.0965
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 281.7289 89.4913 3.148 0.00398 **
## Rad 4.8001 5.4749 0.877 0.38835
## L(Ffd, k = 1) -0.1276 0.1941 -0.658 0.51641
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 11.75 on 27 degrees of freedom
## Multiple R-squared: 0.0358, Adjusted R-squared: -0.03562
## F-statistic: 0.5013 on 2 and 27 DF, p-value: 0.6113
checkresiduals(dynlm10)
##
## Breusch-Godfrey test for serial correlation of order up to 6
##
## data: Residuals
## LM test = 12.642, df = 6, p-value = 0.04908
dynlm11 =dynlm(Ffd ~ Rad+trend(Ffd))
summary(dynlm11)
##
## Time series regression with "ts" data:
## Start = 1984, End = 2014
##
## Call:
## dynlm(formula = Ffd ~ Rad + trend(Ffd))
##
## Residuals:
## Min 1Q Median 3Q Max
## -20.705 -7.566 -1.422 9.256 18.588
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 252.9637 76.6825 3.299 0.00265 **
## Rad 4.1522 5.2776 0.787 0.43804
## trend(Ffd) -0.1070 0.2346 -0.456 0.65184
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 11.6 on 28 degrees of freedom
## Multiple R-squared: 0.02617, Adjusted R-squared: -0.04339
## F-statistic: 0.3762 on 2 and 28 DF, p-value: 0.6899
checkresiduals(dynlm11)
##
## Breusch-Godfrey test for serial correlation of order up to 6
##
## data: Residuals
## LM test = 13.256, df = 6, p-value = 0.03914
dynlm12 =dynlm(Ffd ~ Rad+trend(Ffd)+L(Ffd , k = 1)+L(Ffd , k = 2))
summary(dynlm12)
##
## Time series regression with "ts" data:
## Start = 1986, End = 2014
##
## Call:
## dynlm(formula = Ffd ~ Rad + trend(Ffd) + L(Ffd, k = 1) + L(Ffd,
## k = 2))
##
## Residuals:
## Min 1Q Median 3Q Max
## -19.546 -10.110 1.151 7.804 17.849
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 204.18863 106.61378 1.915 0.0675 .
## Rad 3.73070 5.72471 0.652 0.5208
## trend(Ffd) -0.08300 0.26933 -0.308 0.7606
## L(Ffd, k = 1) -0.09044 0.19866 -0.455 0.6530
## L(Ffd, k = 2) 0.26455 0.19612 1.349 0.1900
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 11.84 on 24 degrees of freedom
## Multiple R-squared: 0.1058, Adjusted R-squared: -0.04326
## F-statistic: 0.7098 on 4 and 24 DF, p-value: 0.5933
checkresiduals(dynlm12)
##
## Breusch-Godfrey test for serial correlation of order up to 8
##
## data: Residuals
## LM test = 11.43, df = 8, p-value = 0.1785
dynlm13 =dynlm(Ffd ~ Humid)
summary(dynlm13)
##
## Time series regression with "ts" data:
## Start = 1984, End = 2014
##
## Call:
## dynlm(formula = Ffd ~ Humid)
##
## Residuals:
## Min 1Q Median 3Q Max
## -23.384 -8.257 -1.304 11.573 15.922
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 621.367 247.063 2.515 0.0177 *
## Humid -3.274 2.613 -1.253 0.2203
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 11.25 on 29 degrees of freedom
## Multiple R-squared: 0.05135, Adjusted R-squared: 0.01864
## F-statistic: 1.57 on 1 and 29 DF, p-value: 0.2203
checkresiduals(dynlm13)
##
## Breusch-Godfrey test for serial correlation of order up to 6
##
## data: Residuals
## LM test = 12.983, df = 6, p-value = 0.04331
dynlm14 =dynlm(Ffd ~ Humid+L(Ffd , k = 1 ))
summary(dynlm14)
##
## Time series regression with "ts" data:
## Start = 1985, End = 2014
##
## Call:
## dynlm(formula = Ffd ~ Humid + L(Ffd, k = 1))
##
## Residuals:
## Min 1Q Median 3Q Max
## -22.0619 -9.3970 0.6428 11.8373 17.4053
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 672.2518 266.1319 2.526 0.0177 *
## Humid -3.4738 2.7191 -1.278 0.2123
## L(Ffd, k = 1) -0.1021 0.1870 -0.546 0.5897
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 11.57 on 27 degrees of freedom
## Multiple R-squared: 0.06488, Adjusted R-squared: -0.004392
## F-statistic: 0.9366 on 2 and 27 DF, p-value: 0.4043
checkresiduals(dynlm14)
##
## Breusch-Godfrey test for serial correlation of order up to 6
##
## data: Residuals
## LM test = 11.858, df = 6, p-value = 0.0652
dynlm15 =dynlm(Ffd ~ Humid+trend(Ffd))
summary(dynlm15)
##
## Time series regression with "ts" data:
## Start = 1984, End = 2014
##
## Call:
## dynlm(formula = Ffd ~ Humid + trend(Ffd))
##
## Residuals:
## Min 1Q Median 3Q Max
## -23.514 -8.182 -1.259 11.419 16.039
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 615.52810 256.15277 2.403 0.0231 *
## Humid -3.20744 2.71719 -1.180 0.2478
## trend(Ffd) -0.02785 0.23494 -0.119 0.9065
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 11.45 on 28 degrees of freedom
## Multiple R-squared: 0.05182, Adjusted R-squared: -0.0159
## F-statistic: 0.7652 on 2 and 28 DF, p-value: 0.4747
checkresiduals(dynlm15)
##
## Breusch-Godfrey test for serial correlation of order up to 6
##
## data: Residuals
## LM test = 13.072, df = 6, p-value = 0.0419
dynlm16 =dynlm(Ffd ~ Humid+trend(Ffd)+L(Ffd , k = 1)+L(Ffd , k = 2))
summary(dynlm16)
##
## Time series regression with "ts" data:
## Start = 1986, End = 2014
##
## Call:
## dynlm(formula = Ffd ~ Humid + trend(Ffd) + L(Ffd, k = 1) + L(Ffd,
## k = 2))
##
## Residuals:
## Min 1Q Median 3Q Max
## -16.9188 -8.5368 0.0918 8.7952 18.9143
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 592.01288 279.23598 2.120 0.0445 *
## Humid -3.67651 2.78149 -1.322 0.1987
## trend(Ffd) 0.02667 0.26207 0.102 0.9198
## L(Ffd, k = 1) -0.06659 0.18768 -0.355 0.7258
## L(Ffd, k = 2) 0.28016 0.18851 1.486 0.1502
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 11.53 on 24 degrees of freedom
## Multiple R-squared: 0.1517, Adjusted R-squared: 0.01033
## F-statistic: 1.073 on 4 and 24 DF, p-value: 0.3916
checkresiduals(dynlm16)
##
## Breusch-Godfrey test for serial correlation of order up to 8
##
## data: Residuals
## LM test = 10.541, df = 8, p-value = 0.2291
dlmodels <- c("TModel1", "TModel2", "TModel3", "TModel4", "RModel1", "RModel2", "RModel3", "RModel4",
"Model1", "Model2", "Model3", "Model4","HModel1", "HModel2", "HModel3", "HModel4")
dlaic <- c(AIC(tmodel1), AIC(tmodel2), AIC(tmodel3), AIC(tmodel4), AIC(rmodel1), AIC(rmodel2), AIC(rmodel3), AIC(rmodel4),AIC(model1), AIC(model2), AIC(model3), AIC(model4),AIC(hmodel1), AIC(hmodel2), AIC(hmodel3), AIC(hmodel4))
## [1] 170.8439
## [1] 163.7328
## [1] 242.2256
## [1] 208.9515
## [1] 159.5287
## [1] 164.9582
## [1] 269.7062
## [1] 201.1726
## [1] 172.2492
## [1] 163.2937
## [1] 237.873
## [1] 208.052
## [1] 172.2492
## [1] 163.5124
## [1] 248.0706
## [1] 206.1062
dlbic <- c(BIC(tmodel1), BIC(tmodel2), BIC(tmodel3), BIC(tmodel4), BIC(rmodel1), BIC(rmodel2), BIC(rmodel3), BIC(rmodel4),BIC(model1), BIC(model2), BIC(model3), BIC(model4),BIC(hmodel1), BIC(hmodel2), BIC(hmodel3), BIC(hmodel4))
## [1] 184.4227
## [1] 168.9554
## [1] 247.8304
## [1] 220.2744
## [1] 173.1074
## [1] 170.1808
## [1] 275.3109
## [1] 212.4955
## [1] 185.828
## [1] 168.5163
## [1] 243.4778
## [1] 224.4073
## [1] 185.828
## [1] 168.735
## [1] 253.6754
## [1] 217.429
dlMASE <- MASE(tmodel1, tmodel2, tmodel3, tmodel4, rmodel1, rmodel2, rmodel3, rmodel4,model1, model2, model3, model4,hmodel1, hmodel2, hmodel3, hmodel4)$MASE
dlaccuracy <- data.frame(dlmodels, dlMASE, dlaic, dlbic)
colnames(dlaccuracy) <- c("Model", "MASE", "AIC", "BIC")
dlaccuracy
## Model MASE AIC BIC
## 1 TModel1 0.5495688 170.8439 184.4227
## 2 TModel2 0.6796679 163.7328 168.9554
## 3 TModel3 0.7968756 242.2256 247.8304
## 4 TModel4 0.5812989 208.9515 220.2744
## 5 RModel1 0.4554174 159.5287 173.1074
## 6 RModel2 0.6551896 164.9582 170.1808
## 7 RModel3 1.1546848 269.7062 275.3109
## 8 RModel4 0.4629303 201.1726 212.4955
## 9 Model1 0.5702439 172.2492 185.8280
## 10 Model2 0.6355363 163.2937 168.5163
## 11 Model3 0.7540611 237.8730 243.4778
## 12 Model4 0.4860361 208.0520 224.4073
## 13 HModel1 0.5702439 172.2492 185.8280
## 14 HModel2 0.7312748 163.5124 168.7350
## 15 HModel3 0.8390184 248.0706 253.6754
## 16 HModel4 0.5336178 206.1062 217.4290
#Coparision of DYNLM models
dynlms <- c("dynlm1", "dynlm2", "dynlm3", "dynlm4", "dynlm5", "dynlm6", "dynlm7","dynlm8","dynlm9","dynlm10","dynlm11", "dynlm12", "dynlm13", "dynlm14", "dynlm15", "dynlm16")
dyaic <- AIC(dynlm1, dynlm2, dynlm3, dynlm4, dynlm5, dynlm6, dynlm7,dynlm8,dynlm9,dynlm10,dynlm11, dynlm12, dynlm13, dynlm14, dynlm15, dynlm16)$AIC
dybic <- BIC(dynlm1, dynlm2, dynlm3, dynlm4, dynlm5, dynlm6, dynlm7,dynlm8,dynlm9,dynlm10,dynlm11, dynlm12, dynlm13, dynlm14, dynlm15, dynlm16)$BIC
dyMASE <- c( accuracy(dynlm1)[6],accuracy(dynlm2)[6], accuracy(dynlm3)[6], accuracy(dynlm4)[6], accuracy(dynlm5)[6], accuracy(dynlm6)[6], accuracy(dynlm7)[6],accuracy(dynlm8)[6],accuracy(dynlm9)[6],accuracy(dynlm10)[6],
accuracy(dynlm11)[6],accuracy(dynlm12)[6], accuracy(dynlm13)[6], accuracy(dynlm14)[6], accuracy(dynlm15)[6], accuracy(dynlm16)[6])
dyaccuracy <- data.frame(dynlms, dyMASE, dyaic, dybic)
colnames(dyaccuracy) <- c("dynlm", "MASE", "AIC", "BIC")
dyaccuracy
## dynlm MASE AIC BIC
## 1 dynlm1 0.7548499 243.5233 247.8253
## 2 dynlm2 0.7571374 238.4217 244.0265
## 3 dynlm3 0.7546133 245.4607 251.1966
## 4 dynlm4 0.7215446 232.6483 240.8521
## 5 dynlm5 0.7283036 242.0575 246.3595
## 6 dynlm6 0.7117269 230.0675 236.9040
## 7 dynlm7 0.7241360 243.6710 249.4070
## 8 dynlm8 0.7160739 231.9589 240.1627
## 9 dynlm9 0.7448205 243.0209 247.3229
## 10 dynlm10 0.7508961 237.8113 243.4161
## 11 dynlm11 0.7412075 244.7915 250.5274
## 12 dynlm12 0.7208492 232.1467 240.3505
## 13 dynlm13 0.7538879 241.9793 246.2813
## 14 dynlm14 0.7591338 236.8928 242.4976
## 15 dynlm15 0.7541481 243.9638 249.6997
## 16 dynlm16 0.7288201 230.6176 238.8214
#forecasting dataset
data.x <- read_csv("/Users/shubhamchougule/Downloads/Covariate x-values for Task 2 (1).csv")
## Parsed with column specification:
## cols(
## Year = col_double(),
## Temperature = col_double(),
## Rainfall = col_double(),
## Radiation = col_double(),
## RelHumidity = col_double()
## )
forecast_ts=ts(data.x)
dlmfore = forecast(rmodel1, x = as.vector(forecast_ts) , h = 4)$forecasts
polfore = forecast(model2, x = as.vector(forecast_ts) , h = 4)$forecasts
koyfore = forecast(model3, x = as.vector(forecast_ts) , h = 4)$forecasts
arfore = forecast(rmodel4, x = as.vector(forecast_ts) , h = 4)$forecasts
#Dynlm model forecasting
q = 4
n = nrow(dynlm6$model)
landings.frc = array(NA , (n + q))
landings.frc[1:n] = Ffd[1:length(Ffd)]
for (i in 1:q){
months = 1
months[(i-1)%%12] = 1
data.new = c(1,landings.frc[n-1+i],landings.frc[n-2+i],1)
landings.frc[n+i] = as.vector(dynlm6$coefficients) %*% data.new
}
dlm = c(Ffd,dlmfore)
poly = c(Ffd,polfore)
koyc = c(Ffd,koyfore)
ard = c(Ffd,arfore)
dynlm_forecast=ts(landings.frc[(n+1):(n+q)],start=2014,frequency = 1)
Dataforecast = ts.intersect(
ts(dlm,start=1984,frequency = 1),
ts(poly,start=1984,frequency = 1),
ts(koyc,start=1984,frequency = 1),
ts(ard,start=1984,frequency = 1),
ts(landings.frc[(n+1):(n+q)],start=2015,frequency = 1)
)
ts.plot(Dataforecast,xlim=c(2015,2018),
plot.type = c("single"), gpars= list(col=c("red","blue","gray","green","black")),
main = "Forecasting of next 4 years of FFD")
legend("bottomleft", col=c("red","blue","gray","green","black"), lty=1, cex=.65,c("DLM","Poly","Koyn","ARdlm","DYNLM"))
Data tells the influence of long-term climate shifts in Victoria on the relative flowering order similarity of 81 species of plants from 1983 to 2014.The species were ranked annually by the time taken to flower (FFD), and changes in flowering order were measured by computing the similarity between annual flowering order and the flowering order of 1983 using the Rank-based Order similarity metric (RBO).
The goal is to forecast RBO three years ahead.
RBO <- read_csv("/Users/shubhamchougule/Downloads/RBO .csv")
## Parsed with column specification:
## cols(
## Year = col_double(),
## RBO = col_double(),
## Temperature = col_double(),
## Rainfall = col_double(),
## Radiation = col_double(),
## RelHumidity = col_double(),
## X7 = col_logical(),
## X8 = col_logical(),
## X9 = col_logical(),
## X10 = col_logical(),
## X11 = col_logical(),
## X12 = col_logical(),
## X13 = col_logical(),
## X14 = col_logical()
## )
RBO<-RBO[!is.na(RBO$Temperature), ]
Temp<-ts(RBO$Temperature,start = 1984,frequency = 1)
Rain<-ts(RBO$Rainfall,start = 1984,frequency = 1)
Rad<-ts(RBO$Radiation,start = 1984,frequency = 1)
Humid<-ts(RBO$RelHumidity,start = 1984,frequency = 1)
RBOTS<-ts(RBO$RBO,start = 1984,frequency = 1)
plot(Temp,type="o",ylab="Yearly Temp",xlab="YEAR",main="Temp")
abline(reg=lm(Temp~time(Temp)))
acf(Temp)
Pacf(Temp)
adf.test(Temp)
##
## Augmented Dickey-Fuller Test
##
## data: Temp
## Dickey-Fuller = -3.3034, Lag order = 3, p-value = 0.08928
## alternative hypothesis: stationary
summary(Temp)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 18.43 19.19 19.69 19.60 19.96 20.83
plot(Rain,type="o",ylab="Yearly Rainfall",xlab="YEAR",main="Rainfall")
abline(reg=lm(Rain~time(Rain)))
acf(Rain)
Pacf(Rain)
adf.test(Rain)
##
## Augmented Dickey-Fuller Test
##
## data: Rain
## Dickey-Fuller = -2.3024, Lag order = 3, p-value = 0.4563
## alternative hypothesis: stationary
summary(Rain)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 1.403 2.210 2.421 2.370 2.628 2.886
plot(Rad,type="o",ylab="Yearly Radiations",xlab="YEAR",main="Radiation")
abline(reg=lm(Rad~time(Rad)))
acf(Rad)
Pacf(Rad)
adf.test(Rad)
##
## Augmented Dickey-Fuller Test
##
## data: Rad
## Dickey-Fuller = -2.6949, Lag order = 3, p-value = 0.3052
## alternative hypothesis: stationary
summary(Rad)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 13.40 14.41 14.64 14.59 14.78 15.41
plot(Humid,type="o",ylab="Yearly Humidity",xlab="YEAR",main="Humidity")
abline(reg=lm(Humid~time(Humid)))
acf(Humid)
Pacf(Humid)
adf.test(Humid)
##
## Augmented Dickey-Fuller Test
##
## data: Humid
## Dickey-Fuller = -3.4175, Lag order = 3, p-value = 0.07309
## alternative hypothesis: stationary
summary(Humid)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 51.27 52.86 53.87 53.95 54.96 56.61
plot(RBOTS,type="o",ylab="Yearly RBOTS",xlab="YEAR",main="RBOTS")
abline(reg=lm(RBOTS~time(RBOTS)))
acf(RBOTS)
Pacf(RBOTS)
adf.test(RBOTS)
##
## Augmented Dickey-Fuller Test
##
## data: RBOTS
## Dickey-Fuller = -2.0545, Lag order = 3, p-value = 0.5518
## alternative hypothesis: stationary
summary(RBOTS)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.6629 0.7043 0.7321 0.7379 0.7566 0.8424
TempL=BoxCox.lambda(Temp)
RainL=BoxCox.lambda(Rain)
RadL=BoxCox.lambda(Rad)
HumidL=BoxCox.lambda(Humid)
RBOTSL=BoxCox.lambda(RBOTS)
cbind(TempL,RainL,RadL,HumidL,RBOTSL)
## TempL RainL RadL HumidL RBOTSL
## [1,] 0.3670229 1.999924 1.999924 -0.9999242 -0.9999242
Rain, radiation, humidity and RBO have values more than 1 and negative so need transformation and differencing to make the series stationary.
#Need to apply transformation to Rain,Rad,Humid and RBOTS
TempD =diff(Temp,differences=3)
plot(TempD,type="o",ylab="Yearly Temp",xlab="YEAR",main="Temp")
RainT=BoxCox(Rain,lambda = RainL)
plot(RainT,type="o",ylab="Yearly Rainfall",xlab="YEAR",main="Rainfall")
RainTD =diff(RainT,differences=3)
plot(RainTD,type="o",ylab="Yearly Rainfall",xlab="YEAR",main="Rainfall")
RadT=BoxCox(Rad,lambda = RadL)
plot(RadT,type="o",ylab="Yearly Radiations",xlab="YEAR",main="Radiation")
RadTD =diff(RadT,differences=3)
plot(RadTD,type="o",ylab="Yearly Radiations",xlab="YEAR",main="Radiation")
HumidT=BoxCox(Humid,lambda = HumidL)
plot(HumidT,type="o",ylab="Yearly Humidity",xlab="YEAR",main="Humidity")
HumidTD =diff(HumidT,differences=3)
plot(HumidTD,type="o",ylab="Yearly Humidity",xlab="YEAR",main="Humidity")
RBOTST=BoxCox(RBOTS,lambda = RBOTSL)
plot(RBOTST,type="o",ylab="Yearly RBOTS",xlab="YEAR",main="RBOTS")
RBOTSTD =diff(RBOTST,differences=3)
plot(RBOTSTD,type="o",ylab="Yearly RBOTS",xlab="YEAR",main="RBOTS")
Now after differencing all series looks good and statinarity is checked by adf test.
adf.test(TempD)
##
## Augmented Dickey-Fuller Test
##
## data: TempD
## Dickey-Fuller = -4.0851, Lag order = 3, p-value = 0.01979
## alternative hypothesis: stationary
adf.test(RainTD)
##
## Augmented Dickey-Fuller Test
##
## data: RainTD
## Dickey-Fuller = -6.4196, Lag order = 3, p-value = 0.01
## alternative hypothesis: stationary
adf.test(RadTD)
##
## Augmented Dickey-Fuller Test
##
## data: RadTD
## Dickey-Fuller = -4.0888, Lag order = 3, p-value = 0.01966
## alternative hypothesis: stationary
adf.test(HumidTD)
##
## Augmented Dickey-Fuller Test
##
## data: HumidTD
## Dickey-Fuller = -4.1069, Lag order = 3, p-value = 0.01902
## alternative hypothesis: stationary
adf.test(RBOTSTD)
##
## Augmented Dickey-Fuller Test
##
## data: RBOTSTD
## Dickey-Fuller = -4.0142, Lag order = 3, p-value = 0.0223
## alternative hypothesis: stationary
All the pvalue of adf test are less than 5% hence all the series are stationary.
For understanding the series we will decompose using STL function.
decompose <- function(x){
stldec=mstl(x, t.window=15, s.window="periodic", robust=TRUE)
plot(stldec)
}
decompose(TempD)
decompose(RainTD)
decompose(RadTD)
decompose(HumidTD)
decompose(RBOTSTD)
In all series we see trend except Radiation and no seasonality in any series.
cor(RBO[,2:6])
## RBO Temperature Rainfall Radiation RelHumidity
## RBO 1.0000000 -0.3452053 0.3932282 -0.3173602 0.3885540
## Temperature -0.3452053 1.0000000 -0.3915072 0.5193576 -0.6621980
## Rainfall 0.3932282 -0.3915072 1.0000000 -0.5813161 0.7911079
## Radiation -0.3173602 0.5193576 -0.5813161 1.0000000 -0.7354087
## RelHumidity 0.3885540 -0.6621980 0.7911079 -0.7354087 1.0000000
Correlation of temprature and Humidity is high with RBO.
#selection of "q" value on basis of AIC and BIC for fitting of DLM model
for(i in 1:10){
model1 = dlm( x = as.vector(Temp) , y = as.vector(RBOTS), q = i )
cat("q = ", i, "AIC = ", AIC(model1$model), "BIC = ", BIC(model1$model),"\n")
}
## q = 1 AIC = -97.52442 BIC = -91.91963
## q = 2 AIC = -91.57332 BIC = -84.73684
## q = 3 AIC = -88.84678 BIC = -80.85356
## q = 4 AIC = -82.35556 BIC = -73.28471
## q = 5 AIC = -81.62553 BIC = -71.56076
## q = 6 AIC = -77.12304 BIC = -66.15316
## q = 7 AIC = -76.88467 BIC = -65.10413
## q = 8 AIC = -78.3504 BIC = -65.85997
## q = 9 AIC = -79.75895 BIC = -66.66644
## q = 10 AIC = -85.18937 BIC = -71.61058
tmodel1<- dlm(x = as.vector(Temp) , y = as.vector(RBOTS), q = 1)
summary(tmodel1)
##
## Call:
## lm(formula = model.formula, data = design)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.096758 -0.026371 -0.003658 0.015824 0.084162
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.133317 0.296340 3.824 0.000703 ***
## x.t -0.027105 0.014342 -1.890 0.069560 .
## x.1 0.006952 0.014650 0.475 0.638919
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.04394 on 27 degrees of freedom
## Multiple R-squared: 0.1223, Adjusted R-squared: 0.05726
## F-statistic: 1.881 on 2 and 27 DF, p-value: 0.1719
##
## AIC and BIC values for the model:
## AIC BIC
## 1 -97.52442 -91.91963
checkresiduals(tmodel1$model)
##
## Breusch-Godfrey test for serial correlation of order up to 6
##
## data: Residuals
## LM test = 13.758, df = 6, p-value = 0.03246
vif(tmodel1$model)
## x.t x.1
## 1.262877 1.262877
tmodel2 = polyDlm(x = as.vector(Temp) , y = as.vector(RBOTS) , q = 1 , k = 1 , show.beta = TRUE)
## Estimates and t-tests for beta coefficients:
## Estimate Std. Error t value P(>|t|)
## beta.0 -0.02710 0.0143 -1.890 0.0688
## beta.1 0.00695 0.0146 0.475 0.6390
summary(tmodel2)
##
## Call:
## "Y ~ (Intercept) + X.t"
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.096758 -0.026371 -0.003658 0.015824 0.084162
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.13332 0.29634 3.824 0.000703 ***
## z.t0 -0.02710 0.01434 -1.890 0.069560 .
## z.t1 0.03406 0.02474 1.377 0.179941
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.04394 on 27 degrees of freedom
## Multiple R-squared: 0.1223, Adjusted R-squared: 0.05726
## F-statistic: 1.881 on 2 and 27 DF, p-value: 0.1719
checkresiduals(tmodel2$model)
##
## Breusch-Godfrey test for serial correlation of order up to 6
##
## data: Residuals
## LM test = 13.758, df = 6, p-value = 0.03246
vif(tmodel2$model)
## z.t0 z.t1
## 3.601424 3.601424
tmodel3 = koyckDlm(x = as.vector(Temp) , y = as.vector(RBOTS))
summary(tmodel3,diagnostics=TRUE)
##
## Call:
## "Y ~ (Intercept) + Y.1 + X.t"
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.0741656 -0.0225173 -0.0006794 0.0240622 0.1270971
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.20775 0.83741 -0.248 0.8059
## Y.1 0.68547 0.25559 2.682 0.0123 *
## X.t 0.02235 0.03523 0.634 0.5312
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.04319 on 27 degrees of freedom
## Multiple R-Squared: 0.1517, Adjusted R-squared: 0.08891
## Wald test: 5.309 on 2 and 27 DF, p-value: 0.01136
##
## Diagnostic tests:
## df1 df2 statistic p-value
## Weak instruments 1 27 4.634891 0.04042345
## Wu-Hausman 1 26 1.347013 0.25634707
##
## alpha beta phi
## Geometric coefficients: -0.6605142 0.02234675 0.6854665
checkresiduals(tmodel3$model)
vif(tmodel3$model)
## Y.1 X.t
## 2.059958 2.059958
#Checking p and q vales on basis fo AIC and BIC
for (i in 1:5){
for(j in 1:5){
model4 = ardlDlm(x = as.vector(Temp) , y = as.vector(RBOTS), p = i , q = j )
cat("p = ", i, "q = ", j, "AIC = ", AIC(model4$model), "BIC = ", BIC(model4$model),"\n")
}
}
## p = 1 q = 1 AIC = -105.6323 BIC = -98.62635
## p = 1 q = 2 AIC = -106.7338 BIC = -98.53007
## p = 1 q = 3 AIC = -109.2081 BIC = -99.88269
## p = 1 q = 4 AIC = -102.1791 BIC = -91.81242
## p = 1 q = 5 AIC = -97.33529 BIC = -86.01242
## p = 2 q = 1 AIC = -100.7618 BIC = -92.55807
## p = 2 q = 2 AIC = -105.1274 BIC = -95.55629
## p = 2 q = 3 AIC = -107.2334 BIC = -96.57577
## p = 2 q = 4 AIC = -100.1907 BIC = -88.52822
## p = 2 q = 5 AIC = -95.74261 BIC = -83.16164
## p = 3 q = 1 AIC = -101.7805 BIC = -92.45505
## p = 3 q = 2 AIC = -107.3386 BIC = -96.681
## p = 3 q = 3 AIC = -105.3553 BIC = -93.36549
## p = 3 q = 4 AIC = -98.69016 BIC = -85.73179
## p = 3 q = 5 AIC = -94.15321 BIC = -80.31415
## p = 4 q = 1 AIC = -96.62629 BIC = -86.25959
## p = 4 q = 2 AIC = -100.9245 BIC = -89.26198
## p = 4 q = 3 AIC = -99.22742 BIC = -86.26905
## p = 4 q = 4 AIC = -97.42765 BIC = -83.17345
## p = 4 q = 5 AIC = -95.44763 BIC = -80.35047
## p = 5 q = 1 AIC = -96.37589 BIC = -85.05302
## p = 5 q = 2 AIC = -97.48107 BIC = -84.90011
## p = 5 q = 3 AIC = -95.70698 BIC = -81.86792
## p = 5 q = 4 AIC = -93.77188 BIC = -78.67472
## p = 5 q = 5 AIC = -93.93583 BIC = -77.58057
tmodel4 = ardlDlm(x = as.vector(Temp) , y = as.vector(RBOTS), p = 1 , q = 3 )
summary(tmodel4)
##
## Time series regression with "ts" data:
## Start = 4, End = 31
##
## Call:
## dynlm(formula = as.formula(model.text), data = data, start = 1)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.063732 -0.012555 0.004698 0.013916 0.056059
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.127938 0.331280 -0.386 0.7031
## X.t -0.008989 0.013504 -0.666 0.5126
## X.1 0.022310 0.011686 1.909 0.0694 .
## Y.1 0.360149 0.167928 2.145 0.0433 *
## Y.2 0.441545 0.181079 2.438 0.0233 *
## Y.3 0.012025 0.205217 0.059 0.9538
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.03024 on 22 degrees of freedom
## Multiple R-squared: 0.58, Adjusted R-squared: 0.4846
## F-statistic: 6.076 on 5 and 22 DF, p-value: 0.001116
checkresiduals(tmodel4$model)
##
## Breusch-Godfrey test for serial correlation of order up to 9
##
## data: Residuals
## LM test = 15.387, df = 9, p-value = 0.08083
vif(tmodel4$model)
## X.t L(X.t, 1) L(y.t, 1) L(y.t, 2) L(y.t, 3)
## 2.105069 1.567956 1.805344 2.093365 2.699369
#selection of "q" value on basis of AIC and BIC for fitting of DLM model
for(i in 1:10){
model1 = dlm( x = as.vector(Rain) , y = as.vector(RBOTS), q = i )
cat("q = ", i, "AIC = ", AIC(model1$model), "BIC = ", BIC(model1$model),"\n")
}
## q = 1 AIC = -100.898 BIC = -95.29319
## q = 2 AIC = -96.70956 BIC = -89.87308
## q = 3 AIC = -97.19966 BIC = -89.20643
## q = 4 AIC = -90.46187 BIC = -81.39101
## q = 5 AIC = -87.24242 BIC = -77.17765
## q = 6 AIC = -82.31788 BIC = -71.348
## q = 7 AIC = -77.98405 BIC = -66.20351
## q = 8 AIC = -76.81922 BIC = -64.32879
## q = 9 AIC = -80.79432 BIC = -67.70181
## q = 10 AIC = -76.93255 BIC = -63.35376
rmodel1<- dlm(x = as.vector(Rain) , y = as.vector(RBOTS), q = 1)
summary(rmodel1)
##
## Call:
## lm(formula = model.formula, data = design)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.105903 -0.024178 -0.006166 0.014773 0.099699
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.56594 0.06397 8.847 1.84e-09 ***
## x.t 0.04199 0.02058 2.040 0.0512 .
## x.1 0.03032 0.02059 1.473 0.1524
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.04153 on 27 degrees of freedom
## Multiple R-squared: 0.2156, Adjusted R-squared: 0.1575
## F-statistic: 3.711 on 2 and 27 DF, p-value: 0.03767
##
## AIC and BIC values for the model:
## AIC BIC
## 1 -100.898 -95.29319
checkresiduals(rmodel1$model)
##
## Breusch-Godfrey test for serial correlation of order up to 6
##
## data: Residuals
## LM test = 9.6735, df = 6, p-value = 0.1391
vif(rmodel1$model)
## x.t x.1
## 1.023917 1.023917
rmodel2 = polyDlm(x = as.vector(Rain) , y = as.vector(RBOTS) , q = 1 , k = 1 , show.beta = TRUE)
## Estimates and t-tests for beta coefficients:
## Estimate Std. Error t value P(>|t|)
## beta.0 0.0420 0.0206 2.04 0.0505
## beta.1 0.0303 0.0206 1.47 0.1520
summary(rmodel2)
##
## Call:
## "Y ~ (Intercept) + X.t"
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.105903 -0.024178 -0.006166 0.014773 0.099699
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.56594 0.06397 8.847 1.84e-09 ***
## z.t0 0.04199 0.02058 2.040 0.0512 .
## z.t1 -0.01167 0.03126 -0.373 0.7117
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.04153 on 27 degrees of freedom
## Multiple R-squared: 0.2156, Adjusted R-squared: 0.1575
## F-statistic: 3.711 on 2 and 27 DF, p-value: 0.03767
checkresiduals(rmodel2$model)
##
## Breusch-Godfrey test for serial correlation of order up to 6
##
## data: Residuals
## LM test = 9.6735, df = 6, p-value = 0.1391
vif(rmodel2$model)
## z.t0 z.t1
## 2.359937 2.359937
rmodel3 = koyckDlm(x = as.vector(Rain) , y = as.vector(RBOTS))
summary(rmodel3,diagnostics=TRUE)
##
## Call:
## "Y ~ (Intercept) + Y.1 + X.t"
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.3665 -0.4155 -0.1142 0.3241 1.6012
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.3207 2.4302 0.132 0.896
## Y.1 -6.5147 243.8216 -0.027 0.979
## X.t 2.2101 76.0635 0.029 0.977
##
## Residual standard error: 0.7951 on 27 degrees of freedom
## Multiple R-Squared: -286.5, Adjusted R-squared: -307.8
## Wald test: 0.01549 on 2 and 27 DF, p-value: 0.9846
##
## Diagnostic tests:
## df1 df2 statistic p-value
## Weak instruments 1 27 0.0008275768 0.9772615
## Wu-Hausman 1 26 0.3602689549 0.5535531
##
## alpha beta phi
## Geometric coefficients: 0.04267914 2.21011 -6.514689
checkresiduals(rmodel3$model)
vif(rmodel3$model)
## Y.1 X.t
## 5531.807 5531.807
#Checking p and q vales on basis fo AIC and BIC
for (i in 1:5){
for(j in 1:5){
model4 = ardlDlm(x = as.vector(Rain) , y = as.vector(RBOTS), p = i , q = j )
cat("p = ", i, "q = ", j, "AIC = ", AIC(model4$model), "BIC = ", BIC(model4$model),"\n")
}
}
## p = 1 q = 1 AIC = -105.2619 BIC = -98.25588
## p = 1 q = 2 AIC = -103.3681 BIC = -95.16429
## p = 1 q = 3 AIC = -106.9248 BIC = -97.59935
## p = 1 q = 4 AIC = -102.0678 BIC = -91.70114
## p = 1 q = 5 AIC = -95.80256 BIC = -84.47969
## p = 2 q = 1 AIC = -99.21505 BIC = -91.01127
## p = 2 q = 2 AIC = -101.4552 BIC = -91.88416
## p = 2 q = 3 AIC = -104.9284 BIC = -94.27076
## p = 2 q = 4 AIC = -100.0892 BIC = -88.4267
## p = 2 q = 5 AIC = -93.80342 BIC = -81.22246
## p = 3 q = 1 AIC = -102.0287 BIC = -92.70325
## p = 3 q = 2 AIC = -106.4754 BIC = -95.8178
## p = 3 q = 3 AIC = -105.1996 BIC = -93.2098
## p = 3 q = 4 AIC = -99.66585 BIC = -86.70748
## p = 3 q = 5 AIC = -93.30294 BIC = -79.46387
## p = 4 q = 1 AIC = -96.40802 BIC = -86.04133
## p = 4 q = 2 AIC = -100.4881 BIC = -88.82555
## p = 4 q = 3 AIC = -100.0049 BIC = -87.04657
## p = 4 q = 4 AIC = -98.96532 BIC = -84.71111
## p = 4 q = 5 AIC = -92.62017 BIC = -77.52301
## p = 5 q = 1 AIC = -93.55318 BIC = -82.23031
## p = 5 q = 2 AIC = -94.0473 BIC = -81.46633
## p = 5 q = 3 AIC = -93.91526 BIC = -80.0762
## p = 5 q = 4 AIC = -92.68035 BIC = -77.58319
## p = 5 q = 5 AIC = -90.68282 BIC = -74.32757
rmodel4 = ardlDlm(x = as.vector(Rain) , y = as.vector(RBOTS), p = 1 , q = 3 )
summary(rmodel4)
##
## Time series regression with "ts" data:
## Start = 4, End = 31
##
## Call:
## dynlm(formula = as.formula(model.text), data = data, start = 1)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.089117 -0.018820 0.001881 0.023063 0.039494
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.184586 0.114255 1.616 0.1204
## X.t 0.022068 0.016922 1.304 0.2057
## X.1 0.002395 0.017264 0.139 0.8909
## Y.1 0.254216 0.182738 1.391 0.1781
## Y.2 0.328851 0.173602 1.894 0.0714 .
## Y.3 0.081803 0.175168 0.467 0.6451
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.0315 on 22 degrees of freedom
## Multiple R-squared: 0.5443, Adjusted R-squared: 0.4408
## F-statistic: 5.256 on 5 and 22 DF, p-value: 0.002523
checkresiduals(rmodel4$model)
##
## Breusch-Godfrey test for serial correlation of order up to 9
##
## data: Residuals
## LM test = 10.906, df = 9, p-value = 0.2822
vif(rmodel4$model)
## X.t L(X.t, 1) L(y.t, 1) L(y.t, 2) L(y.t, 3)
## 1.198664 1.243901 1.970400 1.773383 1.812722
#selection of "q" value on basis of AIC and BIC for fitting of DLM model
for(i in 1:10){
model1 = dlm( x = as.vector(Rad) , y = as.vector(RBOTS), q = i )
cat("q = ", i, "AIC = ", AIC(model1$model), "BIC = ", BIC(model1$model),"\n")
}
## q = 1 AIC = -97.71113 BIC = -92.10634
## q = 2 AIC = -91.50708 BIC = -84.67061
## q = 3 AIC = -92.38658 BIC = -84.39335
## q = 4 AIC = -86.43017 BIC = -77.35931
## q = 5 AIC = -83.32223 BIC = -73.25746
## q = 6 AIC = -81.85403 BIC = -70.88414
## q = 7 AIC = -79.04997 BIC = -67.26943
## q = 8 AIC = -80.65686 BIC = -68.16642
## q = 9 AIC = -78.4524 BIC = -65.35989
## q = 10 AIC = -78.06879 BIC = -64.49
model1<- dlm(x = as.vector(Rad) , y = as.vector(RBOTS), q = 1)
summary(model1)
##
## Call:
## lm(formula = model.formula, data = design)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.072417 -0.030826 -0.001718 0.016681 0.100514
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.13698 0.34038 3.340 0.00246 **
## x.t -0.04431 0.02234 -1.983 0.05764 .
## x.1 0.01689 0.02216 0.762 0.45261
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.0438 on 27 degrees of freedom
## Multiple R-squared: 0.1277, Adjusted R-squared: 0.06311
## F-statistic: 1.977 on 2 and 27 DF, p-value: 0.1581
##
## AIC and BIC values for the model:
## AIC BIC
## 1 -97.71113 -92.10634
checkresiduals(model1$model)
##
## Breusch-Godfrey test for serial correlation of order up to 6
##
## data: Residuals
## LM test = 13.502, df = 6, p-value = 0.03573
vif(model1$model)
## x.t x.1
## 1.254578 1.254578
model2 = polyDlm(x = as.vector(Rad) , y = as.vector(RBOTS) , q = 1 , k = 1 , show.beta = TRUE)
## Estimates and t-tests for beta coefficients:
## Estimate Std. Error t value P(>|t|)
## beta.0 -0.0443 0.0223 -1.980 0.0569
## beta.1 0.0169 0.0222 0.762 0.4520
summary(model2)
##
## Call:
## "Y ~ (Intercept) + X.t"
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.072417 -0.030826 -0.001718 0.016681 0.100514
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.13698 0.34038 3.340 0.00246 **
## z.t0 -0.04431 0.02234 -1.983 0.05764 .
## z.t1 0.06119 0.03790 1.615 0.11802
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.0438 on 27 degrees of freedom
## Multiple R-squared: 0.1277, Adjusted R-squared: 0.06311
## F-statistic: 1.977 on 2 and 27 DF, p-value: 0.1581
checkresiduals(model2$model)
##
## Breusch-Godfrey test for serial correlation of order up to 6
##
## data: Residuals
## LM test = 13.502, df = 6, p-value = 0.03573
vif(model2$model)
## z.t0 z.t1
## 3.66991 3.66991
model3 = koyckDlm(x = as.vector(Rad) , y = as.vector(RBOTS))
summary(model3,diagnostics=TRUE)
##
## Call:
## "Y ~ (Intercept) + Y.1 + X.t"
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.082255 -0.017008 -0.001036 0.021424 0.106984
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.48011 0.94819 -0.506 0.6167
## Y.1 0.69801 0.24502 2.849 0.0083 **
## X.t 0.04812 0.05661 0.850 0.4028
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.0467 on 27 degrees of freedom
## Multiple R-Squared: 0.008467, Adjusted R-squared: -0.06498
## Wald test: 4.731 on 2 and 27 DF, p-value: 0.01732
##
## Diagnostic tests:
## df1 df2 statistic p-value
## Weak instruments 1 27 4.941539 0.03478221
## Wu-Hausman 1 26 2.764873 0.10836470
##
## alpha beta phi
## Geometric coefficients: -1.589802 0.04811971 0.6980071
checkresiduals(model3$model)
vif(model3$model)
## Y.1 X.t
## 1.619594 1.619594
#Checking p and q vales on basis fo AIC and BIC
for (i in 1:5){
for(j in 1:5){
model4 = ardlDlm(x = as.vector(Rad) , y = as.vector(RBOTS), p = i , q = j )
cat("p = ", i, "q = ", j, "AIC = ", AIC(model4$model), "BIC = ", BIC(model4$model),"\n")
}
}
## p = 1 q = 1 AIC = -107.5622 BIC = -100.5562
## p = 1 q = 2 AIC = -106.904 BIC = -98.70018
## p = 1 q = 3 AIC = -110.6338 BIC = -101.3084
## p = 1 q = 4 AIC = -105.7923 BIC = -95.42561
## p = 1 q = 5 AIC = -100.2033 BIC = -88.88038
## p = 2 q = 1 AIC = -100.8085 BIC = -92.60473
## p = 2 q = 2 AIC = -106.3664 BIC = -96.79529
## p = 2 q = 3 AIC = -109.7302 BIC = -99.07252
## p = 2 q = 4 AIC = -104.7047 BIC = -93.04219
## p = 2 q = 5 AIC = -98.98255 BIC = -86.40158
## p = 3 q = 1 AIC = -104.0823 BIC = -94.75685
## p = 3 q = 2 AIC = -109.5259 BIC = -98.8683
## p = 3 q = 3 AIC = -108.3733 BIC = -96.38349
## p = 3 q = 4 AIC = -102.9405 BIC = -89.98212
## p = 3 q = 5 AIC = -97.36077 BIC = -83.5217
## p = 4 q = 1 AIC = -99.86384 BIC = -89.49714
## p = 4 q = 2 AIC = -103.3431 BIC = -91.6806
## p = 4 q = 3 AIC = -101.9438 BIC = -88.98546
## p = 4 q = 4 AIC = -100.979 BIC = -86.72481
## p = 4 q = 5 AIC = -95.51106 BIC = -80.4139
## p = 5 q = 1 AIC = -96.72745 BIC = -85.40458
## p = 5 q = 2 AIC = -96.91278 BIC = -84.33182
## p = 5 q = 3 AIC = -95.91334 BIC = -82.07428
## p = 5 q = 4 AIC = -94.72831 BIC = -79.63116
## p = 5 q = 5 AIC = -93.6481 BIC = -77.29285
model4 = ardlDlm(x = as.vector(Rad) , y = as.vector(RBOTS), p = 1 , q = 3 )
summary(model4)
##
## Time series regression with "ts" data:
## Start = 4, End = 31
##
## Call:
## dynlm(formula = as.formula(model.text), data = data, start = 1)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.06308 -0.01905 0.00578 0.01710 0.05139
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.05413 0.32389 0.167 0.8688
## X.t -0.02521 0.01588 -1.588 0.1266
## X.1 0.03255 0.01559 2.087 0.0487 *
## Y.1 0.35973 0.16351 2.200 0.0386 *
## Y.2 0.35620 0.15889 2.242 0.0354 *
## Y.3 0.05924 0.16656 0.356 0.7255
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.02948 on 22 degrees of freedom
## Multiple R-squared: 0.6009, Adjusted R-squared: 0.5101
## F-statistic: 6.624 on 5 and 22 DF, p-value: 0.0006674
checkresiduals(model4$model)
##
## Breusch-Godfrey test for serial correlation of order up to 9
##
## data: Residuals
## LM test = 12.329, df = 9, p-value = 0.1954
vif(model4$model)
## X.t L(X.t, 1) L(y.t, 1) L(y.t, 2) L(y.t, 3)
## 1.394354 1.345667 1.801101 1.696038 1.870970
#selection of "q" value on basis of AIC and BIC for fitting of DLM model
for(i in 1:10){
model1 = dlm( x = as.vector(Humid) , y = as.vector(RBOTS), q = i )
cat("q = ", i, "AIC = ", AIC(model1$model), "BIC = ", BIC(model1$model),"\n")
}
## q = 1 AIC = -98.90083 BIC = -93.29604
## q = 2 AIC = -94.63327 BIC = -87.79679
## q = 3 AIC = -93.20827 BIC = -85.21504
## q = 4 AIC = -86.75196 BIC = -77.6811
## q = 5 AIC = -84.46252 BIC = -74.39775
## q = 6 AIC = -79.22764 BIC = -68.25775
## q = 7 AIC = -78.33745 BIC = -66.55691
## q = 8 AIC = -77.57454 BIC = -65.0841
## q = 9 AIC = -78.44362 BIC = -65.35111
## q = 10 AIC = -77.84443 BIC = -64.26564
hmodel1<- dlm(x = as.vector(Humid) , y = as.vector(RBOTS), q = 1)
summary(hmodel1)
##
## Call:
## lm(formula = model.formula, data = design)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.088341 -0.023485 -0.006231 0.013353 0.089618
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.081999 0.381422 -0.215 0.8314
## x.t 0.011209 0.005944 1.886 0.0701 .
## x.1 0.003979 0.005980 0.665 0.5114
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.04294 on 27 degrees of freedom
## Multiple R-squared: 0.1616, Adjusted R-squared: 0.09953
## F-statistic: 2.603 on 2 and 27 DF, p-value: 0.09254
##
## AIC and BIC values for the model:
## AIC BIC
## 1 -98.90083 -93.29604
checkresiduals(hmodel1$model)
##
## Breusch-Godfrey test for serial correlation of order up to 6
##
## data: Residuals
## LM test = 11.783, df = 6, p-value = 0.067
vif(hmodel1$model)
## x.t x.1
## 1.097051 1.097051
hmodel2 = polyDlm(x = as.vector(Humid) , y = as.vector(RBOTS) , q = 1 , k = 1 , show.beta = TRUE)
## Estimates and t-tests for beta coefficients:
## Estimate Std. Error t value P(>|t|)
## beta.0 0.01120 0.00594 1.890 0.0694
## beta.1 0.00398 0.00598 0.665 0.5110
summary(hmodel2)
##
## Call:
## "Y ~ (Intercept) + X.t"
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.088341 -0.023485 -0.006231 0.013353 0.089618
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.081999 0.381422 -0.215 0.8314
## z.t0 0.011209 0.005944 1.886 0.0701 .
## z.t1 -0.007229 0.009604 -0.753 0.4581
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.04294 on 27 degrees of freedom
## Multiple R-squared: 0.1616, Adjusted R-squared: 0.09953
## F-statistic: 2.603 on 2 and 27 DF, p-value: 0.09254
checkresiduals(hmodel2$model)
##
## Breusch-Godfrey test for serial correlation of order up to 6
##
## data: Residuals
## LM test = 11.783, df = 6, p-value = 0.067
vif(hmodel2$model)
## z.t0 z.t1
## 2.829767 2.829767
hmodel3 = koyckDlm(x = as.vector(Humid) , y = as.vector(RBOTS))
summary(hmodel3,diagnostics=TRUE)
##
## Call:
## "Y ~ (Intercept) + Y.1 + X.t"
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.081436 -0.017779 -0.005166 0.019919 0.101789
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.215367 1.204579 0.179 0.8594
## Y.1 0.548465 0.290591 1.887 0.0699 .
## X.t 0.002164 0.025588 0.085 0.9332
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.03795 on 27 degrees of freedom
## Multiple R-Squared: 0.3452, Adjusted R-squared: 0.2967
## Wald test: 6.62 on 2 and 27 DF, p-value: 0.004576
##
## Diagnostic tests:
## df1 df2 statistic p-value
## Weak instruments 1 27 1.19587955 0.2838077
## Wu-Hausman 1 26 0.04541097 0.8329122
##
## alpha beta phi
## Geometric coefficients: 0.4769667 0.002164239 0.5484653
checkresiduals(hmodel3$model)
vif(hmodel3$model)
## Y.1 X.t
## 3.449396 3.449396
#Checking p and q vales on basis fo AIC and BIC
for (i in 1:5){
for(j in 1:5){
model4 = ardlDlm(x = as.vector(Humid) , y = as.vector(RBOTS), p = i , q = j )
cat("p = ", i, "q = ", j, "AIC = ", AIC(model4$model), "BIC = ", BIC(model4$model),"\n")
}
}
## p = 1 q = 1 AIC = -105.5243 BIC = -98.51828
## p = 1 q = 2 AIC = -105.4814 BIC = -97.27767
## p = 1 q = 3 AIC = -108.3405 BIC = -99.01504
## p = 1 q = 4 AIC = -103.6137 BIC = -93.24697
## p = 1 q = 5 AIC = -97.27466 BIC = -85.95179
## p = 2 q = 1 AIC = -100.142 BIC = -91.93822
## p = 2 q = 2 AIC = -103.7809 BIC = -94.20985
## p = 2 q = 3 AIC = -106.5199 BIC = -95.86225
## p = 2 q = 4 AIC = -101.6346 BIC = -89.97207
## p = 2 q = 5 AIC = -95.28529 BIC = -82.70433
## p = 3 q = 1 AIC = -103.6086 BIC = -94.28315
## p = 3 q = 2 AIC = -109.1887 BIC = -98.53104
## p = 3 q = 3 AIC = -107.2029 BIC = -95.21302
## p = 3 q = 4 AIC = -101.3096 BIC = -88.35125
## p = 3 q = 5 AIC = -95.58362 BIC = -81.74456
## p = 4 q = 1 AIC = -99.05124 BIC = -88.68455
## p = 4 q = 2 AIC = -102.3928 BIC = -90.73025
## p = 4 q = 3 AIC = -100.4041 BIC = -87.44573
## p = 4 q = 4 AIC = -99.33532 BIC = -85.08111
## p = 4 q = 5 AIC = -93.59832 BIC = -78.50116
## p = 5 q = 1 AIC = -97.08049 BIC = -85.75762
## p = 5 q = 2 AIC = -97.18983 BIC = -84.60887
## p = 5 q = 3 AIC = -95.23858 BIC = -81.39952
## p = 5 q = 4 AIC = -94.25778 BIC = -79.16063
## p = 5 q = 5 AIC = -92.45536 BIC = -76.1001
hmodel4 = ardlDlm(x = as.vector(Humid) , y = as.vector(RBOTS), p = 1 , q = 3 )
summary(hmodel4)
##
## Time series regression with "ts" data:
## Start = 4, End = 31
##
## Call:
## dynlm(formula = as.formula(model.text), data = data, start = 1)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.077853 -0.014823 0.002109 0.019009 0.048138
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.020314 0.286479 0.071 0.9441
## X.t 0.007887 0.004776 1.651 0.1129
## X.1 -0.004519 0.004829 -0.936 0.3595
## Y.1 0.318874 0.178846 1.783 0.0884 .
## Y.2 0.413758 0.173886 2.379 0.0264 *
## Y.3 -0.012091 0.184465 -0.066 0.9483
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.03071 on 22 degrees of freedom
## Multiple R-squared: 0.5668, Adjusted R-squared: 0.4683
## F-statistic: 5.757 on 5 and 22 DF, p-value: 0.001524
checkresiduals(hmodel4$model)
##
## Breusch-Godfrey test for serial correlation of order up to 9
##
## data: Residuals
## LM test = 15.789, df = 9, p-value = 0.07141
vif(hmodel4$model)
## X.t L(X.t, 1) L(y.t, 1) L(y.t, 2) L(y.t, 3)
## 1.328921 1.361798 1.985252 1.871456 2.114492
dynlm1 =dynlm(RBOTS ~ Temp)
summary(dynlm1)
##
## Time series regression with "ts" data:
## Start = 1984, End = 2014
##
## Call:
## dynlm(formula = RBOTS ~ Temp)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.100137 -0.026692 -0.003905 0.016193 0.080467
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.20230 0.23459 5.125 1.79e-05 ***
## Temp -0.02370 0.01196 -1.981 0.0572 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.04258 on 29 degrees of freedom
## Multiple R-squared: 0.1192, Adjusted R-squared: 0.08879
## F-statistic: 3.923 on 1 and 29 DF, p-value: 0.05717
dynlm2 =dynlm(RBOTS ~ Temp+L(RBOTS , k = 1 ))
summary(dynlm2)
##
## Time series regression with "ts" data:
## Start = 1985, End = 2014
##
## Call:
## dynlm(formula = RBOTS ~ Temp + L(RBOTS, k = 1))
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.091435 -0.013818 -0.003589 0.023750 0.092882
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.56889 0.30225 1.882 0.07063 .
## Temp -0.01074 0.01189 -0.904 0.37423
## L(RBOTS, k = 1) 0.51328 0.16873 3.042 0.00518 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.03807 on 27 degrees of freedom
## Multiple R-squared: 0.3409, Adjusted R-squared: 0.292
## F-statistic: 6.982 on 2 and 27 DF, p-value: 0.003598
dynlm3 =dynlm(RBOTS ~ Temp+trend(RBOTS))
summary(dynlm3)
##
## Time series regression with "ts" data:
## Start = 1984, End = 2014
##
## Call:
## dynlm(formula = RBOTS ~ Temp + trend(RBOTS))
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.082815 -0.023534 -0.004804 0.029669 0.068066
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.8026438 0.2524928 3.179 0.00359 **
## Temp -0.0010853 0.0133258 -0.081 0.93567
## trend(RBOTS) -0.0027184 0.0009523 -2.854 0.00803 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.03814 on 28 degrees of freedom
## Multiple R-squared: 0.3177, Adjusted R-squared: 0.269
## F-statistic: 6.519 on 2 and 28 DF, p-value: 0.004737
dynlm4 =dynlm(RBOTS ~ Temp+trend(RBOTS)+L(RBOTS , k = 1)+L(RBOTS , k = 2)+L(RBOTS , k = 3))
summary(dynlm4)
##
## Time series regression with "ts" data:
## Start = 1987, End = 2014
##
## Call:
## dynlm(formula = RBOTS ~ Temp + trend(RBOTS) + L(RBOTS, k = 1) +
## L(RBOTS, k = 2) + L(RBOTS, k = 3))
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.075233 -0.020898 0.003138 0.018987 0.056829
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.0996643 0.3353192 0.297 0.769
## Temp 0.0063957 0.0134005 0.477 0.638
## trend(RBOTS) -0.0006534 0.0011236 -0.582 0.567
## L(RBOTS, k = 1) 0.2981579 0.1846133 1.615 0.121
## L(RBOTS, k = 2) 0.2674881 0.1914027 1.398 0.176
## L(RBOTS, k = 3) 0.1374601 0.2070579 0.664 0.514
##
## Residual standard error: 0.0324 on 22 degrees of freedom
## Multiple R-squared: 0.5178, Adjusted R-squared: 0.4083
## F-statistic: 4.726 on 5 and 22 DF, p-value: 0.004407
dynlm5 =dynlm(RBOTS ~ Rain)
summary(dynlm5)
##
## Time series regression with "ts" data:
## Start = 1984, End = 2014
##
## Call:
## dynlm(formula = RBOTS ~ Rain)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.094310 -0.027945 -0.003845 0.021733 0.102109
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.62656 0.04891 12.810 1.82e-13 ***
## Rain 0.04696 0.02039 2.303 0.0286 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.04171 on 29 degrees of freedom
## Multiple R-squared: 0.1546, Adjusted R-squared: 0.1255
## F-statistic: 5.304 on 1 and 29 DF, p-value: 0.02864
dynlm6 =dynlm(RBOTS ~ Rain+L(RBOTS , k = 1 )+L(RBOTS , k = 2))
summary(dynlm6)
##
## Time series regression with "ts" data:
## Start = 1986, End = 2014
##
## Call:
## dynlm(formula = RBOTS ~ Rain + L(RBOTS, k = 1) + L(RBOTS, k = 2))
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.090456 -0.020612 -0.001949 0.016953 0.096829
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.18747 0.12329 1.521 0.1409
## Rain 0.02482 0.01891 1.313 0.2011
## L(RBOTS, k = 1) 0.26689 0.18877 1.414 0.1698
## L(RBOTS, k = 2) 0.39771 0.17853 2.228 0.0351 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.03568 on 25 degrees of freedom
## Multiple R-squared: 0.4639, Adjusted R-squared: 0.3996
## F-statistic: 7.212 on 3 and 25 DF, p-value: 0.001201
dynlm7 =dynlm(RBOTS ~ Rain+trend(RBOTS))
summary(dynlm7)
##
## Time series regression with "ts" data:
## Start = 1984, End = 2014
##
## Call:
## dynlm(formula = RBOTS ~ Rain + trend(RBOTS))
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.097074 -0.023803 -0.000964 0.023903 0.070110
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.6919225 0.0457877 15.112 5.42e-15 ***
## Rain 0.0362865 0.0176537 2.055 0.04927 *
## trend(RBOTS) -0.0025034 0.0007251 -3.452 0.00178 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.03555 on 28 degrees of freedom
## Multiple R-squared: 0.407, Adjusted R-squared: 0.3647
## F-statistic: 9.61 on 2 and 28 DF, p-value: 0.0006645
dynlm8 =dynlm(RBOTS ~ Rain+trend(RBOTS)+L(RBOTS , k = 1)+L(RBOTS , k = 2))
summary(dynlm8)
##
## Time series regression with "ts" data:
## Start = 1986, End = 2014
##
## Call:
## dynlm(formula = RBOTS ~ Rain + trend(RBOTS) + L(RBOTS, k = 1) +
## L(RBOTS, k = 2))
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.09606 -0.01641 -0.00338 0.01833 0.07448
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.3905672 0.1659227 2.354 0.0271 *
## Rain 0.0273343 0.0182292 1.499 0.1468
## trend(RBOTS) -0.0017407 0.0009953 -1.749 0.0931 .
## L(RBOTS, k = 1) 0.1425821 0.1948777 0.732 0.4715
## L(RBOTS, k = 2) 0.2791408 0.1845178 1.513 0.1434
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.0343 on 24 degrees of freedom
## Multiple R-squared: 0.5245, Adjusted R-squared: 0.4453
## F-statistic: 6.619 on 4 and 24 DF, p-value: 0.0009739
dynlm9 =dynlm(RBOTS ~ Rad)
summary(dynlm9)
##
## Time series regression with "ts" data:
## Start = 1984, End = 2014
##
## Call:
## dynlm(formula = RBOTS ~ Rad)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.082583 -0.030234 -0.007826 0.021558 0.101821
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.24888 0.28365 4.403 0.000133 ***
## Rad -0.03502 0.01943 -1.802 0.081918 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.04302 on 29 degrees of freedom
## Multiple R-squared: 0.1007, Adjusted R-squared: 0.06971
## F-statistic: 3.248 on 1 and 29 DF, p-value: 0.08192
dynlm10 =dynlm(RBOTS ~ Rad+L(RBOTS , k = 1 ))
summary(dynlm10)
##
## Time series regression with "ts" data:
## Start = 1985, End = 2014
##
## Call:
## dynlm(formula = RBOTS ~ Rad + L(RBOTS, k = 1))
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.084030 -0.017322 -0.005222 0.023849 0.102759
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.64415 0.32008 2.012 0.05424 .
## Rad -0.01977 0.01803 -1.097 0.28254
## L(RBOTS, k = 1) 0.51625 0.16320 3.163 0.00384 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.03781 on 27 degrees of freedom
## Multiple R-squared: 0.3499, Adjusted R-squared: 0.3017
## F-statistic: 7.266 on 2 and 27 DF, p-value: 0.002987
dynlm11 =dynlm(RBOTS ~ Rad+trend(RBOTS))
summary(dynlm11)
##
## Time series regression with "ts" data:
## Start = 1984, End = 2014
##
## Call:
## dynlm(formula = RBOTS ~ Rad + trend(RBOTS))
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.088606 -0.018923 -0.001001 0.027398 0.068343
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.1887042 0.2400592 4.952 3.16e-05 ***
## Rad -0.0280269 0.0165219 -1.696 0.10091
## trend(RBOTS) -0.0026165 0.0007345 -3.562 0.00134 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.03632 on 28 degrees of freedom
## Multiple R-squared: 0.3812, Adjusted R-squared: 0.3369
## F-statistic: 8.623 on 2 and 28 DF, p-value: 0.001208
dynlm12 =dynlm(RBOTS ~ Rad+trend(RBOTS)+L(RBOTS , k = 1)+L(RBOTS , k = 2))
summary(dynlm12)
##
## Time series regression with "ts" data:
## Start = 1986, End = 2014
##
## Call:
## dynlm(formula = RBOTS ~ Rad + trend(RBOTS) + L(RBOTS, k = 1) +
## L(RBOTS, k = 2))
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.087887 -0.016682 0.000003 0.020087 0.076572
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.64752 0.33681 1.923 0.0665 .
## Rad -0.01576 0.01697 -0.929 0.3623
## trend(RBOTS) -0.00164 0.00102 -1.608 0.1209
## L(RBOTS, k = 1) 0.20596 0.19236 1.071 0.2950
## L(RBOTS, k = 2) 0.26416 0.19092 1.384 0.1792
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.03524 on 24 degrees of freedom
## Multiple R-squared: 0.498, Adjusted R-squared: 0.4144
## F-statistic: 5.953 on 4 and 24 DF, p-value: 0.001786
dynlm13 =dynlm(RBOTS ~ Humid)
summary(dynlm13)
##
## Time series regression with "ts" data:
## Start = 1984, End = 2014
##
## Call:
## dynlm(formula = RBOTS ~ Humid)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.084681 -0.021582 -0.003647 0.015859 0.091872
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.063957 0.296865 0.215 0.8309
## Humid 0.012491 0.005501 2.271 0.0308 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.0418 on 29 degrees of freedom
## Multiple R-squared: 0.151, Adjusted R-squared: 0.1217
## F-statistic: 5.157 on 1 and 29 DF, p-value: 0.03076
dynlm14 =dynlm(RBOTS ~ Humid+L(RBOTS , k = 1 ))
summary(dynlm14)
##
## Time series regression with "ts" data:
## Start = 1985, End = 2014
##
## Call:
## dynlm(formula = RBOTS ~ Humid + L(RBOTS, k = 1))
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.085745 -0.017642 -0.003202 0.019514 0.096373
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.034334 0.267521 -0.128 0.89883
## Humid 0.007493 0.005169 1.450 0.15868
## L(RBOTS, k = 1) 0.497469 0.161246 3.085 0.00466 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.03722 on 27 degrees of freedom
## Multiple R-squared: 0.37, Adjusted R-squared: 0.3233
## F-statistic: 7.928 on 2 and 27 DF, p-value: 0.001956
dynlm15 =dynlm(RBOTS ~ Humid+trend(RBOTS))
summary(dynlm15)
##
## Time series regression with "ts" data:
## Start = 1984, End = 2014
##
## Call:
## dynlm(formula = RBOTS ~ Humid + trend(RBOTS))
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.087653 -0.023330 0.002706 0.026076 0.065329
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.3576746 0.2765722 1.293 0.2065
## Humid 0.0077618 0.0050517 1.536 0.1357
## trend(RBOTS) -0.0024098 0.0007709 -3.126 0.0041 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.03663 on 28 degrees of freedom
## Multiple R-squared: 0.3706, Adjusted R-squared: 0.3257
## F-statistic: 8.244 on 2 and 28 DF, p-value: 0.00153
dynlm16 =dynlm(RBOTS ~ Humid+trend(RBOTS)+L(RBOTS , k = 1)+L(RBOTS , k = 2))
summary(dynlm16)
##
## Time series regression with "ts" data:
## Start = 1986, End = 2014
##
## Call:
## dynlm(formula = RBOTS ~ Humid + trend(RBOTS) + L(RBOTS, k = 1) +
## L(RBOTS, k = 2))
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.09047 -0.02019 0.00245 0.01653 0.07206
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.0344287 0.3017285 -0.114 0.9101
## Humid 0.0079059 0.0048538 1.629 0.1164
## trend(RBOTS) -0.0013593 0.0009979 -1.362 0.1858
## L(RBOTS, k = 1) 0.1656612 0.1880673 0.881 0.3871
## L(RBOTS, k = 2) 0.3332244 0.1853998 1.797 0.0849 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.03403 on 24 degrees of freedom
## Multiple R-squared: 0.5317, Adjusted R-squared: 0.4537
## F-statistic: 6.814 on 4 and 24 DF, p-value: 0.0008202
dlmodels <- c("TModel1","RModel1","Model1","HModel1", "TModel2","RModel2" , "Model2", "HModel2", "TModel3", "RModel3", "Model3", "HModel3", "TModel4", "RModel4"
, "Model4", "HModel4")
dlaic <- c(AIC(tmodel1), AIC(rmodel1),AIC(model1),AIC(hmodel1), AIC(tmodel2), AIC(rmodel2), AIC(model2), AIC(hmodel2), AIC(tmodel3), AIC(rmodel3), AIC(model3), AIC(hmodel3), AIC(tmodel4), AIC(rmodel4), AIC(model4), AIC(hmodel4))
## [1] -97.52442
## [1] -100.898
## [1] -77.84443
## [1] -98.90083
## [1] -97.52442
## [1] -100.898
## [1] -97.71113
## [1] -98.90083
## [1] -98.54907
## [1] 76.22068
## [1] -93.8669
## [1] -106.3136
## [1] -109.2081
## [1] -106.9248
## [1] -92.45536
## [1] -108.3405
dlbic <- c(BIC(tmodel1), BIC(rmodel1),BIC(model1),BIC(hmodel1), BIC(tmodel2), BIC(rmodel2), BIC(model2), BIC(hmodel2), BIC(tmodel3), BIC(rmodel3), BIC(model3), BIC(hmodel3), BIC(tmodel4), BIC(rmodel4), BIC(model4), BIC(hmodel4))
## [1] -91.91963
## [1] -95.29319
## [1] -64.26564
## [1] -93.29604
## [1] -91.91963
## [1] -95.29319
## [1] -92.10634
## [1] -93.29604
## [1] -92.94428
## [1] 81.82547
## [1] -88.26211
## [1] -100.7088
## [1] -99.88269
## [1] -97.59935
## [1] -76.1001
## [1] -99.01504
dlMASE <- MASE(tmodel1, rmodel1,model1,hmodel1, tmodel2, rmodel2, model2, hmodel2, tmodel3, rmodel3, model3, hmodel3, tmodel4, rmodel4, model4, hmodel4)$MASE
dlaccuracy <- data.frame(dlmodels, dlMASE, dlaic, dlbic)
colnames(dlaccuracy) <- c("Model", "MASE", "AIC", "BIC")
dlaccuracy
## Model MASE AIC BIC
## 1 TModel1 1.0056219 -97.52442 -91.91963
## 2 RModel1 0.9417954 -100.89798 -95.29319
## 3 Model1 0.5947606 -77.84443 -64.26564
## 4 HModel1 0.9858746 -98.90083 -93.29604
## 5 TModel2 1.0056219 -97.52442 -91.91963
## 6 RModel2 0.9417954 -100.89798 -95.29319
## 7 Model2 1.0630293 -97.71113 -92.10634
## 8 HModel2 0.9858746 -98.90083 -93.29604
## 9 TModel3 0.9535116 -98.54907 -92.94428
## 10 RModel3 19.1057647 76.22068 81.82547
## 11 Model3 1.0314227 -93.86690 -88.26211
## 12 HModel3 0.8400135 -106.31363 -100.70884
## 13 TModel4 0.7734247 -109.20812 -99.88269
## 14 RModel4 0.8322089 -106.92478 -97.59935
## 15 Model4 0.7370787 -92.45536 -76.10010
## 16 HModel4 0.8196903 -108.34047 -99.01504
dynlms <- c("dynlm1", "dynlm2", "dynlm3", "dynlm4", "dynlm5", "dynlm6", "dynlm7","dynlm8","dynlm9","dynlm10","dynlm11", "dynlm12", "dynlm13", "dynlm14", "dynlm15", "dynlm16")
dyaic <- AIC(dynlm1, dynlm2, dynlm3, dynlm4, dynlm5, dynlm6, dynlm7,dynlm8,dynlm9,dynlm10,dynlm11, dynlm12, dynlm13, dynlm14, dynlm15, dynlm16)$AIC
dybic <- BIC(dynlm1, dynlm2, dynlm3, dynlm4, dynlm5, dynlm6, dynlm7,dynlm8,dynlm9,dynlm10,dynlm11, dynlm12, dynlm13, dynlm14, dynlm15, dynlm16)$BIC
dyMASE <- c( accuracy(dynlm1)[6],accuracy(dynlm2)[6], accuracy(dynlm3)[6], accuracy(dynlm4)[6], accuracy(dynlm5)[6], accuracy(dynlm6)[6], accuracy(dynlm7)[6],accuracy(dynlm8)[6],accuracy(dynlm9)[6],accuracy(dynlm10)[6],
accuracy(dynlm11)[6],accuracy(dynlm12)[6], accuracy(dynlm13)[6], accuracy(dynlm14)[6], accuracy(dynlm15)[6], accuracy(dynlm16)[6])
dyaccuracy <- data.frame(dynlms, dyMASE, dyaic, dybic)
colnames(dyaccuracy) <- c("dynlm", "MASE", "AIC", "BIC")
dyaccuracy
## dynlm MASE AIC BIC
## 1 dynlm1 0.9918512 -103.7910 -99.48900
## 2 dynlm2 0.8260073 -106.1170 -100.51222
## 3 dynlm3 0.9773604 -109.7089 -103.97298
## 4 dynlm4 0.8551711 -105.3429 -96.01751
## 5 dynlm5 1.0280987 -105.0648 -100.76286
## 6 dynlm6 0.8534979 -105.3293 -98.49280
## 7 dynlm7 0.8975563 -114.0582 -108.32224
## 8 dynlm8 0.8079738 -106.8075 -98.60374
## 9 dynlm9 1.0799582 -103.1484 -98.84641
## 10 dynlm10 0.8434230 -106.5304 -100.92563
## 11 dynlm11 0.9284587 -112.7342 -106.99826
## 12 dynlm12 0.8290288 -105.2343 -97.03055
## 13 dynlm13 1.0134082 -104.9311 -100.62914
## 14 dynlm14 0.8261181 -107.4719 -101.86713
## 15 dynlm15 0.9479550 -112.2109 -106.47492
## 16 dynlm16 0.8087777 -107.2511 -99.04733
#forecasting dataset
data.x <- read_csv("/Users/shubhamchougule/Downloads/Covariate x-values for Task 3 .csv")
## Parsed with column specification:
## cols(
## Year = col_double(),
## Temperature = col_double(),
## Rainfall = col_double(),
## Radiation = col_double(),
## RelHumidity = col_double()
## )
forecast_ts=ts(data.x)
dlmfore = forecast(model1, x = as.vector(forecast_ts) , h = 3)$forecasts
polfore = forecast(rmodel2, x = as.vector(forecast_ts) , h = 3)$forecasts
koyfore = forecast(hmodel3, x = as.vector(forecast_ts) , h = 3)$forecasts
arfore = forecast(model4, x = as.vector(forecast_ts) , h = 3)$forecasts
#Dynlm model forecasting
q = 3
n = nrow(dynlm8$model)
landings.frc = array(NA , (n + q))
landings.frc[1:n] = RBOTS[1:length(RBOTS)]
for (i in 1:q){
months = 1
months[(i-1)%%12] = 1
data.new = c(1,1,landings.frc[n-1+i],landings.frc[n-2+i],1)
landings.frc[n+i] = as.vector(dynlm8$coefficients) %*% data.new
}
dlm = c(RBOTS,dlmfore)
poly = c(RBOTS,polfore)
koyc = c(RBOTS,koyfore)
ard = c(RBOTS,arfore)
dynlm_forecast=ts(landings.frc[(n+1):(n+q)],start=2014,frequency = 1)
Dataforecast = ts.intersect(
ts(dlm,start=1984,frequency = 1),
ts(poly,start=1984,frequency = 1),
ts(koyc,start=1984,frequency = 1),
ts(ard,start=1984,frequency = 1),
ts(landings.frc[(n+1):(n+q)],start=2015,frequency = 1)
)
ts.plot(Dataforecast,xlim=c(2015,2017),
plot.type = c("single"), gpars= list(col=c("red","blue","gray","green","black")),
main = "Forecasting of next 3 years of RBO")
legend("bottomleft", col=c("red","blue","gray","green","black"), lty=1, cex=.65,c("DLM","Poly","Koyn","ARdlm","DYNLM"))
Task2db<-RBO[13:27,1:6]
head(Task2db)
## # A tibble: 6 x 6
## Year RBO Temperature Rainfall Radiation RelHumidity
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 1996 0.664 18.5 2.81 14.3 54.9
## 2 1997 0.694 19.8 1.40 14.8 52.0
## 3 1998 0.705 19.5 2.29 14.6 53.2
## 4 1999 0.699 20.0 2.13 14.6 54.1
## 5 2000 0.714 20.1 2.47 14.7 54.0
## 6 2001 0.727 19.7 2.23 14.1 54.6
Temp<-ts(Task2db$Temperature,start = 1996,frequency = 1)
Rain<-ts(Task2db$Rainfall,start = 1996,frequency = 1)
Rad<-ts(Task2db$Radiation,start = 1996,frequency = 1)
Humid<-ts(Task2db$RelHumidity,start = 1996,frequency = 1)
RBOTS<-ts(Task2db$RBO,start = 1996,frequency = 1)
#Model 1
dynlm1 =dynlm(RBOTS ~ Temp)
summary(dynlm1)
##
## Time series regression with "ts" data:
## Start = 1996, End = 2010
##
## Call:
## dynlm(formula = RBOTS ~ Temp)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.040545 -0.013890 0.003763 0.014788 0.038699
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.45298 0.21922 2.066 0.0593 .
## Temp 0.01272 0.01107 1.149 0.2712
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.02258 on 13 degrees of freedom
## Multiple R-squared: 0.09223, Adjusted R-squared: 0.0224
## F-statistic: 1.321 on 1 and 13 DF, p-value: 0.2712
dynlm2 =dynlm(RBOTS ~ Temp+L(RBOTS , k = 1 ))
summary(dynlm2)
##
## Time series regression with "ts" data:
## Start = 1997, End = 2010
##
## Call:
## dynlm(formula = RBOTS ~ Temp + L(RBOTS, k = 1))
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.041098 -0.008673 -0.003145 0.016689 0.036175
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.788699 0.301887 2.613 0.0241 *
## Temp 0.001432 0.015835 0.090 0.9295
## L(RBOTS, k = 1) -0.155292 0.280186 -0.554 0.5905
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.02215 on 11 degrees of freedom
## Multiple R-squared: 0.0286, Adjusted R-squared: -0.148
## F-statistic: 0.1619 on 2 and 11 DF, p-value: 0.8525
dynlm3 =dynlm(RBOTS ~ Temp+trend(RBOTS))
summary(dynlm3)
##
## Time series regression with "ts" data:
## Start = 1996, End = 2010
##
## Call:
## dynlm(formula = RBOTS ~ Temp + trend(RBOTS))
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.039780 -0.014380 0.002588 0.013622 0.032295
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.556973 0.252170 2.209 0.0474 *
## Temp 0.006915 0.013056 0.530 0.6060
## trend(RBOTS) 0.001372 0.001592 0.862 0.4057
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.02281 on 12 degrees of freedom
## Multiple R-squared: 0.1451, Adjusted R-squared: 0.002654
## F-statistic: 1.019 on 2 and 12 DF, p-value: 0.3903
dynlm4 =dynlm(RBOTS ~ Temp+trend(RBOTS)+L(RBOTS , k = 1)+L(RBOTS , k = 2)+L(RBOTS , k = 3))
summary(dynlm4)
##
## Time series regression with "ts" data:
## Start = 1999, End = 2010
##
## Call:
## dynlm(formula = RBOTS ~ Temp + trend(RBOTS) + L(RBOTS, k = 1) +
## L(RBOTS, k = 2) + L(RBOTS, k = 3))
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.026811 -0.013166 -0.007124 0.019887 0.030190
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.148498 0.748809 1.534 0.176
## Temp 0.011567 0.028569 0.405 0.700
## trend(RBOTS) 0.001859 0.003360 0.553 0.600
## L(RBOTS, k = 1) -0.595427 0.564965 -1.054 0.332
## L(RBOTS, k = 2) -0.390455 0.647824 -0.603 0.569
## L(RBOTS, k = 3) 0.017003 0.485661 0.035 0.973
##
## Residual standard error: 0.02705 on 6 degrees of freedom
## Multiple R-squared: 0.1777, Adjusted R-squared: -0.5076
## F-statistic: 0.2593 on 5 and 6 DF, p-value: 0.92
dynlm5 =dynlm(RBOTS ~ Rain)
summary(dynlm5)
##
## Time series regression with "ts" data:
## Start = 1996, End = 2010
##
## Call:
## dynlm(formula = RBOTS ~ Rain)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.04513 -0.01122 0.00177 0.01451 0.03646
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.720791 0.034840 20.689 2.48e-11 ***
## Rain -0.007307 0.015699 -0.465 0.649
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.02351 on 13 degrees of freedom
## Multiple R-squared: 0.01639, Adjusted R-squared: -0.05927
## F-statistic: 0.2167 on 1 and 13 DF, p-value: 0.6493
dynlm6 =dynlm(RBOTS ~ Rain+L(RBOTS , k = 1 )+L(RBOTS , k = 2))
summary(dynlm6)
##
## Time series regression with "ts" data:
## Start = 1998, End = 2010
##
## Call:
## dynlm(formula = RBOTS ~ Rain + L(RBOTS, k = 1) + L(RBOTS, k = 2))
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.044249 -0.011240 -0.001084 0.020540 0.027247
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.014667 0.397005 2.556 0.0309 *
## Rain -0.012545 0.024065 -0.521 0.6147
## L(RBOTS, k = 1) -0.390504 0.364633 -1.071 0.3121
## L(RBOTS, k = 2) -0.002585 0.287717 -0.009 0.9930
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.02288 on 9 degrees of freedom
## Multiple R-squared: 0.1203, Adjusted R-squared: -0.1729
## F-statistic: 0.4104 on 3 and 9 DF, p-value: 0.7495
dynlm7 =dynlm(RBOTS ~ Rain+trend(RBOTS))
summary(dynlm7)
##
## Time series regression with "ts" data:
## Start = 1996, End = 2010
##
## Call:
## dynlm(formula = RBOTS ~ Rain + trend(RBOTS))
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.04332 -0.01106 0.00120 0.01451 0.02742
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.706348 0.035593 19.845 1.53e-10 ***
## Rain -0.007313 0.015265 -0.479 0.641
## trend(RBOTS) 0.001807 0.001366 1.323 0.211
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.02286 on 12 degrees of freedom
## Multiple R-squared: 0.1416, Adjusted R-squared: -0.001506
## F-statistic: 0.9895 on 2 and 12 DF, p-value: 0.4002
dynlm8 =dynlm(RBOTS ~ Rain+trend(RBOTS)+L(RBOTS , k = 1)+L(RBOTS , k = 2))
summary(dynlm8)
##
## Time series regression with "ts" data:
## Start = 1998, End = 2010
##
## Call:
## dynlm(formula = RBOTS ~ Rain + trend(RBOTS) + L(RBOTS, k = 1) +
## L(RBOTS, k = 2))
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.037141 -0.012038 -0.004784 0.017665 0.027122
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.363149 0.544604 2.503 0.0368 *
## Rain -0.020721 0.025728 -0.805 0.4439
## trend(RBOTS) 0.002370 0.002517 0.942 0.3740
## L(RBOTS, k = 1) -0.611645 0.435673 -1.404 0.1980
## L(RBOTS, k = 2) -0.278949 0.412288 -0.677 0.5177
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.02303 on 8 degrees of freedom
## Multiple R-squared: 0.2081, Adjusted R-squared: -0.1878
## F-statistic: 0.5256 on 4 and 8 DF, p-value: 0.7206
dynlm9 =dynlm(RBOTS ~ Rad)
summary(dynlm9)
##
## Time series regression with "ts" data:
## Start = 1996, End = 2010
##
## Call:
## dynlm(formula = RBOTS ~ Rad)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.039995 -0.010736 0.001714 0.010843 0.039079
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.48166 0.24964 1.929 0.0758 .
## Rad 0.01512 0.01691 0.894 0.3875
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.02301 on 13 degrees of freedom
## Multiple R-squared: 0.05794, Adjusted R-squared: -0.01452
## F-statistic: 0.7996 on 1 and 13 DF, p-value: 0.3875
dynlm10 =dynlm(RBOTS ~ Rad+L(RBOTS , k = 1 ))
summary(dynlm10)
##
## Time series regression with "ts" data:
## Start = 1997, End = 2010
##
## Call:
## dynlm(formula = RBOTS ~ Rad + L(RBOTS, k = 1))
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.039517 -0.006923 -0.004026 0.014736 0.035965
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.705590 0.279579 2.524 0.0283 *
## Rad 0.008681 0.017644 0.492 0.6324
## L(RBOTS, k = 1) -0.179150 0.265470 -0.675 0.5137
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.02192 on 11 degrees of freedom
## Multiple R-squared: 0.04881, Adjusted R-squared: -0.1241
## F-statistic: 0.2822 on 2 and 11 DF, p-value: 0.7594
dynlm11 =dynlm(RBOTS ~ Rad+trend(RBOTS))
summary(dynlm11)
##
## Time series regression with "ts" data:
## Start = 1996, End = 2010
##
## Call:
## dynlm(formula = RBOTS ~ Rad + trend(RBOTS))
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.03941 -0.01178 0.00174 0.01299 0.03157
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.586056 0.268254 2.185 0.0495 *
## Rad 0.007196 0.018487 0.389 0.7039
## trend(RBOTS) 0.001566 0.001503 1.042 0.3181
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.02293 on 12 degrees of freedom
## Multiple R-squared: 0.1361, Adjusted R-squared: -0.007932
## F-statistic: 0.9449 on 2 and 12 DF, p-value: 0.4158
dynlm12 =dynlm(RBOTS ~ Rad+trend(RBOTS)+L(RBOTS , k = 1)+L(RBOTS , k = 2))
summary(dynlm12)
##
## Time series regression with "ts" data:
## Start = 1998, End = 2010
##
## Call:
## dynlm(formula = RBOTS ~ Rad + trend(RBOTS) + L(RBOTS, k = 1) +
## L(RBOTS, k = 2))
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.032087 -0.014729 -0.004137 0.018206 0.029665
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.986292 0.491423 2.007 0.0796 .
## Rad 0.009104 0.020128 0.452 0.6630
## trend(RBOTS) 0.001457 0.002485 0.586 0.5737
## L(RBOTS, k = 1) -0.442341 0.371210 -1.192 0.2676
## L(RBOTS, k = 2) -0.158698 0.391590 -0.405 0.6959
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.02364 on 8 degrees of freedom
## Multiple R-squared: 0.1652, Adjusted R-squared: -0.2521
## F-statistic: 0.3959 on 4 and 8 DF, p-value: 0.8065
dynlm13 =dynlm(RBOTS ~ Humid)
summary(dynlm13)
##
## Time series regression with "ts" data:
## Start = 1996, End = 2010
##
## Call:
## dynlm(formula = RBOTS ~ Humid)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.042833 -0.010511 0.001496 0.014237 0.038061
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.800619 0.245962 3.255 0.00627 **
## Humid -0.001795 0.004606 -0.390 0.70314
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.02357 on 13 degrees of freedom
## Multiple R-squared: 0.01154, Adjusted R-squared: -0.06449
## F-statistic: 0.1518 on 1 and 13 DF, p-value: 0.7031
dynlm14 =dynlm(RBOTS ~ Humid+L(RBOTS , k = 1 ))
summary(dynlm14)
##
## Time series regression with "ts" data:
## Start = 1997, End = 2010
##
## Call:
## dynlm(formula = RBOTS ~ Humid + L(RBOTS, k = 1))
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.041585 -0.008552 -0.003333 0.016449 0.036241
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 8.068e-01 3.493e-01 2.310 0.0413 *
## Humid 5.709e-05 4.689e-03 0.012 0.9905
## L(RBOTS, k = 1) -1.449e-01 2.681e-01 -0.540 0.5997
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.02216 on 11 degrees of freedom
## Multiple R-squared: 0.02789, Adjusted R-squared: -0.1489
## F-statistic: 0.1578 on 2 and 11 DF, p-value: 0.8559
dynlm15 =dynlm(RBOTS ~ Humid+trend(RBOTS))
summary(dynlm15)
##
## Time series regression with "ts" data:
## Start = 1996, End = 2010
##
## Call:
## dynlm(formula = RBOTS ~ Humid + trend(RBOTS))
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.040496 -0.012962 0.001976 0.014653 0.030204
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.7294588 0.2471365 2.952 0.0121 *
## Humid -0.0007261 0.0045848 -0.158 0.8768
## trend(RBOTS) 0.0017657 0.0014018 1.260 0.2318
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.02305 on 12 degrees of freedom
## Multiple R-squared: 0.127, Adjusted R-squared: -0.01853
## F-statistic: 0.8726 on 2 and 12 DF, p-value: 0.4428
dynlm16 =dynlm(RBOTS ~ Humid+trend(RBOTS)+L(RBOTS , k = 1)+L(RBOTS , k = 2))
summary(dynlm16)
##
## Time series regression with "ts" data:
## Start = 1998, End = 2010
##
## Call:
## dynlm(formula = RBOTS ~ Humid + trend(RBOTS) + L(RBOTS, k = 1) +
## L(RBOTS, k = 2))
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.031745 -0.012183 -0.004947 0.018221 0.029948
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.480535 0.738986 2.003 0.0801 .
## Humid -0.003987 0.006113 -0.652 0.5325
## trend(RBOTS) 0.001969 0.002440 0.807 0.4430
## L(RBOTS, k = 1) -0.557162 0.426170 -1.307 0.2274
## L(RBOTS, k = 2) -0.257793 0.418627 -0.616 0.5551
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.02333 on 8 degrees of freedom
## Multiple R-squared: 0.1871, Adjusted R-squared: -0.2193
## F-statistic: 0.4604 on 4 and 8 DF, p-value: 0.7634
dynlms <- c("dynlm1", "dynlm2", "dynlm3", "dynlm4", "dynlm5", "dynlm6", "dynlm7","dynlm8","dynlm9","dynlm10","dynlm11", "dynlm12", "dynlm13", "dynlm14", "dynlm15", "dynlm16")
dyaic <- AIC(dynlm1, dynlm2, dynlm3, dynlm4, dynlm5, dynlm6, dynlm7,dynlm8,dynlm9,dynlm10,dynlm11, dynlm12, dynlm13, dynlm14, dynlm15, dynlm16)$AIC
dybic <- BIC(dynlm1, dynlm2, dynlm3, dynlm4, dynlm5, dynlm6, dynlm7,dynlm8,dynlm9,dynlm10,dynlm11, dynlm12, dynlm13, dynlm14, dynlm15, dynlm16)$BIC
dyMASE <- c( accuracy(dynlm1)[6],accuracy(dynlm2)[6], accuracy(dynlm3)[6], accuracy(dynlm4)[6], accuracy(dynlm5)[6], accuracy(dynlm6)[6], accuracy(dynlm7)[6],accuracy(dynlm8)[6],accuracy(dynlm9)[6],accuracy(dynlm10)[6],
accuracy(dynlm11)[6],accuracy(dynlm12)[6], accuracy(dynlm13)[6], accuracy(dynlm14)[6], accuracy(dynlm15)[6], accuracy(dynlm16)[6])
dyaccuracy <- data.frame(dynlms, dyMASE, dyaic, dybic)
colnames(dyaccuracy) <- c("dynlm", "MASE", "AIC", "BIC")
dyaccuracy
## dynlm MASE AIC BIC
## 1 dynlm1 0.6554974 -67.29468 -65.17053
## 2 dynlm2 0.5839286 -62.32142 -59.76519
## 3 dynlm3 0.6343592 -66.19538 -63.36318
## 4 dynlm4 0.5730998 -46.90487 -43.51053
## 5 dynlm5 0.6406198 -66.09120 -63.96705
## 6 dynlm6 0.5473857 -56.09820 -53.27346
## 7 dynlm7 0.6287249 -66.13296 -63.30076
## 8 dynlm8 0.5613903 -55.46457 -52.07488
## 9 dynlm9 0.6193915 -66.73860 -64.61445
## 10 dynlm10 0.5821928 -62.61576 -60.05953
## 11 dynlm11 0.6197268 -66.03702 -63.20482
## 12 dynlm12 0.5771093 -54.77938 -51.38969
## 13 dynlm13 0.6435500 -66.01738 -63.89323
## 14 dynlm14 0.5843675 -62.31120 -59.75497
## 15 dynlm15 0.6336591 -65.88010 -63.04790
## 16 dynlm16 0.5741842 -55.12473 -51.73503
#Dynlm model forecasting
q = 4
n = nrow(dynlm6$model)
landings.frc = array(NA , (n + q))
landings.frc[1:n] = RBOTS[1:length(RBOTS)]
for (i in 1:q){
months = 1
months[(i-1)%%12] = 1
data.new = c(1,landings.frc[n-1+i],landings.frc[n-2+i],1)
landings.frc[n+i] = as.vector(dynlm6$coefficients) %*% data.new
}
Dataforecast = ts.intersect(
ts(landings.frc[(n+1):(n+q)],start=2010,frequency = 1)
)
ts.plot(Dataforecast,xlim=c(2010,2013),
plot.type = c("single"), gpars= list(col=c("black")),
main = "DYNLM Forecasting of next 3 years of RBO")