# Example 7.5, Log Hourly Wage Equation
# Data set: wage1
# Function for result reporting
source("_report.R")
# Load the data, create new variables and estimate the model
load("wage1.Rdata")
data$expersq=(data$exper)^2
data$tenuresq=(data$tenure)^2
model=lm(lwage~female+educ+exper+expersq+tenure+tenuresq,data=data)
dig=c(3,3,3,3,5,3,5,3)
# Describe the model
cat("This example uses the wage data set that was used in Example 7.1. In the previous example, we estimated the model: wage = beta0 + beta1 * female + beta2 * educ + beta3 * exper + beta4 * tenure + u",
"\nwhere wage is ", paste(desc[desc[,1]=="wage",2]),
"\nfemale is ", paste(desc[desc[,1]=="female",2]),
"\neduc is ", paste(desc[desc[,1]=="educ",2]),
"\nexper is ", paste(desc[desc[,1]=="exper",2]),
"\nand tenure is ", paste(desc[desc[,1]=="tenure",2]),
"\nIn this example, we change the dependent variable from wage to the log of wage, or lwage. We also add two new independent variables, expersq and tenure, which are the quadratic terms in exper and tenure. The new model to estimate is ",
"\n\tlwage = beta0 + beta1 * female + beta2 * educ + beta3 * exper + beta4 * expersq + beta5 * tenure + beta6 * tenuresq + u",
sep="")
# Report results
{
cat("The estimated regression line is")
reportreg(model,dig)
}
# Interpretation
cat("The coefficient on female, with a simple approximation, for the same levels of educ, exper, and tenure, women are precicted to earn about ",
100*as.numeric(printabscoef(model,2,dig[2])), "% less than man. We can also compute the exact percentage difference in predicted wages between men and women. From the regression result, we have",
"\n\tlwageFemalehat - lwageMalehat = ", printcoef(model,2,dig[2]), "\nHence,",
"\n\t(wageFemalehat - wageMalehat)/wageMalehat = exp(", printcoef(model,2,dig[2]), ") - 1 = ",
round(exp(as.numeric(printcoef(model,2,dig[2])))-1,3),
"\nThat is, the exact percentage difference in predicted wages is ",
100*abs(round(exp(as.numeric(printcoef(model,2,dig[2])))-1,3)), "%",
sep="")