Grading the professor

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 lab we will analyze the data from this study in order to learn what goes into a positive professor evaluation.

The data

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 aslightly 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.

load("more/evals.RData")
variable description
score average professor evaluation score: (1) very unsatisfactory - (5) excellent.
rank rank of professor: teaching, tenure track, tenured.
ethnicity ethnicity of professor: not minority, minority.
gender gender of professor: female, male.
language language of school where professor received education: english or non-english.
age age of professor.
cls_perc_eval percent of students in class who completed evaluation.
cls_did_eval number of students in class who completed evaluation.
cls_students total number of students in class.
cls_level class level: lower, upper.
cls_profs number of professors teaching sections in course in sample: single, multiple.
cls_credits number of credits of class: one credit (lab, PE, etc.), multi credit.
bty_f1lower beauty rating of professor from lower level female: (1) lowest - (10) highest.
bty_f1upper beauty rating of professor from upper level female: (1) lowest - (10) highest.
bty_f2upper beauty rating of professor from second upper level female: (1) lowest - (10) highest.
bty_m1lower beauty rating of professor from lower level male: (1) lowest - (10) highest.
bty_m1upper beauty rating of professor from upper level male: (1) lowest - (10) highest.
bty_m2upper beauty rating of professor from second upper level male: (1) lowest - (10) highest.
bty_avg average beauty rating of professor.
pic_outfit outfit of professor in picture: not formal, formal.
pic_color color of professor’s picture: color, black & white.

Exploring the data

  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.

A: Research is an observational study. I believe original research question draws students focus on to the word beauty. It also sounds more appealing, and students may want to answer the question more directly. Given a chance to rephrase I would ask students what factors contributed to staying focused on the course, instructors physical appearance, teaching style or course content?

  1. 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?

A: Looing at the summary of score, most students rated instructors very highly. That indicates course content and teaching style was important than the physical appearance of the instructors. However, the histogram shows data is left skewed, and there are some outliers. In other words, there were some students to whom instructors physical appearance mattered more than course content and teaching style. I did expect some skewness in the data. A small portion of the students giving remarkably lower or higher rating would skew the data.

hist(evals$score)

summary(evals$score)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   2.300   3.800   4.300   4.175   4.600   5.000
  1. Excluding score, select two other variables and describe their relationship using an appropriate visualization (scatterplot, side-by-side boxplots, or mosaic plot).

A: Box plot shows gender had no impact while rating instructors physical appearance. Both male and female instructors received similar rating.

plot(bty_avg ~ gender, data=evals)

Simple linear regression

The fundamental phenomenon suggested by the study is that better looking teachers are evaluated more favorably. Let’s create a scatterplot to see if this appears to be the case:

plot(evals$score ~ evals$bty_avg)

Before we draw conclusions about the trend, compare the number of observations in the data frame with the approximate number of points on the scatterplot. Is anything awry?

  1. 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?

A: Initial scatterplot did not reveal any relationship between two variables score and bty_avg. It suggested relationship may not be linear. After adding jitter() function, scatterplots show some pattern. Especially, scatterplot with jitter() function added to score. However, it still does not reveal form and direction.

par(mfrow = c(1, 2))

plot(evals$score ~ jitter(evals$bty_avg))

plot(jitter(evals$score) ~ evals$bty_avg)

  1. 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?

A: Linear equation to predict average professor score(\(\hat{y}_{professor\ score}\)) by average beauty rating(\(x_{beauty\ rating}\)), with \(\beta_0 = 3.88034, \beta_1 = 0.06664\)

\(\hat{y}_{professor\ score} = \beta_0 + \beta_1{x}_{beauty\ rating}\)

\(\hat{y}_{professor\ score} = 3.88034 + 0.06664{x}_{beauty\ rating}\)

Since \(\beta_0 = 3.88034\ and\ \beta_1 = 0.06664\) are positive, linear equation suggests there is positive relation between average professor score and average beauty rating. The equation also suggests as beauty rating increases professor score will be increased by 0.06664. Also, as beauty rating approaches zero, professor score will be 3.88034.

As the p-value is 0.0000508, which is much less than 0.05, the model suggests there is a significant relationship between the variables in the linear regression model. Using \(R^2 = 0.035\), only 3.5 percent data can be explained by the model. Since it is low value, model is considered to be statistically significant predictor and not a practically significant predictor.

options("scipen"=100, "digits"=4)
m_bty <- lm(evals$score ~ evals$bty_avg)
plot(evals$score ~ evals$bty_avg)

abline(m_bty)

summary(m_bty)
## 
## Call:
## lm(formula = evals$score ~ evals$bty_avg)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -1.925 -0.369  0.142  0.398  0.931 
## 
## Coefficients:
##               Estimate Std. Error t value             Pr(>|t|)    
## (Intercept)     3.8803     0.0761   50.96 < 0.0000000000000002 ***
## evals$bty_avg   0.0666     0.0163    4.09             0.000051 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.535 on 461 degrees of freedom
## Multiple R-squared:  0.035,  Adjusted R-squared:  0.0329 
## F-statistic: 16.7 on 1 and 461 DF,  p-value: 0.0000508
  1. 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).

A: Looking at scatterplot, residuals are randomly scattered around zero on the horizontal axis. This indicates Linearity condition is met.

Histogram suggests data are left skewed. This indicates there are some outliers. Normal probability plot shows that most data points are close to the line. Both graphs show enough evidence that data meets Nearly Normal condition.

Looking at scatterplot, the points have constant variance, with the residuals scattered randomly around zero on the horizontal axis. Since residuals do not show increasing or decreasing pattern, we can assume Constant Variance exists.

Using residual plots we can conclude conditions for least squares regression are reasonable.

#Scatter residual plot 
m_bty <- lm(evals$score ~ evals$bty_avg)
plot(m_bty$residuals ~ evals$bty_avg)
abline(h = 0, lty = 3)

#Residuals Histogram
hist(m_bty$residuals)

# Nearly normal residuals using Normal probability plot 
qqnorm(m_bty$residuals)
qqline(m_bty$residuals)  # adds diagonal line to the normal prob plot

Multiple linear regression

The data set contains several variables on the beauty score of the professor: individual ratings from each of the six students who were asked to score the physical appearance of the professors and the average of these six scores. Let’s take a look at the relationship between one of these scores and the average beauty score.

plot(evals$bty_avg ~ evals$bty_f1lower)

cor(evals$bty_avg, evals$bty_f1lower)
## [1] 0.8439

As expected the relationship is quite strong - after all, the average score is calculated using the individual scores. We can actually take a look at the relationships between all beauty variables (columns 13 through 19) using the following command:

plot(evals[,13:19])

These variables are collinear (correlated), and adding more than one of these variables to the model would not add much value to the model. In this application and with these highly-correlated predictors, it is reasonable to use the average beauty score as the single representative of these variables.

In order to see if beauty is still a significant predictor of professor score after we’ve accounted for the gender of the professor, we can add the gender term into the model.

options(show.signif.stars=F)
options("scipen"=100, "digits"=4)
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.831 -0.362  0.105  0.421  0.931 
## 
## Coefficients:
##             Estimate Std. Error t value             Pr(>|t|)
## (Intercept)   3.7473     0.0847   44.27 < 0.0000000000000002
## bty_avg       0.0742     0.0163    4.56            0.0000065
## gendermale    0.1724     0.0502    3.43              0.00065
## 
## Residual standard error: 0.529 on 460 degrees of freedom
## Multiple R-squared:  0.0591, Adjusted R-squared:  0.055 
## F-statistic: 14.5 on 2 and 460 DF,  p-value: 0.000000818
  1. 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.

A: According to OpenIntro Statistics, if data meets following conditions it is reasonable to apply regression model.

1. The residuals of the model are nearly normal.

2. The variability of the residuals is nearly constant.

3. The residuals are independent.

4. Each variable is linearly related to the outcome.

Histogram doesn’t have the ideal bell-shaped appearance, and it suggests there are some outliers in the data. However, the histogram can be strongly influenced by choice of intervals for the bars. Reading the normal plot of the residuals, data points lie pretty close to the line. Some deviation is noticed near the ends. There is not enough evidence to assume residuals are not nearly normal.

Reading Residuals Vs. Fitted plot from left to right, the average of the residuals remains approximately Zero. If there was no scatter and all the actual data points fell on the estimated regression line, then dots on this plot would be on the gray dashed line (residual = 0). The red line on the plot is a scatterplot smoother, showing the average value of the residuals at each value of fitted value. It is relatively flat and lies close to the gray dashed line. The variation of the residuals appears to be roughly constant. This meets condition of Constant Variability of the residuals.

Scale-Location plot is drawn using fitted values on the x-axis and square root of the standardized residuals on the y-axis. That means residuals values on the y-axis are rescaled so that they have mean of zero and variance of one. The plot is also known as Absolute values of residuals against fitted values. The red line on the plot shows the trend and is relatively flat. It suggests that the variance in the residuals(y) doesn’t change as a function of x. Scale-Location plot provides enough evidence that the residuals are independent.

Plots Beauty Vs. Residuals and Gender Vs. Residuals, show variability that doesn’t fluctuate across groups. This satisfies condition each variable is linearly related to the outcome.

#Scatter residual plot 
m_bty_gen <- lm(score ~ bty_avg + gender, data = evals)

#Regression diagnostic plots
plot(m_bty_gen)

hist(m_bty_gen$res)

plot(evals$bty_avg, residuals(m_bty_gen), xlab="Beauty", ylab="Residuals", main = "Beauty Vs. Residuals")
abline(h=0, col="red")

plot(evals$gender, residuals(m_bty_gen), xlab="Gender", ylab="Residuals", main = "Gender Vs. Residuals")

  1. Is bty_avg still a significant predictor of score? Has the addition of gender to the model changed the parameter estimate for bty_avg?

A: Yes, bty_avg still is a significant predictor of score. By applying forward selection strategy,

For one predictor bty_avg adjusted `\({R^2}_{adj}\) is 0.032929

When two predictors bty_avg and gender are used \({R^2}_{adj}\) is 0.055032

Increase in \(R^2\) value suggests adding predictor gender has improved the model.

options("scipen"=100, "digits"=4)
bg <- summary(m_bty_gen)
b <- summary(m_bty)

cat(sprintf("\"Beauty average R squared = %f\" \"Beauty average and Gender R squared = %f\"\n", b$adj.r.squared, bg$adj.r.squared))
## "Beauty average R squared = 0.032929" "Beauty average and Gender R squared = 0.055032"

Note that the estimate for gender is now called gendermale. You’ll see this name change whenever you introduce a categorical variable. The reason is that R recodes gender from having the values of female and male to being an indicator variable called gendermale that takes a value of \(0\) for females and a value of \(1\) for males. (Such variables are often referred to as “dummy” variables.)

As a result, for females, the parameter estimate is multiplied by zero, leaving the intercept and slope form familiar from simple regression.

\[ \begin{aligned} \widehat{score} &= \hat{\beta}_0 + \hat{\beta}_1 \times bty\_avg + \hat{\beta}_2 \times (0) \\ &= \hat{\beta}_0 + \hat{\beta}_1 \times bty\_avg\end{aligned} \]

We can plot this line and the line corresponding to males with the following custom function.

multiLines(m_bty_gen)

  1. 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?

A: Regression model that accounts for two variable bty_avg and gender is

\(\hat{y} = {\beta}_0 + {\beta}_1 * {bty\_avg} + {\beta}_2 * gender\)

\({\beta}_0 = 3.74734, {\beta}_1 = 0.07416, {\beta}_2 = 0.17239\), since Linear Models(lm) created gendermale dummy variable, it translates to male = 1 and female = 0. Therefore, gender value for above equation is 1.

Substituting values, \(\hat{y} = 3.74734 + 0.07416 * {bty\_avg} + 0.17239 * 1\)

\(\hat{y} = 3.9197 + 0.07416 * {bty\_avg}\)

Above equation suggests, when two professors male and female receive same beauty rating, male professors tend to receive better course evaluation score.

options("scipen"=100, "digits"=4)
bg$coefficients
##             Estimate Std. Error t value   Pr(>|t|)
## (Intercept)  3.74734    0.08466  44.266 6.227e-168
## bty_avg      0.07416    0.01625   4.563  6.484e-06
## gendermale   0.17239    0.05022   3.433  6.518e-04

The decision to call the indicator variable gendermale instead ofgenderfemale has no deeper meaning. R simply codes the category that comes first alphabetically as a \(0\). (You can change the reference level of a categorical variable, which is the level that is coded as a 0, using therelevel function. Use ?relevel to learn more.)

  1. 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.

Summary of the regression model with categorical variable rank shows that R stats package has created two dummy variables ranktenure track and ranktenured. That means when a categorical variable has n levels, R creates n - 1 dummy variables. One missing level will be zero. In this particular example, \(rank_{teaching}\) value is zero.

Regression model is written as \(\hat{y} = {\beta}_0 + {\beta}_1 * {bty\_avg} + {\beta}_2 * rank_{teaching} + {\beta}_3 * rank_{tenure\ track} + {\beta}_4 * rank_{tenured}\)

\({\beta}_0 = 3.9815, {\beta}_1 = 0.0678, {\beta}_3 = -0.1607, {\beta}_4 = -0.1262, rank_{teaching} = 0\)

Regression model for professor in the category of rank = teaching, value for \(rank_{tenure\ track} = 0\ and\ rank_{tenured} = 0\)

\(\hat{y} = 3.9815 + 0.0678 * {bty\_avg} + {\beta}_2 * 0 -0.1607 * 0 -0.1262 * 0\)

\(\hat{y} = 3.9815 + 0.0678 * {bty\_avg}\)

For professor in the category of rank = tenure track, value for \(rank_{tenured} = 0\)

\(\hat{y} = 3.9815 + 0.0678 * {bty\_avg} + {\beta}_2 * 0 -0.1607 * 1 -0.1262 * 0\)

\(\hat{y} = 3.8208 + 0.0678 * {bty\_avg}\)

For professor in the category of rank = tenured, value for \(rank_{tenure\ track} = 0\)

\(\hat{y} = 3.8553 + 0.0678 * {bty\_avg}\)

options(show.signif.stars=F)
options("scipen"=100, "digits"=4)
#Scatter residual plot 
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.871 -0.364  0.149  0.410  0.953 
## 
## Coefficients:
##                  Estimate Std. Error t value             Pr(>|t|)
## (Intercept)        3.9815     0.0908   43.86 < 0.0000000000000002
## bty_avg            0.0678     0.0165    4.10             0.000049
## ranktenure track  -0.1607     0.0740   -2.17                0.030
## ranktenured       -0.1262     0.0627   -2.01                0.045
## 
## Residual standard error: 0.533 on 459 degrees of freedom
## Multiple R-squared:  0.0465, Adjusted R-squared:  0.0403 
## F-statistic: 7.46 on 3 and 459 DF,  p-value: 0.0000688

The interpretation of the coefficients in multiple regression is slightly different from that of simple regression. The estimate for bty_avg reflects how much higher a group of professors is expected to score if they have a beauty rating that is one point higher while holding all other variables constant. In this case, that translates into considering only professors of the same rank with bty_avg scores that are one point apart.

The search for the best model

We will start with a full model that predicts professor score based on rank, ethnicity, gender, language of the university where they got their degree, age, proportion of students that filled out evaluations, class size, course level, number of professors, number of credits, average beauty rating, outfit, and picture color.

  1. 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.

A: I am expecting age variable would have the highest p-value.

Let’s run the model…

options(show.signif.stars=F)
options("scipen"=100, "digits"=4)
m_full <- lm(score ~ rank + ethnicity + gender + language + age + cls_perc_eval 
             + cls_students + cls_level + cls_profs + cls_credits + bty_avg 
             + pic_outfit + pic_color, data = evals)
summary(m_full)
## 
## Call:
## lm(formula = score ~ rank + ethnicity + gender + language + age + 
##     cls_perc_eval + cls_students + cls_level + cls_profs + cls_credits + 
##     bty_avg + pic_outfit + pic_color, data = evals)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.7740 -0.3243  0.0907  0.3518  0.9504 
## 
## Coefficients:
##                        Estimate Std. Error t value             Pr(>|t|)
## (Intercept)            4.095214   0.290528   14.10 < 0.0000000000000002
## ranktenure track      -0.147593   0.082067   -1.80              0.07278
## ranktenured           -0.097338   0.066330   -1.47              0.14295
## ethnicitynot minority  0.123493   0.078627    1.57              0.11698
## gendermale             0.210948   0.051823    4.07             0.000055
## languagenon-english   -0.229811   0.111375   -2.06              0.03965
## age                   -0.009007   0.003136   -2.87              0.00427
## cls_perc_eval          0.005327   0.001539    3.46              0.00059
## cls_students           0.000455   0.000377    1.20              0.22896
## cls_levelupper         0.060514   0.057562    1.05              0.29369
## cls_profssingle       -0.014662   0.051988   -0.28              0.77806
## cls_creditsone credit  0.502043   0.115939    4.33             0.000018
## bty_avg                0.040033   0.017506    2.29              0.02267
## pic_outfitnot formal  -0.112682   0.073880   -1.53              0.12792
## pic_colorcolor        -0.217263   0.071502   -3.04              0.00252
## 
## Residual standard error: 0.498 on 448 degrees of freedom
## Multiple R-squared:  0.187,  Adjusted R-squared:  0.162 
## F-statistic: 7.37 on 14 and 448 DF,  p-value: 0.0000000000000655
  1. Check your suspicions from the previous exercise. Include the model output in your response.

A: Predictor variable cls_profs for catagorical value single has highest p-value.

  1. Interpret the coefficient associated with the ethnicity variable.

A: Professor belonging to a non minority ethnic group tend to score 0.123493 more given all other parameters are same. Since p-value is larger than \(\alpha = 0.05\) it may not be statistically significant.

  1. Drop the variable with the highest p-value and re-fit the model. Did the coefficients and significance of the other explanatory variables change? (One of the things that makes multiple regression interesting is that coefficient estimates depend on the other variables that are included in the model.) If not, what does this say about whether or not the dropped variable was collinear with the other explanatory variables?

A: Variable cls_profs had highest p-value = 0.77806. After dropping the variable, point estimates in the re-fit model have changed. Example ethnicitynot minority value went up, while pic_outfitnot formal value dropped. Change in the point estimates explains existence of collinearity in the predictor variables.

options(show.signif.stars=F)
options("scipen"=100, "digits"=4)
m_full <- 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_full)
## 
## Call:
## lm(formula = score ~ rank + ethnicity + gender + language + age + 
##     cls_perc_eval + cls_students + cls_level + cls_credits + 
##     bty_avg + pic_outfit + pic_color, data = evals)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.7836 -0.3257  0.0859  0.3513  0.9551 
## 
## Coefficients:
##                        Estimate Std. Error t value             Pr(>|t|)
## (Intercept)            4.087252   0.288856   14.15 < 0.0000000000000002
## ranktenure track      -0.147675   0.081982   -1.80              0.07233
## ranktenured           -0.097383   0.066261   -1.47              0.14235
## ethnicitynot minority  0.127446   0.077289    1.65              0.09986
## gendermale             0.210123   0.051687    4.07             0.000057
## languagenon-english   -0.228289   0.111131   -2.05              0.04053
## age                   -0.008999   0.003133   -2.87              0.00426
## cls_perc_eval          0.005289   0.001532    3.45              0.00061
## cls_students           0.000469   0.000374    1.25              0.21038
## cls_levelupper         0.060637   0.057501    1.05              0.29220
## cls_creditsone credit  0.506120   0.114916    4.40             0.000013
## bty_avg                0.039863   0.017478    2.28              0.02303
## pic_outfitnot formal  -0.108323   0.072171   -1.50              0.13408
## pic_colorcolor        -0.219053   0.071147   -3.08              0.00221
## 
## Residual standard error: 0.497 on 449 degrees of freedom
## Multiple R-squared:  0.187,  Adjusted R-squared:  0.163 
## F-statistic: 7.94 on 13 and 449 DF,  p-value: 0.0000000000000234
  1. 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.

A:\(\hat{y}_{score} = 4.085626 -0.142070 * {rank}_{tenure\ track} + 0.142434 * {ethnicity}_{not\ minority} + 0.203772 * {gender}_{male} -0.209319 * {language}_{non-english} -0.008729 * age + 0.005355 * cls\_perc\_eval + 0.000357 * cls\_students + 0.473373 * cls\_credits + 0.041034 * bty\_avg -0.117215 * {pic\_outfit}_{not\ formal} -0.197320 * {pic\_color}_{color}\)

\(\hat{y}_{score} = 3.7659 -0.008729 * age + 0.005355 * cls\_perc\_eval + 0.000357 * cls\_students + 0.473373 * cls\_credits + 0.041034 * bty\_avg\)

options(show.signif.stars=F)
options("scipen"=100, "digits"=4)
m_full <- lm(score ~ rank + ethnicity + gender + language + age + cls_perc_eval 
             + cls_students + cls_credits + bty_avg 
             + pic_outfit + pic_color, data = evals)

summary(m_full)
## 
## Call:
## lm(formula = score ~ rank + ethnicity + gender + language + age + 
##     cls_perc_eval + cls_students + cls_credits + bty_avg + pic_outfit + 
##     pic_color, data = evals)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.7761 -0.3187  0.0875  0.3547  0.9367 
## 
## Coefficients:
##                        Estimate Std. Error t value             Pr(>|t|)
## (Intercept)            4.085626   0.288888   14.14 < 0.0000000000000002
## ranktenure track      -0.142070   0.081820   -1.74              0.08318
## ranktenured           -0.089594   0.065857   -1.36              0.17437
## ethnicitynot minority  0.142434   0.075980    1.87              0.06149
## gendermale             0.203772   0.051342    3.97             0.000084
## languagenon-english   -0.209319   0.109678   -1.91              0.05697
## age                   -0.008729   0.003122   -2.80              0.00540
## cls_perc_eval          0.005355   0.001531    3.50              0.00051
## cls_students           0.000357   0.000358    1.00              0.31945
## cls_creditsone credit  0.473373   0.110655    4.28             0.000023
## bty_avg                0.041034   0.017445    2.35              0.01909
## pic_outfitnot formal  -0.117215   0.071686   -1.64              0.10272
## pic_colorcolor        -0.197320   0.068105   -2.90              0.00395
## 
## Residual standard error: 0.498 on 450 degrees of freedom
## Multiple R-squared:  0.185,  Adjusted R-squared:  0.163 
## F-statistic: 8.51 on 12 and 450 DF,  p-value: 0.0000000000000127
  1. Verify that the conditions for this model are reasonable using diagnostic plots.

A: Histogram doesn’t have the ideal bell-shaped appearance, it suggest there are some outliers in the data. However, the histogram can be strongly influenced by choice of intervals for the bars. Reading normal plot of the residuals, data points lie pretty close to the line. Some deviation is noticed near the ends. There is not enough evidence to assume residuals are not nearly normal.

Reading Residuals Vs. Fitted plot from left to right, the average of the residuals remains approximately Zero. If there was no scatter and all the actual data points fell on the estimated regression line, then dots on this plot would be on the gray dashed line (residual = 0). The red line on the plot is a scatterplot smoother, showing the average value of the residuals at each value of fitted value. It is relatively flat and lies close to the gray dashed line. The variation of the residuals appears to be roughly constant. This meets condition of Constant Variability of the residuals.

Scale-Location plot is drawn using fitted values on the x-axis and square root of the standardized residuals on the y-axis. That means residuals values on the y-axis are rescaled so that they have mean of zero and variance of one. The red line on the plot shows the trend and is relatively flat. It suggests that the variance in the residuals(y) doesn’t change as a function of x. Scale-Location plot provides enough evidence that the residuals are independent.

Plots Rank Vs. Residuals, Ethnicity Vs. Residuals, Gender Vs. Residuals, Language Vs. Residuals, cls_credits Vs. Residuals, pic_outfit Vs. Residuals, pic_color Vs. Residuals, Beauty Vs. Residuals, Age Vs. Residuals and cls_perc_eval Vs. Residuals, show variability that doesn’t fluctuate across groups. This satisfies condition each variable is linearly related to the outcome.

#Scatter residual plot 
m_full <- lm(score ~ rank + ethnicity + gender + language + age + cls_perc_eval 
             + cls_students + cls_credits + bty_avg 
             + pic_outfit + pic_color, data = evals)

#Regression diagnostic plots
par(mfrow = c(2, 2))

plot(m_full)

hist(m_full$res)

plot(evals$rank, residuals(m_full), xlab="Rank", ylab="Residuals", main = "Rank Vs. Residuals")
plot(evals$ethnicity, residuals(m_full), xlab="Ethnicity", ylab="Residuals", main = "Ethnicity Vs. Residuals")
plot(evals$gender, residuals(m_full), xlab="Gender", ylab="Residuals", main = "Gender Vs. Residuals")

plot(evals$language, residuals(m_full), xlab="Language", ylab="Residuals", main = "Language Vs. Residuals")
plot(evals$cls_credits, residuals(m_full), xlab="cls_credits", ylab="Residuals", main = "cls_credits Vs. Residuals")
plot(evals$pic_outfit, residuals(m_full), xlab="pic_outfit", ylab="Residuals", main = "pic_outfit Vs. Residuals")
plot(evals$pic_color, residuals(m_full), xlab="pic_color", ylab="Residuals", main = "pic_color Vs. Residuals")

plot(evals$bty_avg, residuals(m_full), xlab="Beauty", ylab="Residuals", main = "Beauty Vs. Residuals")
abline(h=0, col="red")
plot(evals$age, residuals(m_full), xlab="Age", ylab="Residuals", main = "Age Vs. Residuals")
abline(h=0, col="red")
plot(evals$cls_perc_eval, residuals(m_full), xlab="cls_perc_eval", ylab="Residuals", main = "cls_perc_eval Vs. Residuals")
abline(h=0, col="red")

  1. 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?

A: One of the conditions of the linear regression model is independence. Each observation is independent of another. If all the courses professor has taught are added then sample dataset loses independence.

  1. 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.

A: Male professors from non-minority ethnicity who received education from a school in the English language, teaching single credit to a class that has high number of students will receive high evaluation score.

  1. Would you be comfortable generalizing your conclusions to apply to professors generally (at any university)? Why or why not?

A: Sample is collected from just one university, it does not represent a true sample of the entire population (all universities). Also, adjusted \(R^2\) is 0.163, that means only 16% of the data can be explained using the regression model. This is a very low percentage. Because of these reasons, I am not comfortable in generalizing the conclusions.

This is a product of OpenIntro that is released under a Creative Commons Attribution-ShareAlike 3.0 Unported. This lab was written by Mine Çetinkaya-Rundel and Andrew Bray.