# Example 4.4, Campus Crime and Enrollment
# Data set: campus
# Functions for result reporting
source("_report.R")
# Load the data and estimate the model in the background
load("campus.Rdata")
model=lm(lcrime~lenroll, data=data)
dig=c(2,2,3)
# Describe the model
cat("\nModel to estimate: lcrime = beta0 + beta1 * lenroll + u",
"\nwhere lcrime is ", paste(desc[desc[,1]=="lcrime",2]), " (crime: ", paste(desc[desc[,1]=="crime",2]),
")\nand lenroll is ", paste(desc[desc[,1]=="lenroll",2]), " (enroll: ", paste(desc[desc[,1]=="enroll",2]),
")", sep="")
# Report results
{
cat("The estimated regression line is")
reportreg(model,dig)
}
# Interpretation
cat("This is a constant elasticity model, where beta1 is the elasticity of crime with respect to enroll. It is not much use to test H0: beta1 = 0, as we expect the total number of crimes to increase as the campus size increases. It's more interesting to test H0: beta1 = 1, which means that a 1% increase in enroll leads to a 1% increase in predicted crime. The alternative canbe H1: beta1 > 1, which implies that a 1% increase in enroll increases predicted crime by more than 1%, i.e. crime is more of a problem on larger campuses, not just in an absolute sense, but a relative sense",
"\nWith df = ", nrow(model$model)-nrow(summary(model)$coef), ", the 1% critical value is 2.37. To test H0: beta1 = 1, we compute the t statistic as (",
printcoef(model,2,dig[2]), " - 1)/", printse(model,2,dig[2]), " = ",
round((as.numeric(printcoef(model,2,dig[2]))-1)/as.numeric(printse(model,2,dig[2])),2),
" > 2.37, so we reject H0 in favor of H1 at the 1% level, that is, beta1 is significantly larger than 1 at the 1% level",
"\nIt is noteworthy that the model does not hold any other factor constant, and hence may not be a good estimate of ceteris paribus effect. Controlling for other variables would make the conclusion more convincing",
sep="")