# Example 10.10, Housing Investment
# Data set: hseinv
# Function for result reporting
source("_report.R")
# Load the data and estimate the models in the background
load("hseinv.Rdata")
data=ts(data,start=1947,frequency=1)
model1=lm(linvpc~lprice,data=data)
model2=lm(linvpc~lprice+t,data=data)
dig1=c(3,3,3)
dig2=c(3,3,4,3)
# Recap models
{
cat("This example closely follows Example 10.7. The two estimated regression lines in the previous example were")
reportreg(model1,dig1,adj=T)
cat("\nand")
reportreg(model2,dig2,adj=T)
}
# Interpretation
m0=lm(linvpc~t,data=data)
m1=lm(summary(m0)$residuals~lprice+t,data=data)
cat("The R^2 of the second regression seems to indicate that the equation is explaining ", 100*as.numeric(printr(model2,dig2[4])),
"% of the variation in linvpc. This is misleading. If we detrend linvpc first and regress the detrended variable on lprice and t, the R^2 will be a mere ",
printr(m1,3), ", and the adjusted R^2 is even negative (", printrbar(m1,3), "). That is, movements in lprice about its trend have virtually no explanatory power for movements in linvpc about its trend, which is consistent with the fact that the t statistic on lprice in the detrended model is as small as ",
printt(model2,2,dig2[2]),
sep="")