# Example 3.1, Determinants of College GPA
# Data set: gpa1
load("gpa1.Rdata")
# Describe the model
cat("Model to estimate: colGPA = beta0 + beta1 * hsGPA + beta2 * ACT + u",
"\nwhere colGPA is ", paste(desc[desc[,1]=="colGPA",2]),
",\nhsGPA is ", paste(desc[desc[,1]=="hsGPA",2]),
",\nand ACT is ", paste(desc[desc[,1]=="ACT",2]),
sep="")
# Estimate and show results
model=lm(colGPA~hsGPA+ACT, data=data)
summary(model)
cat("The estimated regression line is\n",
"colGPAhat = ",
if(model$coefficients[1]>0) "" else "- ", abs(round(model$coefficients[1],digits=2)),
if(model$coefficients[2]>0) " + " else " - ", abs(round(model$coefficients[2],digits=3)), " * hsGPA",
if(model$coefficients[3]>0) " + " else " - ", abs(round(model$coefficients[3],digits=4)), " * ACT\n",
"n = ", nrow(data), sep="")
# Interpretation
cat("The intercept, ", round(model$coefficients[1],digits=2), ", stands for the predicted colGPA when both hsGPA and ACT are zero, and is of little practical use\n",
"The two slope coefficients have partial effect / ceteris paribus interpretations:\n",
"With ACT held fixed, when hsGPA increases by 1 point, colGPA is predicted to increase by ", round(model$coefficients[2],digits=3), " point\n",
"With hsGPA held fixed, when ACT increases by 10 points, colGPA is predicted to increase by ", 10*round(model$coefficients[3],digits=4), " point, which is a tiny effect\n",
"Unlike a simple regression, this multiple regression allows us to compare two people, say, with the same high school GPA",
sep="")