# Example 3.2, Hourly Wage Equation
# Data set: wage1
load("wage1.Rdata")
# Recap the simple regression
model=lm(lwage~educ, data=data)
cat("This example uses the wage data set that was used in Example 2.10\nIn the previous example, we estimated the model lwage = beta0 + beta1 * educ + u, where lwage is ",
paste(desc[desc[,1]=="lwage",2]), ", and educ is ", paste(desc[desc[,1]=="educ",2]),
"\nThe estimated regression line was\nlwagehat = ", round(model$coefficients[1],digits=3), " + ",
round(model$coefficients[2],digits=3), " * educ\n",
"n = ", nrow(data), sep="")
# Describe the multiple regression model
cat("In this example, two more independent variables are included in the model, that is exper (", paste(desc[desc[,1]=="exper",2]),
") and tenure (", paste(desc[desc[,1]=="tenure",2]), ")\n",
"Model to estimate: lwage = beta0 + beta1 * educ + beta2 * exper + beta3 * tenure + u",
sep="")
# Estimate and show results
model=lm(lwage~educ+exper+tenure, data=data)
summary(model)
cat("The estimated regression line is\n",
"lwagehat = ",
if(model$coefficients[1]>0) "" else "- ", abs(round(model$coefficients[1],digits=3)),
if(model$coefficients[2]>0) " + " else " - ", abs(round(model$coefficients[2],digits=3)), " * educ",
if(model$coefficients[3]>0) " + " else " - ", abs(round(model$coefficients[3],digits=4)), " * exper",
if(model$coefficients[4]>0) " + " else " - ", abs(round(model$coefficients[4],digits=3)), " * tenure\n",
"n = ", nrow(data), sep="")
# Interpretation
cat("The slope coefficients now have BOTH a percentage interpretation AND a ceteris paribus interpretation\n",
"For example, with exper and tenure held fixed, 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\n",
sep="")