Exercise 1: Is this an observational study or an experiment? The original research question posed in the paper is whether beauty leads directly to the differences in course evaluations. Given the study design, is it possible to answer this question as it is phrased? If not, rephrase the question.
Observational study. Not a randomized, fully controlled study, so not possible to answer the question as phrased.
Exercise 2: Describe the distribution of score. Is the distribution skewed? What does that tell you about how students rate courses? Is this what you expected to see? Why, or why not?
Exercise 3: Excluding score, select two other variables and describe their relationship using an appropriate visualization (scatterplot, side-by-side boxplots, or mosaic plot).
Somewhat normally distributed, but with a gap around 53-55 years, and another at approximately 66-68 years.
#rank
plot4 <- evals %>%ggplot(aes(x= bty_avg, y= rank, color = rank)) +geom_point() +ggtitle("Scatterplot of Prof Rank by Beauty Scores") +xlab("Average Beauty Scores Assessed by Students") +ylab("Average Professor Rank")plot4
All 3 ranks covered just about all the levels of beauty scores; however tenured had the most responses and was also the most normally distributed.
Simple linear regression
plot2 <- evals %>%ggplot(aes(x= bty_avg, y= score, color = gender)) +geom_point() +ggtitle("Scatterplot of Prof Scores by Beauty Scores") +xlab("Average Beauty Scores Assessed by Students") +ylab("Average Professor Evaluation Score")plot2
Exercise 4: Replot the scatterplot, but this time use the function jitter() on the y or the x coordinate. (Use ?jitter to learn more.) What was misleading about the initial scatterplot?
plot(jitter(evals$score) ~ evals$bty_avg)
The original scatterplot didn’t contain all of the data points that the jitter plot does. The original took points that are mostly overlapping and merged them.
Exercise 5: Let’s see if the apparent trend in the plot is something more than natural variation. Fit a linear model called m_bty to predict average professor score by average beauty rating and add the line to your plot using abline(m_bty). Write out the equation for the linear model and interpret the slope. Is average beauty score a statistically significant predictor? Does it appear to be a practically significant predictor?
plot2 <- evals %>%ggplot(aes(x= bty_avg, y= score, color = gender)) +geom_point() +geom_smooth(method="lm") +ggtitle("Scatterplot of Prof Scores by Beauty Scores") +xlab("Average Beauty Scores Assessed by Students") +ylab("Average Professor Evaluation Score")plot2
`geom_smooth()` using formula = 'y ~ x'
Exercise 6: Use residual plots to evaluate whether the conditions of least squares regression are reasonable. Provide plots and comments for each one (see the Simple Regression Lab for a reminder of how to make these).
plot6 <-lm(bty_avg ~ score, data = evals)summary(plot6)
Call:
lm(formula = bty_avg ~ score, data = evals)
Residuals:
Min 1Q Median 3Q Max
-2.7116 -1.2116 -0.2032 0.9328 4.2089
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 2.2237 0.5409 4.111 4.66e-05 ***
score 0.5256 0.1285 4.090 5.08e-05 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 1.502 on 461 degrees of freedom
Multiple R-squared: 0.03502, Adjusted R-squared: 0.03293
F-statistic: 16.73 on 1 and 461 DF, p-value: 5.083e-05
plot(evals$bty_avg ~ evals$score)abline(plot6)
Multiple Linear Regression
plot(evals$bty_avg ~ evals$bty_f1lower)
cor(evals$bty_avg, evals$bty_f1lower)
[1] 0.8439112
plot(evals[,13:19])
m_bty_gen <-lm(score ~ bty_avg + gender, data = evals)summary(m_bty_gen)
Call:
lm(formula = score ~ bty_avg + gender, data = evals)
Residuals:
Min 1Q Median 3Q Max
-1.8305 -0.3625 0.1055 0.4213 0.9314
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 3.74734 0.08466 44.266 < 2e-16 ***
bty_avg 0.07416 0.01625 4.563 6.48e-06 ***
gendermale 0.17239 0.05022 3.433 0.000652 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.5287 on 460 degrees of freedom
Multiple R-squared: 0.05912, Adjusted R-squared: 0.05503
F-statistic: 14.45 on 2 and 460 DF, p-value: 8.177e-07
#female is reference level #beauty score adds .074 #being male adds .172 #not a good model: Adjusted R-squared is really small (only 5.5% is explained by this model)
Exercise 7: P-values and parameter estimates should only be trusted if the conditions for the regression are reasonable. Verify that the conditions for this model are reasonable using diagnostic plots.
Call:
lm(formula = score ~ bty_avg + gender + bty_avg * gender, data = evals)
Residuals:
Min 1Q Median 3Q Max
-1.8084 -0.3828 0.0903 0.4037 0.9211
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 3.95006 0.11800 33.475 <2e-16 ***
bty_avg 0.03064 0.02400 1.277 0.2024
gendermale -0.18351 0.15349 -1.196 0.2325
bty_avg:gendermale 0.07962 0.03247 2.452 0.0146 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.5258 on 459 degrees of freedom
Multiple R-squared: 0.07129, Adjusted R-squared: 0.06522
F-statistic: 11.74 on 3 and 459 DF, p-value: 1.997e-07
plot(fit3)
Based on the diagnostic plots, the conditions for linear regression have been met.
Exercise 8: Is bty_avg still a significant predictor of score? Has the addition of gender to the model changed the parameter estimate for bty_avg?
multiLines(m_bty_gen)
Bty_avg is still a good predictor of score, though adding gender into the mix does have an impact. It appears as though males will have an overall higher score in general.
Exercise 9: What is the equation of the line corresponding to males? (Hint: For males, the parameter estimate is multiplied by 1.) For two professors who received the same beauty rating, which gender tends to have the higher course evaluation score?
y=3.747 +.172x
males have the higher score
Exercise 10: Create a new model called m_bty_rank with gender removed and rank added in. How does R appear to handle categorical variables that have more than two levels? Note that the rank variable has three levels: teaching, tenure track, tenured.
m_bty_rank <-lm(score ~ bty_avg + rank, data = evals)summary(m_bty_rank)
Call:
lm(formula = score ~ bty_avg + rank, data = evals)
Residuals:
Min 1Q Median 3Q Max
-1.8713 -0.3642 0.1489 0.4103 0.9525
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 3.98155 0.09078 43.860 < 2e-16 ***
bty_avg 0.06783 0.01655 4.098 4.92e-05 ***
ranktenure track -0.16070 0.07395 -2.173 0.0303 *
ranktenured -0.12623 0.06266 -2.014 0.0445 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.5328 on 459 degrees of freedom
Multiple R-squared: 0.04652, Adjusted R-squared: 0.04029
F-statistic: 7.465 on 3 and 459 DF, p-value: 6.88e-05
multiLines(m_bty_rank)
R makes one of them the standard that the others are compared to
The search for the best model
Exercise 11: Which variable would you expect to have the highest p-value in this model? Why? Hint: Think about which variable would you expect to not have any association with the professor score.
I would think level of class taught would have the highest p-value. That seems to be the least relevant toward the beauty score.
Exercise 12: Check your suspicions from the previous exercise. Include the model output in your response.
Cls_profssingle had the highest p-value, with an output of 0.77806
Exercise 13: Interpret the coefficient associated with the ethnicity variable.
The ethnicity variable has a 0.1235 greater slope than the intercept, which is the not-tenured professor.
Exercise 14: Drop the variable with the highest p-value and re-fit the model. Did the coefficients and significance of the other explanatory variables change? If not, what does this say about whether or not the dropped variable was collinear with the other explanatory variables?
m_full2 <-lm(score ~ rank + ethnicity + gender + language + age + cls_perc_eval + cls_students + cls_level + cls_credits + bty_avg + pic_outfit + pic_color, data = evals)summary(m_full2)
Generally speaking, the variables that came after the removed variable were impacted more than the ones that came before. For example, age as a variable had little change in it’s coefficient, whereas the color/BW variable for the picture did have some change in the coefficient. Nothing changed drastically, but there is more impact after the removed variable.
Exercise 15: Using backward-selection and p-value as the selection criterion, determine the best model. You do not need to show all steps in your answer, just the output for the final model. Also, write out the linear model for predicting score based on the final model you settle on.
m_full3 <-lm(score ~ ethnicity + gender + age + pic_outfit*pic_color + age*gender+ cls_credits + bty_avg + pic_color, data = evals)summary(m_full3)
Exercise 16: Verify that the conditions for this model are reasonable using diagnostic plots.
plot(m_full3)
Constant variability and normal distribution are still mostly intact.
Exercise 17: The original paper describes how these data were gathered by taking a sample of professors from the University of Texas at Austin and including all courses that they have taught. Considering that each row represents a course, could this new information have an impact on any of the conditions of linear regression?
If each row represents a course rather than a professor, than there could be impact to the conditions of linear regression. If a professor teaches multiple courses, then data will be skewed toward that professor, which would potentially violate the distribution of the data.
Exercise 18: Based on your final model, describe the characteristics of a professor and course at University of Texas at Austin that would be associated with a high evaluation score.
Casual picture in color, male, younger, white, one credit courses.
Exercise 19: Would you be comfortable generalizing your conclusions to apply to professors generally (at any university)? Why or why not?
No. Different areas have different physical standards. Younger, white, male professors aren’t the most appealing to everybody everywhere.