# Example 2.7, Wage and Education
# Data set: wage1
load("wage1.Rdata")
# Recap the estimated model
model=lm(wage~educ, data=data)
cat("This example uses the wage data set that was used in Example 2.4.\nIn the previous example, we estimated the model wage = beta0 + beta1 * educ + u, where wage is ",
paste(desc[desc[,1]=="wage",2]), ", and educ is ", paste(desc[desc[,1]=="educ",2]),
"\nThe estimated regression line was\nwagehat = ", round(model$coefficients[1],digits=2), " + ",
round(model$coefficients[2],digits=2), " * educ\n",
"n = ", nrow(data), sep="")
# Show the rounding error
beta0=round(model$coefficients[1],digits=2)
beta1=round(model$coefficients[2],digits=2)
mwage=round(mean(data$wage),digits=2)
meduc=round(mean(data$educ),digits=2)
cat("In the sample, the average wage is ", mwage, ", and the average education is ", meduc,
"\nIf the average education is plugged into the estimated regression line, the resulting wagehat will equal ",
beta0, " + ", beta1, " * ", meduc, " = ", beta0+beta1*meduc,
", which equals 5.9 when rounded to the first decimal place",
"\nThis happens because the coefficient estimates were initially rounded. We can get a more accurate result by not rounding any of the values",
sep="")