Code
library(tidyverse)
library(tidymodels)
library(openintro)Simple and multiple linear regression
Many college courses conclude by giving students the opportunity to evaluate the course and the instructor anonymously. However, the use of these student evaluations as an indicator of course quality and teaching effectiveness is often criticized because these measures may reflect the influence of non-teaching related characteristics, such as the physical appearance of the instructor. The article titled, “Beauty in the classroom: instructors’ pulchritude and putative pedagogical productivity” (Hamermesh and Parker, 2005) found that instructors who are viewed to be better looking receive higher instructional ratings. (Daniel S. Hamermesh, Amy Parker, Beauty in the classroom: instructors pulchritude and putative pedagogical productivity, Economics of Education Review, Volume 24, Issue 4, August 2005, Pages 369-376, ISSN 0272-7757, 10.1016/j.econedurev.2004.07.013. http://www.sciencedirect.com/science/article/pii/S0272775704001165.)
In this activity you will analyze the data from this study in order to learn what goes into a positive professor evaluation.
The data were gathered from end of semester student evaluations for a large sample of professors from the University of Texas at Austin. In addition, six students rated the professors’ physical appearance. (This is a slightly modified version of the original data set that was released as part of the replication data for Data Analysis Using Regression and Multilevel/Hierarchical Models (Gelman and Hill, 2007).) The result is a data frame where each row contains a different course and columns represent variables about the courses and professors.
Download the activity Quarto file here and place it in your class activities folder.
Open the R Quarto document.
Render the document to make sure it compiles without errors.
Update the YAML (header) of your Quarto file with your information and render.
What to do if you face an error when installing and loading the tidymodels package.
The newest version of tidymodels requires you to either:
Update the rlang package. Use install.packages("rlang") to update.
Update your version of RStudio. To do so, you will need to download the newest release of RStudio (that came out just after we started the semester):
Note: you do not need to uninstall anything in order to update. Simply download the newest version and install.
We’ll use the tidyverse package for much of the data wrangling and visualization, the tidymodels package for modeling and inference, and the data lives in the dsbox package.
The data can be found in the openintro package, and it’s called evals.
Since the dataset is distributed with the package, we don’t need to load it separately; it becomes available to us when we load the package. You can find out more about the dataset by inspecting its documentation, which you can access by running ?evals in the Console or using the Help menu in RStudio to search for evals. You can also find this information here.
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? Include any summary statistics and visualizations you use in your response.score and bty_avg.geom_jitter(). What does “jitter” mean? What was misleading about the initial plot?Linear model is in the form \(\hat{y} = b_0 + b_1 x\).
score_bty_fit to predict average professor evaluation score by average beauty rating (bty_avg). Based on the regression output, write the linear model (as a comment inside the code chunk).With a beauty rating of 0, on average, the professor evaluation score is estimated to be 3.9.
What aspects of the residual plot show that the linear model is appropriate or not? Are there any aspects of the residual plot that cause you to be concerned about the fitting of the linear model? Write your response.
score_gender_fit to predict average professor evaluation score based on gender of the professor. Based on the regression output, write the linear model and interpret the slope and intercept in context of the data.score_bty_fit, predicting average professor evaluation score based on average beauty rating (bty_avg) only. Write the linear model, and note the adjusted \(R^2\).score_bty_gen_fit, predicting average professor evaluation score based on average beauty rating (bty_avg) and gender. Write the linear model, and note the \(R^2\) and the adjusted \(R^2\).score_bty_gen_fit in context of the data.# Slopes:
## A one unit change in average beauty rating bty_avg is associated, on average, with a 0.074 increase in professor evaluation score.
## Professors who are men, on average, are expected to have an evaluation score 0.074 greater than women.
# Intercept
## Professors who are women are expected, on average, to have an evaluation score of 3.75.score is explained by the model score_bty_gen_fit?score_rank_fit to predict average professor evaluation score based on rank of the professor. Based on the regression output, write the linear model and interpret the slopes and intercept in context of the data.score_rank_fit <- lm(score ~ rank, data = evals)
summary(score_rank_fit)
# score = 4.28 - 0.13*ranktenure_track - 0.145*ranktenured
# Adjusted R-squared: 0.007332
# The proportion of variation in score (our dependent variable) explained by the model is 0.007. In other words, 0.7% of the variation in professor score is explained by a professor's rank. rank_relevel where "tenure track" is the baseline level. Use the fct_relevel function to specify the baseline (first) level. See our notes on factors.score_rank_relevel_fit to predict average professor evaluation score based on rank_relevel of the professor. This is the new (releveled) variable you created in the previous step. Based on the regression output, write the linear model and interpret the slopes and intercept in context of the data. Also determine and interpret the \(R^2\) of the model.tenure_eligible that labels "teaching" faculty as "no" and labels "tenure track" and "tenured" faculty as "yes".score_tenure_eligible_fit to predict average professor evaluation score based on tenure_eligibleness of the professor. This is the new (regrouped) variable you created in the previous step. Based on the regression output, write the linear model and interpret the slopes and intercept in context of the data. Also determine and interpret the \(R^2\) of the model.
score_bty_gen_fit and score_bty_fit compare? What does this tell us about how useful gender is in explaining the variability in evaluation scores when we already have information on the beauty score of the professor.
bty_avg under the two models (score_bty_fit and score_bty_gen_fit). Has the addition of gender to the model changed the parameter estimate (slope) for bty_avg?
score_bty_rank_fit with gender removed and rank added in. Write the equation of the linear model and interpret the slopes and intercept in context of the data.