Cointegration, R, Irish Mortgage Debt and Property Prices
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
As a follow-up to my post examining the stationarity of the new property price index, this post will briefly look at some of the dynamics of mortgage debt and property prices; all data is monthly, from the beginning of 2005 to March 2011. This will also serve as an illustration of the ‘vars‘ and ‘urca‘ packages by Bernhard Pfaff, with relevant R code at the bottom of this post.
To begin, we look to the stationarity of each series. First, I transform the data by taking the (natural) log to help induce homoskedasticity and normally distributed errors, and for ease of interpretation as log changes approximate growth rates and are additive through time. One interesting feature I noted in the previous post was the apparent high order of integretion in the house price index, which carries over with the log transformation. (For those unfamiliar with this terminology: if a series is integrated of order, say, d we mean it is (asymptotically) stationary if differenced d times, denoted , where is the relevant time-series; stationary, in any context I refer to, implies weakly (or covariance) stationary, where the first and second moments of the distribution exist and are not a function of time.)
Augmented Dickey-Fuller (ADF) Tests:
Test Statistic: Debt | Test Statistic: Property | 1 Pct | 5 Pct | 10 Pct | |
-1.966106 | -3.427696 | -4.04 | -3.45 | -3.15 | |
-1.018575 | -1.220702 | -3.51 | -2.89 | -2.58 | |
-1.522126 | -1.255785 | -2.60 | -1.95 | -1.61 |
KPSS Tests:
Test Statistic: Debt | Test Statistic: Property | 1 Pct | 5 Pct | 10 Pct | No. Lags | |
1.0324562 | 0.9815038 | 0.739 | 0.463 | 0.347 | 3 | |
0.3906951 | 0.9815038 | 0.739 | 0.463 | 0.347 | 11 | |
0.4838172 | 0.9815038 | 0.216 | 0.146 | 0.119 | 3 | |
0.1903786 | 0.9815038 | 0.216 | 0.146 | 0.119 | 11 |
Analysing the first-differences of each series presents a messier picture:
ADF Tests:
Test Statistic: Debt | Test Statistic: Property | 1 Pct | 5 Pct | 10 Pct | |
-6.373145 | -1.9932346 | -4.04 | -3.45 | -3.15 | |
-1.335485 | -1.1632033 | -3.51 | -2.89 | -2.58 | |
-2.039878 | -0.7706823 | -2.60 | -1.95 | -1.61 |
KPSS Tests:
Test Statistic: Debt | Test Statistic: Property | 1 Pct | 5 Pct | 10 Pct | No. Lags | |
1.41975607 | 1.4547323 | 0.739 | 0.463 | 0.347 | 3 | |
0.64528772 | 0.5581214 | 0.739 | 0.463 | 0.347 | 11 | |
0.10741737 | 0.2283326 | 0.216 | 0.146 | 0.119 | 3 | |
0.09882218 | 0.1128649 | 0.216 | 0.146 | 0.119 | 11 |
If we proceed under the assumption that both series are , the question of cointegration naturally arises. Augmented Engle-Granger tests point to no cointegration, with a test statistic of -1.1410, but a cointegrating regression Durbin-Watson test rejects the null of no cointegration at the 5% significance level (DW stat: 0.7419, critical value: 0.38-0.72). Below is a scatter plot of the first-difference of each series,
Assuming there is a cointegrating relationship between the variables, , lag-order selection criteria from the ‘vars’ package implies an appropriate lag-order of 5, based on minimising the AIC and final prediction error (FPE). As our data only goes back to the beginning of 2005, degrees of freedom are an issue when estimating these models, and there is a trade-off against longer lag-order models due to the short sample size.
The Johansen procedure identifies a cointegrating rank, , of one (which is natural, as there are only two variables in the VAR),
Maximal Eigenvalue test:
Test Statistic | 1 Pct | 5 Pct | 10 Pct | |
2.74 | 7.52 | 9.24 | 12.97 | |
19.30 | 20.20 | 15.67 | 13.75 |
Trace test:
Test Statistic | 1 Pct | 5 Pct | 10 Pct | |
2.74 | 7.52 | 9.24 | 12.97 | |
22.04 | 24.60 | 19.96 | 17.85 |
The orthoganalised impulse response functions from the level-form of the vector error correction model are given below (click to make it larger):
(95% bootstrapped confidence intervals with 10,000 runs.) The first graph roughly shows what the effect of a one percentage point shock to mortgage debt will be on the national property price index over time. The second plot shows the effect on the mortgage debt level from a one percentage point shock to property prices. Here we can see the effect of deleveraging on asset prices, and the effect of falling asset prices on the amount of credit extended to households to purchase property.
R Code:
require(tseries) require(urca) require(vars) require(ggplot2) # a<-read.csv(file="Book1.csv") # Debt<-a[,4] Property<-a[,2] # debtts<-ts(Debt,start = c(2005, 1), end = c(2011, 3), frequency=12) propts<-ts(Property,start = c(2005, 1), end = c(2011, 3), frequency=12) # ddebtts<-diff(debtts) dpropts<-diff(propts) # ldebtts<-log(debtts) lpropts<-log(propts) # dldebtts<-diff(ldebtts) dlpropts<-diff(lpropts) # ddldebtts<-diff(dldebtts) ddlpropts<-diff(dlpropts) # ### ADF and KPSS Tests: summary(ur.df(lpropts,type="trend",lags = 12, selectlags="AIC")) summary(ur.df(lpropts,type="drift",lags = 12, selectlags="AIC")) summary(ur.df(lpropts,type="none",lags = 12, selectlags="AIC")) # summary(ur.kpss(lpropts,type="mu",lags="short")) summary(ur.kpss(lpropts,type="mu",lags="long")) summary(ur.kpss(lpropts,type="tau",lags="short")) summary(ur.kpss(lpropts,type="tau",lags="long")) # summary(ur.df(dlpropts,type="trend",lags = 12, selectlags="AIC")) summary(ur.df(dlpropts,type="drift",lags = 12, selectlags="AIC")) summary(ur.df(dlpropts,type="none",lags = 12, selectlags="AIC")) # summary(ur.kpss(dlpropts,type="mu",lags="short")) summary(ur.kpss(dlpropts,type="mu",lags="long")) summary(ur.kpss(dlpropts,type="tau",lags="short")) summary(ur.kpss(dlpropts,type="tau",lags="long")) # summary(ur.df(ldebtts,type="trend",lags = 12, selectlags="AIC")) summary(ur.df(ldebtts,type="drift",lags = 12, selectlags="AIC")) summary(ur.df(ldebtts,type="none",lags = 12, selectlags="AIC")) # summary(ur.kpss(ldebtts,type="mu",lags="short")) summary(ur.kpss(ldebtts,type="mu",lags="long")) summary(ur.kpss(ldebtts,type="tau",lags="short")) summary(ur.kpss(ldebtts,type="tau",lags="long")) # summary(ur.df(dldebtts,type="trend",lags = 12, selectlags="AIC")) summary(ur.df(dldebtts,type="drift",lags = 12, selectlags="AIC")) summary(ur.df(dldebtts,type="none",lags = 12, selectlags="AIC")) # summary(ur.kpss(dldebtts,type="mu",lags="short")) summary(ur.kpss(dldebtts,type="mu",lags="long")) summary(ur.kpss(dldebtts,type="tau",lags="short")) summary(ur.kpss(dldebtts,type="tau",lags="long")) # creg<-lm(dlpropts~dldebtts) dwtest(creg1) # # Scatter Plot DLDebt<-as.numeric(dldebtts) DLProperty<-as.numeric(dlpropts) scdata<-data.frame(DLDebt,DLProperty) # sc1.1<-ggplot(scdata,aes(DLDebt,DLProperty)) + xlab("FD Log Mortgage Debt") + ylab("FD Log National Property Prices") sc1.2<-sc1.1+geom_point(shape=18,colour="darkred", size=3) + opts(title="",plot.title = theme_text(size = 11),axis.title.y = theme_text(size = 8.5,angle = 90),axis.title.x = theme_text(size = 8.5)) sc1.3<- sc1.2 + geom_hline(yintercept=0,linetype=1,colour="black") + geom_vline(xintercept=0,linetype=1,colour="black") # png(filename = "scatter1.png", width = 500, height = 400, units = "px", pointsize = 12, bg = "white") sc1.3 dev.off() # ### Johansen Procedure: johandata<-data.frame(dldebtts,dlpropts) # VARselect(johandata, lag.max = 6, type="const") # johan3.1 <- ca.jo(johandata, ecdet = "const", type="eigen", K=5, spec="transitory",season=NULL) johan3.2 <- ca.jo(johandata, ecdet = "const", type="trace", K=5, spec="transitory",season=NULL) summary(johan3.1) summary(johan3.2) # ### VECM vecm31<-cajorls(johan3.1,r=1) summary(vecm31$rlm) # ### VEC2VAR vecvar3.1<-vec2var(johan3.1, r = 1) #logLik(vecvar3.1) # ### Orthogonalised IRFs irf1 <- irf(vecvar3.1, impulse = "dldebtts", response = "dlpropts",n.ahead = 25, boot = TRUE,ci=0.95,runs = 10000,seed=1234) irf1.prop<-ts(irf1$irf$dldebtts[,1]) irf1.prop.l<-irf1$Lower$dldebtts[,1] irf1.prop.u<-irf1$Upper$dldebtts[,1] # irf2 <- irf(vecvar3.1, impulse = "dlpropts", response = "dldebtts",n.ahead = 25, boot = TRUE,ci=0.95,runs = 10000,seed=1224) irf2.debt<-ts(irf2$irf$dlpropts[,1]) irf2.debt.l<-irf2$Lower$dlpropts[,1] irf2.debt.u<-irf2$Upper$dlpropts[,1] # ### Plotting the IRFs irf1.prop<-as.numeric(irf1.prop) irf2.debt<-as.numeric(irf2.debt) timet<-1:26 # df.irf<-data.frame(irf1.prop,irf1.prop.l,irf1.prop.u,irf2.debt,irf2.debt.l,irf2.debt.u) df.irf<- df.irf*100 df.irf<- data.frame(timet,df.irf) # ggirf1.1<-ggplot(df.irf,aes(timet)) + xlab("Months") + ylab("% Change in Property Price Index") ggirf1.2<-ggirf1.1 + geom_line(aes(y = irf1.prop, colour = "Property Price Index")) + geom_line(aes(y = irf1.prop.l, colour = "95% CI")) + geom_line(aes(y = irf1.prop.u, colour = "95% CI")) + scale_colour_hue("Series:") + opts(title=substitute(paste("IRF for ",Delta," Log(Property Price Index)"))) + opts(legend.position=c(.13,0.82)) #ggirf1.2 # ggirf2.1<-ggplot(df.irf,aes(timet)) + xlab("Months") + ylab("% Change in Mortgage Debt Index") ggirf2.2<-ggirf2.1 + geom_line(aes(y = irf2.debt, colour = "Mortgage Debt")) + geom_line(aes(y = irf2.debt.l, colour = "95% CI")) + geom_line(aes(y = irf2.debt.u, colour = "95% CI")) + scale_colour_hue("Series:") + opts(title=substitute(paste("IRF for ",Delta," Log(Mortgage Debt Index)"))) + opts(legend.position=c(.12,0.82)) #ggirf2.2 # png(filename = "irf1.png", width = 1000, height = 1000, units = "px", pointsize = 12, bg = "white") grid.newpage() pushViewport(viewport(layout=grid.layout(2,1))) vplayout<-function(x,y) viewport(layout.pos.row=x, layout.pos.col=y) print(ggirf1.2, vp = vplayout(1,1)) print(ggirf2.2, vp = vplayout(2,1)) dev.off() #
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.