Moshi Alam
  • Research
  • Teaching
  • CV

On this page

  • Question 1
    • Part (a)
    • Part (b)
    • Part (c)
    • Part (d)
    • Part (e)
  • Question 2
    • Part (a)
    • Part (b)
    • Part (c)
    • Part (d)
  • Question 3
    • Part (a)
    • Part (b)
    • Part (c)
  • Question 4
    • Part (a)
    • Part (b)
    • Part (c)
    • Part (d)
    • Part (e)
Md Moshi Ul Alam
Md Moshi Ul Alam
Assistant Professor of Economics
Clark University
Email CV

Econometrics PS 4 - Solution key

Author

Prof Alam

Question 1

Part (a)

Each graduate’s treatment effect is \delta_i = Y_i(1) - Y_i(0):

Graduate i Y_i(0) Y_i(1) D_i \delta_i
1 30 36 1 6
2 28 33 1 5
3 26 30 1 4
4 20 27 0 7
5 18 24 0 6
6 16 22 0 6
  • ATE = \frac{1}{6}(6 + 5 + 4 + 7 + 6 + 6) = \frac{34}{6} \approx 5.67: on average, the bootcamp raises starting salaries by about $5,670.
  • ATT = \frac{1}{3}(6 + 5 + 4) = 5: among those who attended, it raised salaries by $5,000 on average.
  • ATNT = \frac{1}{3}(7 + 6 + 6) = \frac{19}{3} \approx 6.33: among those who did not attend, it would have raised salaries by about $6,330 on average.

Part (b)

The observed outcome is Y_i = D_i\, Y_i(1) + (1 - D_i)\, Y_i(0):

Graduate i 1 2 3 4 5 6
Y_i 36 33 30 20 18 16

A researcher sees D_i for everyone, Y_i(1) for graduates 1 to 3 (who attended) and Y_i(0) for graduates 4 to 6 (who did not). Y_i(0) for graduates 1 to 3 and Y_i(1) for graduates 4 to 6 are counterfactuals that are never observed.

Part (c)

E[Y_i \mid D_i = 1] - E[Y_i \mid D_i = 0] = \frac{36 + 33 + 30}{3} - \frac{20 + 18 + 16}{3} = 33 - 18 = 15

The decomposition is

\underbrace{E[Y_i \mid D_i = 1] - E[Y_i \mid D_i = 0]}_{15} = \underbrace{E[Y_i(1) - Y_i(0) \mid D_i = 1]}_{ATT \,=\, 5} + \underbrace{E[Y_i(0) \mid D_i = 1] - E[Y_i(0) \mid D_i = 0]}_{\text{selection bias}}

with E[Y_i(0) \mid D_i = 1] = \frac{30 + 28 + 26}{3} = 28 and E[Y_i(0) \mid D_i = 0] = 18. So the selection bias is 28 - 18 = 10, and indeed 15 = 5 + 10.

Part (d)

The graduates who attended would have earned more than the non-attendees even without the bootcamp: their average Y_i(0) is $28,000, compared with $18,000. The observed difference in salaries mixes the effect of the bootcamp with this pre-existing difference.

The positive sign says that the graduates with higher earning potential (for example, the more able, motivated or better-connected ones) chose to attend. Here two-thirds of the observed gap of $15,000 is selection, not the effect of the bootcamp.

Part (e)

This violates SUTVA (the stable unit treatment value assumption): each graduate’s potential outcomes depend only on their own treatment, not on anyone else’s. If attendees compete with non-attendees for a fixed number of entry-level jobs, a non-attendee’s salary depends on how many of the others attended: the more bootcamp graduates there are, the fewer good jobs are left for them. Then Y_i(0) is not a single fixed number for each graduate, and the table above is not well defined.


Question 2

Part (a)

data(jtrain2)

pre <- c("age", "educ", "black", "hisp", "married", "nodegree", "re74", "re75")

balance <- t(sapply(pre, function(v) {
  s <- summary(lm(jtrain2[[v]] ~ jtrain2$train))$coefficients
  c(control = mean(jtrain2[[v]][jtrain2$train == 0]),
    treated = mean(jtrain2[[v]][jtrain2$train == 1]),
    difference = s[2, "Estimate"],
    se = s[2, "Std. Error"],
    t_stat = s[2, "t value"],
    p_value = s[2, "Pr(>|t|)"])
}))
round(balance, 3)
         control treated difference    se t_stat p_value
age       25.054  25.816      0.762 0.683  1.117   0.265
educ      10.088  10.346      0.257 0.172  1.496   0.135
black      0.827   0.843      0.016 0.036  0.455   0.649
hisp       0.108   0.059     -0.048 0.027 -1.776   0.076
married    0.154   0.189      0.035 0.036  0.980   0.327
nodegree   0.835   0.708     -0.127 0.039 -3.215   0.001
re74       2.107   2.096     -0.011 0.516 -0.022   0.982
re75       1.267   1.532      0.265 0.303  0.875   0.382

If randomization works, the treatment and control groups are the same on average, so we expect the differences to be small and not statistically significant. Most of them are: the differences in age, schooling, race, marital status and 1974 and 1975 earnings are small and not statistically significant. But two differences are statistically significant:

  • Trainees are 12.7 percentage points less likely to lack a high school degree. This is significant at the 1% level (t = -3.22).
  • Trainees are 4.8 percentage points less likely to be Hispanic. This is significant at the 10% level (t = -1.78).

So the groups are not fully balanced. This is a concern if these characteristics affect earnings. For example, men with a high school degree tend to earn more, so the trainees might have earned more in 1978 even without training. The simple comparison of 1978 earnings in (b) would then overstate the effect of training.

Part (b)

m_exp <- lm(re78 ~ train, data = jtrain2)
summary(m_exp)

Call:
lm(formula = re78 ~ train, data = jtrain2)

Residuals:
   Min     1Q Median     3Q    Max 
-6.349 -4.555 -1.829  2.917 53.959 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)   4.5548     0.4080  11.162  < 2e-16 ***
train         1.7943     0.6329   2.835  0.00479 ** 
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 6.58 on 443 degrees of freedom
Multiple R-squared:  0.01782,   Adjusted R-squared:  0.01561 
F-statistic: 8.039 on 1 and 443 DF,  p-value: 0.004788
c(beta_hat = unname(coef(m_exp)["train"]),
  diff_means = mean(jtrain2$re78[jtrain2$train == 1]) - mean(jtrain2$re78[jtrain2$train == 0]))
  beta_hat diff_means 
  1.794343   1.794343 

With a single binary regressor, \hat{\alpha} is the average of re78 in the control group (4.555) and \hat{\alpha} + \hat{\beta} is the average in the treatment group (6.349). So \hat{\beta} is exactly the difference in means, as the output confirms.

Men assigned to job training earned on average $1,794 more in 1978 than men in the control group, who earned $4,555 on average. The difference is statistically significant at the 1% level (t = 2.84).

Part (c)

The observed difference in means decomposes as

E[Y_i \mid D_i = 1] - E[Y_i \mid D_i = 0] = \underbrace{E[Y_i(1) - Y_i(0) \mid D_i = 1]}_{ATT} + \underbrace{E[Y_i(0) \mid D_i = 1] - E[Y_i(0) \mid D_i = 0]}_{\text{selection bias}}

In the NSW experiment, training was randomly assigned, so train is independent of the potential outcomes. The men assigned to training would, on average, have earned the same as the control group without it: E[Y_i(0) \mid D_i = 1] = E[Y_i(0) \mid D_i = 0]. The selection bias is zero, and \hat{\beta} estimates the ATT (which here also equals the ATE, since the two groups are the same on average).

In most other datasets, men choose whether to enroll in training, or are selected by a caseworker. Those who enroll typically differ from those who don’t in ways that also affect earnings (motivation, ability, how poor their job prospects are), so E[Y_i(0) \mid D_i = 1] \neq E[Y_i(0) \mid D_i = 0]. The regression coefficient then mixes the effect of training with selection bias. Question 3 shows how large that bias can be.

Part (d)

m_ctrl <- lm(re78 ~ train + age + educ + black + hisp + married + re74 + re75, data = jtrain2)

stargazer(m_exp, m_ctrl, type = "text",
          column.labels = c("No controls", "Controls"),
          keep.stat = c("n", "rsq"))

=========================================
                 Dependent variable:     
             ----------------------------
                         re78            
               No controls     Controls  
                   (1)           (2)     
-----------------------------------------
train           1.794***       1.683***  
                 (0.633)       (0.632)   
                                         
age                             0.056    
                               (0.045)   
                                         
educ                           0.406**   
                               (0.176)   
                                         
black                          -2.170*   
                               (1.159)   
                                         
hisp                            0.158    
                               (1.545)   
                                         
married                         -0.140   
                               (0.878)   
                                         
re74                            0.083    
                               (0.077)   
                                         
re75                            0.052    
                               (0.134)   
                                         
Constant        4.555***        0.622    
                 (0.408)       (2.447)   
                                         
-----------------------------------------
Observations       445           445     
R2                0.018         0.055    
=========================================
Note:         *p<0.1; **p<0.05; ***p<0.01

Holding the controls fixed, men assigned to training earned on average $1,683 more in 1978 than the control group. The estimate is still significant at the 1% level (t = 2.66). It is close to the estimate of 1.794 in (b), and the standard error is almost identical (0.632 versus 0.633).

Why the estimate barely changes. Random assignment makes train unrelated to the controls: in (a), none of them differs between the groups at the 5% level. In the omitted variable bias formula, the slope from regressing each control on train is about zero, so leaving the controls out causes essentially no bias, and adding them leaves the estimate where it was. The small drop is in line with the trainees having slightly more years of schooling in (a).

Using the hint.

aux <- lm(train ~ age + educ + black + hisp + married + re74 + re75, data = jtrain2)

data.frame(model = c("(b) no controls", "(d) controls"),
           sigma_hat = round(c(summary(m_exp)$sigma, summary(m_ctrl)$sigma), 3),
           r_squared = round(c(summary(m_exp)$r.squared, summary(m_ctrl)$r.squared), 3),
           se_train = round(c(summary(m_exp)$coefficients["train", "Std. Error"],
                              summary(m_ctrl)$coefficients["train", "Std. Error"]), 3))
            model sigma_hat r_squared se_train
1 (b) no controls     6.580     0.018    0.633
2    (d) controls     6.506     0.055    0.632
summary(aux)$r.squared
[1] 0.01884809
  1. Controls that help predict re78 take that variation out of the error term, so \sigma^2 falls. Here they explain little: the R^2 only rises from 0.018 to 0.055, and \hat{\sigma} only falls from 6.58 to 6.51.

  2. Because train was randomly assigned, the controls should not predict it, so R^2_{train} should be close to zero. Here it is 0.019.

  3. The small fall in \sigma^2 lowers the variance, while 1 - R^2_{train} \approx 0.981 raises it very slightly. The two roughly offset, so the standard error hardly changes. Adding controls helps more when they are strong predictors of the outcome: they then lower \sigma^2 a lot, while randomization keeps R^2_{train} near zero, so the standard error falls.

So why would a researcher still include these controls? In practice, we always control for variables that matter for the outcome. They reduce the residual variation in the outcome, \sigma^2, so we get more precise estimates, following

Var(\hat{\beta}_{train}) = \frac{\sigma^2}{(1 - R^2_{train})\, SST_{train}}

Controls also let us check that the estimate is not driven by differences between the groups like those in (a). For example, nodegree had the largest imbalance in (a). Adding it to the controls:

m_ctrl_deg <- lm(re78 ~ train + age + educ + black + hisp + married + re74 + re75 + nodegree,
                 data = jtrain2)
summary(m_ctrl_deg)$coefficients[c("train", "nodegree"), ]
            Estimate Std. Error     t value    Pr(>|t|)
train     1.67634320  0.6386822  2.62469072 0.008978095
nodegree -0.07068188  1.0043873 -0.07037313 0.943929018

The coefficient on train stays at 1.68, significant at the 1% level (t = 2.62). The coefficient on nodegree is small and not statistically significant (t = -0.07). So the degree imbalance does not drive the estimate.


Question 3

Part (a)

data(jtrain3)

m_nonexp <- lm(re78 ~ train, data = jtrain3)
summary(m_nonexp)

Call:
lm(formula = re78 ~ train, data = jtrain3)

Residuals:
    Min      1Q  Median      3Q     Max 
-21.554  -9.732  -0.866   7.705  99.620 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)  21.5539     0.3036   70.98   <2e-16 ***
train       -15.2048     1.1546  -13.17   <2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 15.15 on 2673 degrees of freedom
Multiple R-squared:  0.06092,   Adjusted R-squared:  0.06057 
F-statistic: 173.4 on 1 and 2673 DF,  p-value: < 2.2e-16

Trainees earned on average $15,205 less in 1978 than the men in the PSID comparison group. The difference is significant at the 1% level (t = -13.2).

This has the opposite sign of the experimental estimate in Question 2(b), a gain of $1,794. Taken at face value, it would say that job training lowers earnings by about $15,000 a year, which is not credible.

Part (b)

Students only need to explain why the selection bias is large and negative. For how big it is, see More details below.

pre3 <- c("age", "educ", "black", "hisp", "married", "re74", "re75")

round(data.frame(trainees = sapply(pre3, function(v) mean(jtrain3[[v]][jtrain3$train == 1])),
                 comparison = sapply(pre3, function(v) mean(jtrain3[[v]][jtrain3$train == 0]))), 3)
        trainees comparison
age       25.816     34.851
educ      10.346     12.117
black      0.843      0.251
hisp       0.059      0.033
married    0.189      0.866
re74       2.096     19.429
re75       1.532     19.063

The two groups are very different before the program. Men in the comparison group earned $19,063 on average in 1975, compared with $1,532 for the trainees. They are also older, have more schooling, are much more likely to be married and much less likely to be black. The NSW program was targeted at disadvantaged men, while the PSID sample is drawn from the general population.

So even without training, the comparison group would have earned far more in 1978 than the trainees: E[Y_i(0) \mid D_i = 1] is much smaller than E[Y_i(0) \mid D_i = 0]. The selection bias is large and negative.

More details. We can gauge the size of the selection bias because the trainees are the same 185 men as in Question 2. The randomized control group in jtrain2 tells us what they would have earned on average without training, E[Y_i(0) \mid D_i = 1] \approx 4.55. The PSID comparison group earned 21.55. So the selection bias is about -17.00, or roughly $17,000, and

\underbrace{-15.20}_{\text{observed difference}} \approx \underbrace{1.79}_{ATT \text{ (experiment)}} + \underbrace{(-17.00)}_{\text{selection bias}}

Part (c)

m_nonexp_ctrl <- lm(re78 ~ train + age + educ + black + hisp + married + re74 + re75, data = jtrain3)

stargazer(m_exp, m_ctrl, m_nonexp, m_nonexp_ctrl, type = "text",
          column.labels = c("Experiment", "Experiment", "PSID", "PSID"),
          keep.stat = c("n", "rsq"))

=======================================================
                        Dependent variable:            
             ------------------------------------------
                                re78                   
             Experiment Experiment    PSID      PSID   
                (1)        (2)        (3)        (4)   
-------------------------------------------------------
train         1.794***   1.683***  -15.205***   0.860  
              (0.633)    (0.632)    (1.155)    (0.908) 
                                                       
age                       0.056               -0.082***
                         (0.045)               (0.021) 
                                                       
educ                     0.406**              0.528*** 
                         (0.176)               (0.075) 
                                                       
black                    -2.170*               -0.543  
                         (1.159)               (0.494) 
                                                       
hisp                      0.158                2.166** 
                         (1.545)               (1.092) 
                                                       
married                   -0.140               1.220** 
                         (0.878)               (0.586) 
                                                       
re74                      0.083               0.278*** 
                         (0.077)               (0.028) 
                                                       
re75                      0.052               0.568*** 
                         (0.134)               (0.028) 
                                                       
Constant      4.555***    0.622    21.554***    0.777  
              (0.408)    (2.447)    (0.304)    (1.366) 
                                                       
-------------------------------------------------------
Observations    445        445       2,675      2,675  
R2             0.018      0.055      0.061      0.586  
=======================================================
Note:                       *p<0.1; **p<0.05; ***p<0.01

Holding the controls fixed, trainees earned on average $860 more in 1978 than comparison men. This is not statistically significant (t = 0.95).

The controls move the estimate a long way, from -15.20 to 0.86, and give it the right sign. But it is still only about half of the experimental estimate (1.68 with the same controls), and it cannot be distinguished from zero.

Controlling for observable characteristics can only remove the part of the selection bias that comes from the variables we measure. Trainees and comparison men also differ in things we do not observe, such as motivation, ability, health or why they ended up in a program for disadvantaged workers. These still bias the estimate. And without the experiment as a benchmark, we would have no way of knowing how far off the estimate is.


Question 4

Note

Note on standard errors. The standard errors in this question are clustered by person (cluster = ~nr), as the problem set asked. We did not have time to cover clustered standard errors in class, but this is the correct way to compute them with panel data. The same man appears in all 8 years, and the unobserved factors that affect his wage in one year are likely related to those in other years. The usual standard errors treat all 4,360 observations as independent, and here they would be too small.

Part (a)

data(wagepan)

c(observations = nrow(wagepan), men = length(unique(wagepan$nr)))
observations          men 
        4360          545 
table(table(wagepan$nr))

  8 
545 
status <- tapply(wagepan$union, wagepan$nr, function(x) {
  if (all(x == 1)) "always union" else if (all(x == 0)) "never union" else "switcher"
})
table(status)
status
always union  never union     switcher 
          34          265          246 

Yes, it is a balanced panel: each of the 545 men is observed in all 8 years, giving 4,360 observations. 246 men switch union status at least once.

Fixed effects use only the variation within each man over time. For a man whose union status never changes, union minus his own average is zero in every year, so he contributes nothing to estimating the union coefficient. The fixed effects estimate of the union premium therefore comes entirely from the 246 switchers.

Part (b)

pooled <- feols(lwage ~ union + married + educ + exper + expersq + black + hisp,
                data = wagepan, cluster = ~nr)
summary(pooled)
OLS estimation, Dep. Var.: lwage
Observations: 4,360
Standard-errors: Clustered (nr) 
             Estimate Std. Error   t value   Pr(>|t|)    
(Intercept) -0.034706   0.120104 -0.288965 7.7272e-01    
union        0.180073   0.027580  6.529027 1.5200e-10 ***
married      0.107666   0.026081  4.128115 4.2318e-05 ***
educ         0.099388   0.009208 10.793267  < 2.2e-16 ***
exper        0.089179   0.012443  7.166995 2.5097e-12 ***
expersq     -0.002849   0.000871 -3.272085 1.1353e-03 ** 
black       -0.143842   0.050112 -2.870430 4.2587e-03 ** 
hisp         0.015698   0.039198  0.400479 6.8896e-01    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
RMSE: 0.480302   Adj. R2: 0.185278

Holding marital status, schooling, experience and race fixed, men whose wages are set in a union contract earn about 18.0% higher hourly wages on average than men who are not. The coefficient is significant at the 1% level (t = 6.53).

Part (c)

fe <- feols(lwage ~ union + married + educ + exper + expersq + black + hisp | nr,
            data = wagepan, cluster = ~nr)

etable(pooled, fe, signif.code = c("***" = 0.01, "**" = 0.05, "*" = 0.10))
                             pooled                  fe
Dependent Var.:               lwage               lwage
                                                       
Constant           -0.0347 (0.1201)                    
union            0.1801*** (0.0276)  0.0821*** (0.0228)
married          0.1077*** (0.0261)   0.0453** (0.0210)
educ             0.0994*** (0.0092)                    
exper            0.0892*** (0.0124)  0.1168*** (0.0107)
expersq         -0.0028*** (0.0009) -0.0043*** (0.0007)
black           -0.1438*** (0.0501)                    
hisp                0.0157 (0.0392)                    
Fixed-Effects:  ------------------- -------------------
nr                               No                 Yes
_______________ ___________________ ___________________
S.E.: Clustered              by: nr              by: nr
Observations                  4,360               4,360
R2                          0.18659             0.61974
Within R2                        --             0.17804
---
Signif. codes: 0 '***' 0.01 '**' 0.05 '*' 0.1 ' ' 1
fe$collin.var
[1] "educ"  "black" "hisp" 

Comparing the same man across years, and holding his marital status and experience fixed, his hourly wage is about 8.2% higher in years when he is covered by a union contract than in years when he is not. The coefficient is significant at the 1% level (t = 3.60).

educ, black and hisp drop out. None of them changes over time for any man in the sample (all of them have finished school by 1980), so each is perfectly collinear with the person fixed effects. The within transformation turns them into zeros, and their effects are absorbed into a_i.

Part (d)

One example is a worker’s unobserved ability or productivity. Pooled OLS leaves it in the error term. It raises wages, and it is likely to be positively related to union membership: union jobs pay above-market wages, so union employers can choose from many applicants and hire the most productive ones. By the omitted variable bias formula, the bias is (effect of ability on wages) × (relationship between ability and union) > 0. Pooled OLS therefore overstates the union premium, attributing to the union part of the higher wages that more productive workers would earn anyway.

Person fixed effects remove all time-invariant traits like this, which is why the estimate falls from 0.180 to 0.082.

Part (e)

twfe <- feols(lwage ~ union + married + educ + exper + expersq + black + hisp | nr + year,
              data = wagepan, cluster = ~nr)

etable(pooled, fe, twfe, signif.code = c("***" = 0.01, "**" = 0.05, "*" = 0.10))
                             pooled                  fe                twfe
Dependent Var.:               lwage               lwage               lwage
                                                                           
Constant           -0.0347 (0.1201)                                        
union            0.1801*** (0.0276)  0.0821*** (0.0228)  0.0800*** (0.0227)
married          0.1077*** (0.0261)   0.0453** (0.0210)   0.0467** (0.0210)
educ             0.0994*** (0.0092)                                        
exper            0.0892*** (0.0124)  0.1168*** (0.0107)                    
expersq         -0.0028*** (0.0009) -0.0043*** (0.0007) -0.0052*** (0.0008)
black           -0.1438*** (0.0501)                                        
hisp                0.0157 (0.0392)                                        
Fixed-Effects:  ------------------- ------------------- -------------------
nr                               No                 Yes                 Yes
year                             No                  No                 Yes
_______________ ___________________ ___________________ ___________________
S.E.: Clustered              by: nr              by: nr              by: nr
Observations                  4,360               4,360               4,360
R2                          0.18659             0.61974             0.62091
Within R2                        --             0.17804             0.02157
---
Signif. codes: 0 '***' 0.01 '**' 0.05 '*' 0.1 ' ' 1
twfe$collin.var
[1] "educ"  "exper" "black" "hisp" 

Year fixed effects control for anything that shifts the wages of all men in the sample equally in a given year, such as economy-wide wage growth, inflation or the recession of the early 1980s.

exper drops out because every man gains exactly one year of experience each year: exper_{it} = exper_{i,1980} + (t - 1980). The first term is constant for each man, so the person fixed effects absorb it. The second term is the same for everyone in a given year, so the year fixed effects absorb it. exper is therefore a perfect linear combination of the fixed effects. expersq stays because the square is not linear in the year.

  • Copyright 2021, Md Moshi Ul Alam. Website created using Quarto.