# Example 10.7, Housing Investment and Prices # 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) # Describe the model cat("Model to estimate: linvpc = beta0 + beta1 * lprice + u", "\nwhere linvpc is ", paste(desc[desc[,1]=="linvpc",2]), " (invpc: ", paste(desc[desc[,1]=="invpc",2]), ")", "\nand lprice is ", paste(desc[desc[,1]=="lprice",2]), " (price: ", paste(desc[desc[,1]=="price",2]), ")", sep="") # Report results { cat("The estimated regression line is") reportreg(model1,dig1,adj=T) } # Interpretation cat("The elasticity of invpc with respect to price is large in magnitude and statistically significant. However, it is important to note that both invpc and price have upward trends: regressing linvpc on t gives a slope coefficient of ", printcoef(lm(linvpc~t,data=data),2,4), " (standard error = ", printse(lm(linvpc~t,data=data),2,4), "), and regressing lprice on t gives a slope coefficient of ", printcoef(lm(lprice~t,data=data),2,4), " (standard error = ", printse(lm(lprice~t,data=data),2,4), ")", sep="") # Report results of second model { cat("To account for the trending behavior of the variables, we add a time trend. The estimated regression line is") reportreg(model2,dig2,adj=T) } # Interpretation cat("This time, the estimated elasticity is negative and not statistically significant. Instead, the coefficient on t is statistically significant, and implies an approximate ", 100*round(as.numeric(printcoef(model2,3,dig2[3])),2), "% increase in invpc every year. Based on this model, we cannot conclude that invpc is influenced by price. The results in the first model merely reflects the upward trend in both invpc and price over time", sep="")