\(~\)

This lab will use data from a major US university that was assembled in response to an evaluation of salary disparities between male and female faculty at the university. The publicly released version of the data excludes any potentially identifying variables, and masks the department of each faculty member under the discipline categories “A” (departments deemed to be theoretical or part of the liberal arts) and “B” (departments deemed to be applied or business oriented).

fac_sal = read.csv("https://remiller1450.github.io/data/Salaries.csv")

The outcome variable in our analysis is Salary, the 9-month salary of the faculty member. There are several categorical predictors we will consider:

  • sex - whether the sex of the professor is male or female.
  • rank - either “AsstProf”, the lowest rank, “AssocProf”, an intermediate rank, or “Prof”, the highest rank.
  • discipline - whether the professor belongs to group “A” or “B” (see the description in the paragraph above)

Question #1: For this question you are to consider using one-hot encoding to represent the variable rank using a set of dummy variables.

  • Part A: How many dummy variables are required as part of this representation?
  • Part B: By default, R will use the first alphabetical category as the reference category when creating dummy variables. For these data, that is the “AssocProf” category. With this in mind, write out the form of the population-level linear regression model involving the dummy variables described in Part A.
  • Part C: Fit a linear regression model using the lm() function and the model formula salary ~ rank. Then use the summary() function to print a summary of the fitted model.
  • Part D: Interpret the intercept of the fitted model. What does this value tell you about the expected salary of the reference group?
  • Part E: Interpret the coefficient of the dummy variable rankAsstProf. What does this value you tell you about the mean faculty salaries at different ranks?
  • Part F: Lab 5 introduced grouped summarization using functions from the dplyr package. Use grouped summarization to find the mean salary for each rank. How do these means relate to the fitted model coefficients from Parts C-E?
  • Part G: Consider the null hypothesis that there is no difference in the mean faculty salaries of associate and assistant professors. Test this hypothesis using the summary of the fitted model you printed in Part C. Provide a 1-sentence conclusion including the \(p\)-value and observed difference in means.

\(~\)

Question #2: This question will focus on changing the reference category, which is useful to facilitate comparisons between different groups. Below we use the factor() function to overwrite an existing categorical variable with a new order of levels:

fac_sal$rank = factor(fac_sal$rank, levels = c("AsstProf", "AssocProf", "Prof"))
new_rank_model = lm(salary ~ rank, data = fac_sal)
summary(new_rank_model)
## 
## Call:
## lm(formula = salary ~ rank, data = fac_sal)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -68972 -16376  -1580  11755 104773 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      80776       2887  27.976  < 2e-16 ***
## rankAssocProf    13100       4131   3.171  0.00164 ** 
## rankProf         45996       3230  14.238  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 23630 on 394 degrees of freedom
## Multiple R-squared:  0.3943, Adjusted R-squared:  0.3912 
## F-statistic: 128.2 on 2 and 394 DF,  p-value: < 2.2e-16

Notice how the model’s intercept and coefficients have changed to reflect the new reference category, but the model’s predictions for each category are still the same (the group means you found in Question 1 Part F).

  • Part A: Fit a model using sex to predict salary and print a summary of the fitted model. Which category of sex was used as the reference group?
  • Part B: Use the model from Part A to find the expected average salary of faculty of each sex. Show your calculations.
  • Part C: Following the example from this section, use the factor() function to change the reference category to “Female” and refit the model from Part A using the modified data. How did the slope and intercept of this model change from Part A?
  • Part D: Use the model from Part C to find the expected average salary of faculty of each sex. Show your calculations.
  • Part E: Compare the \(p\)-values of the sexMale and sexFemale coefficients in the models from Part A and Part C. In your own words, explain why they are identical.
  • Part F: As you’ve now seen, the choice of reference category does not affect model predictions, but it does affect coefficient interpretations. What characteristics make a category useful as a reference group? For example, do you find “AsstProf” or “AssocProf” to be a more useful reference category? Briefly explain.