# Example 6.1, Effects of Pollution on Housing Prices # Data set: hprice2 # Function for result reporting source("_report.R") # Load the data, standardize the variables and estimate the model load("hprice2.Rdata") data$zprice=(data$price-mean(data$price))/sd(data$price) data$znox=(data$nox-mean(data$nox))/sd(data$nox) data$zcrime=(data$crime-mean(data$crime))/sd(data$crime) data$zrooms=(data$rooms-mean(data$rooms))/sd(data$rooms) data$zdist=(data$dist-mean(data$dist))/sd(data$dist) data$zstratio=(data$stratio-mean(data$stratio))/sd(data$stratio) model=lm(zprice~znox+zcrime+zrooms+zdist+zstratio, data=data) dig=c(3,3,3,3,3,3,3) # Describe the model cat("This example use the housing price data set that was used in Example 4.5. Here we standardize the variables (compute their z-scores) in a level-level model, and estimate the beta coefficients on the standardized variables", "\nThe original level-level model is: price = beta0 + beta1 * nox + beta2 * crime + beta3 * rooms + beta4 * dist + beta5 * stratio + u", "\nwhere price is ", paste(desc[desc[,1]=="price",2]), "\nnox is ", paste(desc[desc[,1]=="nox",2]), "\ncrime is ", paste(desc[desc[,1]=="crime",2]), "\nrooms is ", paste(desc[desc[,1]=="rooms",2]), "\ndist is ", paste(desc[desc[,1]=="dist",2]), "\nand stratio is ", paste(desc[desc[,1]=="stratio",2]), "\nAfter standardization, the model to estimate is: zprice = beta0 + beta1 * znox + beta2 * zcrime + beta3 * zrooms + beta4 * zdist + beta5 * zstratio + u", sep="") # Report results { cat("The estimated regression line is") reportreg(model,dig) } # Interpretation cat("We know from the estimation result that, for example, a one standard deviation increase in nox decreases price by ", printabscoef(model,2,dig[2]), " standard deviation, and a one standard deviation increase in crime reduces price by ", printabscoef(model,3,dig[3]), " standard deviation. Such estimation of beta coefficients allows us to compare the effects of the same \"relative\" change in different independent variables", sep="")