# Example 3.4, Determinants of College GPA
# Data set: gpa1
load("gpa1.Rdata")
# Recap the model
model=lm(colGPA~hsGPA+ACT, data=data)
cat("This example uses the GPA data set that was used in Example 3.1\nIn the previous example, we estimated the model colGPA = beta0 + beta1 * hsGPA + beta2 * ACT + u, where colGPA is ",
paste(desc[desc[,1]=="colGPA",2]), ", hsGPA is ", paste(desc[desc[,1]=="hsGPA",2]), ", and ACT is ", paste(desc[desc[,1]=="ACT",2]),
"\nThe estimated regression line was\nlwagehat = ",
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), ", R^2 = ", round(summary(model)$r.squared,digits=3), sep="")
# Interpretation of R^2
cat("The R^2 indicates that hsGPA and ACT together explain about ", 100*round(summary(model)$r.squared,digits=3),
"% of the variation in colGPA. While this may not seem a large percentage, it is reasonable because many factors other than hsGPA and ACT also contribute to students' colGPA",
sep="")