Midterm 2 Extra Questions Solutions

  1. Consider the following regression

    \[\begin{align*} \text{Score} = 50 + 5 \times \text{Hours} + 10 \times \text{GPA} + U \end{align*}\] where \(\text{Score}\) is a student’s score on a midterm, \(\text{Hours}\) is the number of hours the student studied for the midterm, \(\text{GPA}\) is the student’s current GPA, and \(\mathbb{E}[U \mid \text{Score}, \text{Hours}, \text{GPA}] = 0\). Carefully explain how to interpret the coefficient on \(\text{Hours}\).

    Answer: Comparing students with the same GPA, those who study one more hour score, on average, 5 points higher on the midterm.

  2. Consider the following regression where airq is an indicator of air quality (lower is better) for a particular metropolitan area in California, dens1000 is the number of 1000s of people per square mile, coas indicates whether or not the metro area is on the coast, and medi1000 is the median income in the metro area (in thousands of dollars). The numbers in parentheses are the standard errors of the coefficients.

    data("Airq", package = "Ecdat")
    library(modelsummary)
    Airq$coas <- 1 * (Airq$coas == "yes")
    Airq$dens1000 <- Airq$dens / 1000
    Airq$medi1000 <- Airq$medi / 1000
    reg1 <- lm(airq ~ dens1000 + coas + dens1000 * coas + medi1000, data = Airq)
    modelsummary(reg1, fmt = 1, gof_omit = ".")
    (1)
    (Intercept) 120.6
    (9.5)
    dens1000 -0.3
    (2.8)
    coas -31.2
    (11.3)
    medi1000 0.8
    (0.4)
    dens1000 × coas -1.2
    (3.4)
    1. Which regressors are statistically significant in this regression?

      Answer: The intercept and coas are statistically significant. medi1000 is marginally statistically significant (the t-statistic is exactly equal to 2 from the available information); none of the other regressors are statistically significant.

    2. What is the predicted value for the air quality index for a metro area with 1000 people per square mile, that is not located on the coast, and with median income equal to $50,000?

      Answer: The predicted value is given by:

      120.6 - 0.3(1) - 31.2(0) + 0.8(50) - 1.2(1)(0) = 160.3




  1. Let \(Y\) denote a person’s age in the United States. Suppose that you have the theory that \(\mathbb{E}[Y] = 35\). You are able to collect a random sample of 100 observations. Using this data, you calculate \(\bar{Y} = 37\) and that \(\widehat{\mathrm{var}}(Y) = 6\).

    1. Calculate a t-statistic for testing the null hypothesis that \(\mathbb{E}[Y]=35\). Do you reject the null hypothesis here? Explain.

      Answer:

      \[ \begin{aligned} t &= \frac{\sqrt{n}(\bar{Y} - \mu_0)}{\sqrt{\widehat{\mathrm{var}}(Y)}} \\ &= \frac{10(37-35)}{\sqrt{6}} \\ &= \frac{20}{\sqrt{6}} \\ &= 8.16 \end{aligned} \]

      Since \(|t| > 1.96\), you reject the null hypothesis here. In other words, if the null hypothesis were true, there is less than a 5% chance that we would get a t-statistic this large (in absolute value).

    2. What is the standard error of \(\bar{Y}\).

      Answer:

      \[ \begin{aligned} \textrm{s.e.}(\bar{Y}) &= \frac{\sqrt{\widehat{\mathrm{var}}(Y)}}{\sqrt{n}} \\ &= \frac{\sqrt{6}}{\sqrt{100}} \\ &= 0.245 \end{aligned} \]

    3. Calculate a p-value for the null hypothesis that \(\mathbb{E}[Y]=35\). How do you interpret it?

      Answer:

      \[ \begin{aligned} \textrm{p-value} &= 2 \Phi(-|t|) \\ &= 2 \Phi(-8.16) \\ &= 3\times 10^{-16} \approx 0 \end{aligned} \]

      This p-value indicates that, if the null hypothesis were true, it is virtually certain that we would not get a t-statistic as large in absolute value as we did — in other words, we have very strong evidence against \(H_0\) here.

    4. Calculate a 95% confidence interval for \(\mathbb{E}[Y]\). How do you interpret it?

      Answer:

      \[ \begin{aligned} CI &= [\bar{Y} - 1.96 \textrm{s.e.}(\bar{Y}), \bar{Y} + 1.96 \textrm{s.e.}(\bar{Y})] \\ &= [37 - 1.96 \cdot 0.245, 37 + 1.96 \cdot 0.245] \\ &= [36.52, 37.48] \end{aligned} \]

      There is a 95% chance that the interval \([36.52,37.48]\) contains the true value of \(\mathbb{E}[Y]\).



  1. Consider the following conditional expectation using country-level data, where \(\text{pcGDP}\) is a country’s per capita GDP (in thousands of dollars), \(\text{Inflation}\) is the country’s current inflation rate, \(\text{Europe}\) is a binary variable indicating whether the country is located in Europe, and where \(\text{Democracy}\) is a binary variable indicating whether a country has democratic institutions.

    \[\mathbb{E}[\text{pcGDP} \mid \text{Inflation}, \text{Europe}, \text{Democracy}] = \beta_0 + \beta_1 \text{Inflation} + \beta_2 \text{Inflation} \cdot \text{Europe} + \beta_3 \text{Inflation}^2 + \beta_4 \text{Democracy}\]

    Further suppose that \(\beta_0 = 45, \beta_1=-1, \beta_2=-2, \beta_3=-0.1, \beta_4=8\)

    1. What is the expected value of per capita GDP for a European country with democratic institutions whose inflation rate is equal to 4?

      Answer:

      \[ \begin{aligned} \mathbb{E}[\text{pcGDP}|\text{Inflation}=4, \text{Europe}=1, \text{Democracy}=1] &= \beta_0 + \beta_1 (4) + \beta_2 (4)(1) + \beta_3 (4)^2 + \beta_4(1) \\ &= 45 + (-1)(4) + (-2)(4)(1) + (-0.1)(16) + 8(1) \\ &= 39.4 \end{aligned} \]

    2. What is the marginal contrast for inflation in this model?

      Answer:

      The marginal contrast of inflation is given by

      \[ \begin{aligned} MC_{\text{Inflation}} = \frac{\partial \mathbb{E}[\text{pcGDP} \mid \text{Inflation}, \text{Europe}, \text{Democracy}]}{\partial \text{Inflation}} &= \beta_1 + \beta_2 \text{Europe} + 2 \beta_3 \text{Inflation} \\ &= -1 + (-2) \text{Europe} + 2(-0.1) \text{Inflation} \\ &= -1 - 2 \text{Europe} - 0.2 \text{Inflation} \end{aligned} \]

    3. What is the average marginal contrast for inflation in this model?

      Answer:

      The average marginal contrast of inflation is given by

      \[ \begin{aligned} AMC_{\text{Inflation}} = \mathbb{E}\left[\frac{\partial \mathbb{E}[\text{pcGDP}|\text{Inflation}, \text{Europe}, \text{Democracy}]}{\partial \text{Inflation}}\right] &= \mathbb{E}[-1 - 2 \text{Europe} - 0.2 \text{Inflation}] \\ &= -1 - 2 \mathbb{E}[\text{Europe}] - 0.2 \mathbb{E}[\text{Inflation}] \end{aligned} \]

    4. Given the relevant data, how would you estimate the average marginal contrast for inflation?

      Answer:

      First, run the regression of pcGDP on Inflation, Europe, Inflation*Europe, Inflation^2, and Democracy and recover the estimated coefficients \(\hat{\beta}_0\), _1, _2$, \(\hat{\beta}_3\), and \(\hat{\beta}_4\). Then, compute

      \[ \widehat{AMC}_{\text{Inflation}} = \hat{\beta}_1 + \hat{\beta}_2 \overline{\text{Europe}} + 2 \hat{\beta}_3 \overline{\text{Inflation}} \]

      where \(\overline{\text{Europe}}\) and \(\overline{\text{Inflation}}\) are the sample averages of Europe and Inflation (for Europe, this is just the fraction of countries located in Europe).



  1. Extra Question #3 from Chapter 12.

    Answer:

    1. You can run the following regression

      \[Earnings = \beta_0 + \beta_1 Education + \beta_2 Female + \beta_3 Education \times Female + U\]

      In this regression, the marginal contrast of education is \(\beta_1 + \beta_3 Female\), i.e., the difference in the marginal contrast for women relative to men is given by \(\beta_3\). Then, you can test whether \(\beta_3=0\). If it is different from 0, that would indicate that the marginal contrast for education is different for women relative to men.

    2. You can estimate the following regression

      \[Earnings = \beta_0 + \beta_1 Education + \beta_2 Female + \beta_3 Education \times Female + \beta_4 Experience + U\]

      and continue to test whether \(\beta_3=0\).



  1. Extra Question #4 from Chapter 12.

    Answer: Comparing people with the same experience and sex, on average, people with one more year of education have \(100 \beta_1\) percent higher earnings.



  1. Coding Question #1 from Chapter 13

    Answer:

    1. \(\text{ }\)

      library(wooldridge)
      library(marginaleffects)
      data(mroz)
      probit_res <- glm(inlf ~ kidslt6 + kidsge6,
                        data = mroz,
                        family=binomial(link=probit))
      probit_amc <- avg_slopes(probit_res)
      probit_amc
      
          Term Estimate Std. Error      z Pr(>|z|)    S   2.5 %  97.5 %
       kidsge6  0.00621     0.0135  0.462    0.644  0.6 -0.0202  0.0326
       kidslt6 -0.20554     0.0335 -6.139   <0.001 30.2 -0.2712 -0.1399
      
      Type: response
      Comparison: dY/dX

      Comparing mothers with the same number of kids that are 6 or older, on average, mothers in families with one more kid less than 6 years old participate in the labor force about 21 percentage points less.

      Comparing mothers with the same number of kids that are less than 6 years old old, on average, mothers in families with one more kid 6 or older paticipate in the labor force at roughly the same rate.

    2. \(\text{ }\)

      probit_res2 <- glm(inlf ~ kidslt6 + kidsge6 + age + educ + city,
                         data = mroz,
                         family=binomial(link=probit))
      probit_amc2 <- avg_slopes(probit_res2)
      probit_amc2
      
          Term Contrast Estimate Std. Error      z Pr(>|z|)    S   2.5 %   97.5 %
       age        dY/dX  -0.0132    0.00251 -5.278   <0.001 22.9 -0.0181 -0.00831
       city       1 - 0  -0.0303    0.03583 -0.846    0.397  1.3 -0.1006  0.03991
       educ       dY/dX   0.0435    0.00747  5.816   <0.001 27.3  0.0288  0.05812
       kidsge6    dY/dX  -0.0191    0.01417 -1.348    0.178  2.5 -0.0469  0.00867
       kidslt6    dY/dX  -0.3116    0.03494 -8.919   <0.001 60.9 -0.3801 -0.24315
      
      Type: response

      Comparing mothers with the same number of kids that are 6 or older that are the same age, have the same years of education, and are the same in terms of whether or not they live in a city, on average, mothers with one more kid younger than 6 participate in the labor force about 31 percentage points less.

      Comparing mothers with the same number of kids that are less than 6 years old that are the same age, have the same years of eduation, and are the same in terms of whether or not they live in a city, on average, mothers with one more kid 6 or older participate in the labor force about 2 percentage point less (not statistically different from 0).

    3. \(\text{ }\)

      # logit
      logit_res2 <- glm(inlf ~ kidslt6 + kidsge6 + age + educ + city,
                        data = mroz,
                        family=binomial(link=logit))
      
      # linear probability model
      lpm_res2 <- lm(inlf ~ kidslt6 + kidsge6 + age + educ + city,
                        data = mroz)
      
      
      # show estimated coefficients for probit, logit, and linear probability model
      library(modelsummary)
      modelsummary(list(probit_res2, logit_res2, lpm_res2))
      (1) (2) (3)
      (Intercept) 0.605 1.008 0.708
      (0.465) (0.771) (0.162)
      kidslt6 -0.885 -1.469 -0.307
      (0.113) (0.195) (0.036)
      kidsge6 -0.054 -0.091 -0.017
      (0.040) (0.067) (0.014)
      age -0.038 -0.062 -0.013
      (0.007) (0.013) (0.003)
      educ 0.123 0.204 0.043
      (0.023) (0.038) (0.008)
      city -0.086 -0.148 -0.034
      (0.102) (0.169) (0.036)
      Num.Obs. 753 753 753
      R2 0.124
      R2 Adj. 0.118
      AIC 941.5 941.3 992.9
      BIC 969.3 969.0 1025.3
      Log.Lik. -464.755 -464.651 -489.441
      F 17.518 16.009 21.204
      RMSE 0.46 0.46 0.46
      # show estimated average marginal contrasts
      modelsummary(list(avg_slopes(probit_res2),
                        avg_slopes(logit_res2),
                        avg_slopes(lpm_res2)))
      (1) (2) (3)
      age -0.013 -0.013 -0.013
      (0.003) (0.003) (0.003)
      city -0.030 -0.032 -0.034
      (0.036) (0.036) (0.036)
      educ 0.043 0.044 0.043
      (0.007) (0.008) (0.008)
      kidsge6 -0.019 -0.020 -0.017
      (0.014) (0.014) (0.014)
      kidslt6 -0.312 -0.315 -0.307
      (0.035) (0.036) (0.036)
      Num.Obs. 753 753 753
      R2 0.124
      R2 Adj. 0.118
      AIC 941.5 941.3 992.9
      BIC 969.3 969.0 1025.3
      Log.Lik. -464.755 -464.651 -489.441
      F 17.518 16.009 21.204
      RMSE 0.46 0.46 0.46

      Notice that the coefficients are quite different, but the average marginal contrasts are all similar. In general, this is what we would expect here, and we are ultimately interested in the average marginal contrasts rather than the coefficients themselves.