Before you start, please check the course website for important reminders on:
This assignment requires two types of work:
We have included empty code and markdown cells where you should enter your solutions. Feel free to add additional cells wherever needed.
Note: You may only use Python packages that were introduced during the EMET2007 computer labs.
This assignment investigates whether a professor's physical attractiveness affects their teaching evaluations using the Teaching_Ratings dataset.
The dataset contains observations on course evaluations, course characteristics, and professor characteristics for 463 courses at the University of Texas at Austin.
Good luck!
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import statsmodels.stats.api as sms
import statsmodels.formula.api as smf
df = pd.read_csv('https://raw.githubusercontent.com/juergenmeinecke/EMET2007/refs/heads/main/datasets/teaching_ratings.csv')
Create box plots and histograms for courseEval and beauty. Describe and interpret your findings.
Your task:
Note: Add as many code cells and markdown cells as needed.
# Your code here:
Your interpretation here:
Run a simple regression of courseEval on beauty and create a scatter plot with the estimated population regression function (PRF).
Your task:
smf.ols()# Your code here:
Your interpretation here:
Using your regression from Exercise 2, predict the course evaluation for:
Hint: Use the .predict() method from your regression results.
# Your code here:
Based on your predictions, is the effect of a one-standard-deviation increase in beauty on predicted course evaluations large or small? Explain your reasoning.
Your interpretation here:
Run a multiple regression of courseEval on beauty and the following control variables:
intro (1 if introductory course)oneCredit (1 if one-credit course)female (1 if female professor)minority (1 if minority professor)nnEnglish (1 if non-native English speaker)# Your code here:
Professor Smith is a Black male professor with average beauty, who is a native English speaker, teaching a three-credit upper-division course.
What is Professor Smith's predicted course evaluation?
# Your code here:
Professor Jones has all the same characteristics as Professor Smith, except she is female.
What is Professor Jones's predicted course evaluation?
# Your code here:
Run the regression from Exercise 4 again, but without female as a control variable.
Your task:
beauty in this regression to the one from Exercise 4.female leads to omitted variable bias. What are the conditions for omitted variable bias, and do they hold here?# Your code here:
Your discussion here:
Add an interaction between beauty and female to the regression from Exercise 4. This allows the effect of beauty to differ by gender.
Your task:
Hint: In statsmodels, you can include an interaction using beauty * female in the formula.
# Your code here:
Your interpretation here:
Professor White is a male professor who has cosmetic surgery that increases his beauty from one standard deviation below average to one standard deviation above average.
What are Professor White's beauty values before and after surgery?
# Your code here:
Using the regression with the interaction term from Exercise 6, what is the predicted increase in Professor White's course evaluation as a result of the surgery?
# Your code here:
Construct a 95% confidence interval for the predicted increase in Professor White's course evaluation.
# Your code here:
Professor Robinson is a female professor who has the same surgery as Professor White (increasing beauty from one SD below to one SD above average).
What is the predicted increase in Professor Robinson's course evaluation as a result of the surgery?
Hint: For a female professor, the effect of beauty is the sum of the coefficient on beauty and the coefficient on the interaction term.
# Your code here:
Construct a 95% confidence interval for the predicted increase in Professor Robinson's course evaluation.
Hint: To get the confidence interval for the female effect directly, you can re-run the regression using a male dummy variable instead of female. Then the coefficient on beauty will represent the effect for females.
# Your code here:
# Your code here:
Hint: You can use the .f_test() method for the joint test. The syntax is: results.f_test('age = I(age ** 2) = 0')
# Your code here:
Your interpretation here:
Submit both files on the course's Canvas page:
Note: The
.ipynbfile is required. If you have difficulty creating the HTML file, you will not lose marks for that portion.
This exercise is based on Additional Empirical Exercises 4.2, 5.2, 6.1, 7.2, and 8.1 of Stock and Watson, Introduction to Econometrics, 4th Global Edition.