the monthly data for Total Private Residential Construction Spending
library(Quandl)
## Loading required package: xts
## Loading required package: zoo
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
library(xts)
ps <- Quandl("FRED/PRRESCON", type="ts")
lps <- log(ps)
dlps1 <- diff(lps)
dlps1_2 <- diff(lps,12)
dlps1_2_1 <- diff(diff(lps,12))
par(mfrow=c(2,3))
plot(ps, main=expression(ps))
plot(lps, main=expression(log(ps)))
plot.new()
plot(dlps1, main=expression(paste(Delta, "log(ps)")))
plot(dlps1_2, main=expression(paste(Delta[12], "log(ps)")))
plot(dlps1_2_1, main=expression(paste(Delta, Delta[12], "log(ps)")))
library(forecast)
## Loading required package: timeDate
## This is forecast 7.3
maxlag <- 20
par(mfrow=c(2,4), max=c(3,3,4,2))
Acf(lps, type='correlation', lag=maxlag, na.action=na.omit, ylab="", main=expression(paste("ACF for lag(ps)")))
Acf(dlps1, type='correlation', lag=maxlag, na.action=na.omit, ylab="", main=expression(paste("ACF for",Delta," lag(ps)")))
Acf(dlps1_2, type='correlation',lag=maxlag, na.action=na.omit, ylab="", main=expression(paste("ACF for",Delta[12]," lag(ps)")))
Acf(dlps1_2_1, type='correlation',lag=maxlag, na.action=na.omit, ylab="", main=expression(paste("ACF for",Delta, Delta[12],"lag(ps)")))
Acf(lps, type='partial',lag=maxlag, na.action=na.omit, ylab="", main=expression(paste("PACF for lag(ps)")))
Acf(dlps1, type='partial',lag=maxlag, na.action=na.omit, ylab="", main=expression(paste("PACF for",Delta," lag(ps)")))
Acf(dlps1_2, type='partial',lag=maxlag, na.action=na.omit, ylab="", main=expression(paste("PACF for",Delta[12]," lag(ps)")))
Acf(dlps1_2_1, type='partial',lag=maxlag, na.action=na.omit, ylab="", main=expression(paste("PACF for",Delta,Delta[12]," lag(ps)")))
m1 <- Arima(dlps1, order = c(1,0,0), seasonal = list(order = c(1,0,0), period = 12))
m2 <- Arima(dlps1, order = c(1,1,0), seasonal = list(order = c(2,0,0), period = 12))
m3 <- Arima(dlps1, order = c(2,0,0), seasonal = list(order = c(1,0,0), period = 12))
m4 <- Arima(dlps1, order = c(2,0,0), seasonal = list(order = c(1,0,0), period = 12))
m5 <- Arima(dlps1, order = c(2,1,0), seasonal = list(order = c(1,0,0), period = 12))
m6 <- Arima(dlps1, order = c(2,0,1), seasonal = list(order = c(2,0,0), period = 12))
m7 <- Arima(dlps1, order = c(3,0,0), seasonal = list(order = c(1,0,0), period = 12))
m8 <- Arima(dlps1, order = c(3,1,0), seasonal = list(order = c(2,0,0), period = 12))
m9 <- Arima(dlps1, order = c(9,1,0), seasonal = list(order = c(1,0,0), period = 12))
m10<- Arima(dlps1, order = c(9,1,0), seasonal = list(order = c(0,1,0), period = 12))
m1
## Series: dlps1
## ARIMA(1,0,0)(1,0,0)[12] with non-zero mean
##
## Coefficients:
## ar1 sar1 intercept
## 0.5256 0.9715 0.0075
## s.e. 0.0500 0.0094 0.0426
##
## sigma^2 estimated as 0.0003718: log likelihood=712.63
## AIC=-1417.27 AICc=-1417.13 BIC=-1402.61
m2
## Series: dlps1
## ARIMA(1,1,0)(2,0,0)[12]
##
## Coefficients:
## ar1 sar1 sar2
## -0.4101 0.9132 0.0611
## s.e. 0.0569 0.0669 0.0680
##
## sigma^2 estimated as 0.0004105: log likelihood=695.67
## AIC=-1383.34 AICc=-1383.2 BIC=-1368.7
m3
## Series: dlps1
## ARIMA(2,0,0)(1,0,0)[12] with non-zero mean
##
## Coefficients:
## ar1 ar2 sar1 intercept
## 0.4164 0.2052 0.9716 0.0072
## s.e. 0.0576 0.0575 0.0093 0.0523
##
## sigma^2 estimated as 0.0003571: log likelihood=718.85
## AIC=-1427.7 AICc=-1427.48 BIC=-1409.38
m4
## Series: dlps1
## ARIMA(2,0,0)(1,0,0)[12] with non-zero mean
##
## Coefficients:
## ar1 ar2 sar1 intercept
## 0.4164 0.2052 0.9716 0.0072
## s.e. 0.0576 0.0575 0.0093 0.0523
##
## sigma^2 estimated as 0.0003571: log likelihood=718.85
## AIC=-1427.7 AICc=-1427.48 BIC=-1409.38
m5
## Series: dlps1
## ARIMA(2,1,0)(1,0,0)[12]
##
## Coefficients:
## ar1 ar2 sar1
## -0.4225 -0.0734 0.9736
## s.e. 0.0591 0.0595 0.0087
##
## sigma^2 estimated as 0.0004089: log likelihood=696.03
## AIC=-1384.05 AICc=-1383.91 BIC=-1369.42
m6
## Series: dlps1
## ARIMA(2,0,1)(2,0,0)[12] with non-zero mean
##
## Coefficients:
## ar1 ar2 ma1 sar1 sar2 intercept
## -0.385 0.5537 0.8844 0.8693 0.1041 0.0047
## s.e. 0.059 0.0489 0.0472 0.0645 0.0655 0.0441
##
## sigma^2 estimated as 0.0003469: log likelihood=723.42
## AIC=-1432.84 AICc=-1432.44 BIC=-1407.2
m7
## Series: dlps1
## ARIMA(3,0,0)(1,0,0)[12] with non-zero mean
##
## Coefficients:
## ar1 ar2 ar3 sar1 intercept
## 0.4316 0.2365 -0.0736 0.9701 0.0067
## s.e. 0.0588 0.0627 0.0594 0.0097 0.0472
##
## sigma^2 estimated as 0.0003572: log likelihood=719.61
## AIC=-1427.23 AICc=-1426.93 BIC=-1405.25
m8
## Series: dlps1
## ARIMA(3,1,0)(2,0,0)[12]
##
## Coefficients:
## ar1 ar2 ar3 sar1 sar2
## -0.4656 -0.1582 -0.1851 0.8744 0.1022
## s.e. 0.0616 0.0649 0.0594 0.0666 0.0678
##
## sigma^2 estimated as 0.0003966: log likelihood=701.18
## AIC=-1390.36 AICc=-1390.06 BIC=-1368.41
m9
## Series: dlps1
## ARIMA(9,1,0)(1,0,0)[12]
##
## Coefficients:
## ar1 ar2 ar3 ar4 ar5 ar6 ar7
## -0.4271 -0.1765 -0.2135 -0.1208 -0.0580 -0.0881 -0.2375
## s.e. 0.0590 0.0644 0.0643 0.0664 0.0663 0.0649 0.0641
## ar8 ar9 sar1
## 0.0158 -0.0486 0.9743
## s.e. 0.0662 0.0620 0.0088
##
## sigma^2 estimated as 0.0003785: log likelihood=710.15
## AIC=-1398.31 AICc=-1397.35 BIC=-1358.05
m10
## Series: dlps1
## ARIMA(9,1,0)(0,1,0)[12]
##
## Coefficients:
## ar1 ar2 ar3 ar4 ar5 ar6 ar7
## -0.4200 -0.1804 -0.2022 -0.0991 -0.0547 -0.0724 -0.2382
## s.e. 0.0604 0.0655 0.0651 0.0673 0.0672 0.0667 0.0660
## ar8 ar9
## 0.0356 -0.0338
## s.e. 0.0676 0.0626
##
## sigma^2 estimated as 0.0003818: log likelihood=696.2
## AIC=-1372.4 AICc=-1371.56 BIC=-1336.23
par(mar=c(1,1,1,1))
tsdiag(m1, gof.lag=36)
tsdiag(m2, gof.lag=36)
tsdiag(m3, gof.lag=36)
tsdiag(m4, gof.lag=36)
tsdiag(m5, gof.lag=36)
tsdiag(m6, gof.lag=36)
tsdiag(m7, gof.lag=36)
tsdiag(m8, gof.lag=36)
tsdiag(m9, gof.lag=36)
tsdiag(m10, gof.lag=36)
par(mfrow=c(2,3))
tsdiag(m6, gof.lag=36)
tsdiag(m9, gof.lag=36)
par(mfrow=c(2,3))
Box.test(residuals(m6),lag=24,type="Ljung")
##
## Box-Ljung test
##
## data: residuals(m6)
## X-squared = 30.104, df = 24, p-value = 0.1813
par(mar = rep(2, 4))
tsdiag(m6, gof.lag=24)
Box.test(residuals(m9),lag=24,type="Ljung")
##
## Box-Ljung test
##
## data: residuals(m9)
## X-squared = 34.725, df = 24, p-value = 0.07258
par(mar = rep(2, 4))
tsdiag(m9, gof.lag=24)
AIC | BIC | p-value | |
ARIMA(2,0,1)(2,0,0)[12] -1 | 432.84 -1 | 407.2 | 0.1813 |
ARIMA(9,1,0)(1,0,0)[12] -1 | 398.31 -1 | 358.05 | 0.07258 |
end.month <- 2013 + 11/12
pse <- window( ps, end = end.month)
psp <- window( ps, start = end.month + 1/12)
fst <- 1993-1 # 1993-01-01
lst <- 2017-1 # 2017-01-01
multiple<- forecast(m9, length(psp))
plot(multiple, type="o", pch=16, xlim=c(2013,2016), ylim=c(-0.03,0.03),
main="Multistep Forecasts: Total Private Construction Spending: Residential")
lines(multiple$mean, type="p", pch=16, lty="dashed", col="blue")
lines(dlps1, type="o", pch=16, lty="dashed")
m1.fcast <- forecast( m9, h=25)
plot(m1.fcast, type="o", pch=16, xlim=c(2013,2016), ylim=c(-0.03,0.03),
main=" Forecasts: Total Private Construction Spending: Residential")
lines(multiple$mean, type="l", pch=16, lty="dashed", col="blue")
lines(dlps1, type="l", pch=16, lty="dashed")
the ARIMA(9,1,0)(1,0,0)[12] has similar actual and forcasting data.