# Example 2.4, Wage and Education
# Data set: wage1
load("wage1.Rdata")
# Describe the model and summarize the variables
cat("Model to estimate: wage = beta0 + beta1 * educ + u",
"\n where wage is", paste(desc[desc[,1]=="wage",2]),
"\n and educ is", paste(desc[desc[,1]=="educ",2]))
summary(data$wage)
summary(data$educ)
# Estimate and show results
model=lm(wage~educ, data=data)
summary(model)
cat("The estimated regression line is\n",
"wagehat =", round(model$coefficients[1],digits=2), "+",
round(model$coefficients[2],digits=2), "* educ\n",
"n =", nrow(data))
# Interpretation
cat("When educ = 0, the predicted wage is the intercept, ", round(model$coefficients[1],digits=2),
", which makes no sense",
"\n This happens because the sample contains very few individuals with this level of education",
"\n When educ increases by 1 year, wage is predicted to increase by $",
round(model$coefficients[2],digits=2), sep="")