# Example 2.10, A Log Wage Equation
# Data set: wage1
load("wage1.Rdata")
# Describe the model and summarize the variables
cat("This example uses the wage data set that was used in Example 2.4.\nHowever, the dependent variable is changed from wage to lwage, which is ",
paste(desc[desc[,1]=="lwage",2]), "\nThe independent variable is still educ, which is ",
paste(desc[desc[,1]=="educ",2]), "\nModel to estimate: lwage = beta0 + beta1 * educ + u",
sep="")
summary(data$lwage)
summary(data$educ)
# Estimate and show results
model=lm(lwage~educ, data=data)
summary(model)
cat("The estimated regression line is\n",
"lwagehat = ", round(model$coefficients[1],digits=3), " + ",
round(model$coefficients[2],digits=3), " * educ\n",
"n = ", nrow(data), ", R^2 = ", round(summary(model)$r.squared,digits=3), sep="")
# Interpretation
cat("The estimate of the slope coefficient indicates that when educ increases by 1 year, wage is predicted to increase by ",
100*round(model$coefficients[2],digits=3), " (= 100 * ", round(model$coefficients[2],digits=3),
") per cent. The value of lwage itself is of little concern",
"\nThe intercept, ", round(model$coefficients[1],digits=3),
", equals the predicted lwage when educ = 0, and is barely informative",
"\nThe R^2, ", round(summary(model)$r.squared,digits=3), ", indicates that educ explains ",
100*round(summary(model)$r.squared,digits=3), "% of the variation in lwage (not wage)",
sep="")