Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Correcting standard errors in manual IV procedure and within fixed effects

    Dear all

    I'm working with three level nested data:

    Individuals (childnum6), nested within...
    Nuclear families (linked by nfamid), nested within...
    Extended families (linked by efamid)

    *A sample of my data is attached below*

    My simplified baseline OLS regression to estimate a LPM is:
    Code:
    reg chmarried6 chtotal6 childnum6 chage6 feduc, cluster(nfamid)
    To control for extended family fixed effects, I de-mean the variables (denoted with d_) with respect to extended family means and run:
    Code:
    reg d_chmarried6 d_chtotal6 d_childnum6 d_chage6 d_feduc, cluster(nfamid)
    Question 1: Since I de-mean to manually remove extended family fixed effects, I need to adjust the standard errors. As I cluster at the nuclear family level, I can not use -, dof()- to do this and instead need to calculate: true variance = report variance*(report DoF/true DoF) and se = sqrt(variance). At the moment I'm doing this with a calculator. Is there is a way to calculate this within Stata using matrices? I'm not proficient enough with Stata commands to achieve this myself. Any help would be massively appreciated.

    I augment the fixed effects model with an IV component. The variable d_spfamsize is used as an instrument for endogenous chtotal6. Since both these variables are at the nuclear family level, I need to run the first stage of 2SLS at the nuclear family level (using iv_d_spfamsize) and the second stage at the individual level - i.e., need to do it manually.
    Code:
    *First Stage
    reg d_chtotal6 iv_d_spfamsize d_childnum6 d_chage6 d_feduc
    predict d_chtotal6_hatz, xb
    bysort nfamid: egen d_chtotal6_hat = mean(d_chtotal6_hatz)
    
    *Second Stage
    reg d_chmarried6 d_chtotal6_hat d_childnum6 d_chage6 d_feduc, cluster(nfamid)
    Question 2: Now I need to adjust standard errors for the de-meaning and the use of predicted values in the IV procedure. Again, any idea how to do this?

    Any help would be hugely appreciated.

    Best
    Owen

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input long efamid float nfamid byte childnum6 float(chmarried6 chtotal6 chage6 feduc spfamsize d_chmarried6 d_childnum6 d_chtotal6 d_chage6 d_feduc d_spfamsize iv_d_spfamsize)
    1200002  4 1 0 3 45 13 8       -.5         -1   0   3.333332   0    0    0
    1200002  4 2 . 3 42 13 8         .          0   0   .3333321   0    0    .
    1200002  4 3 1 3 38 13 8        .5          1   0  -3.666668   0    0    .
    1200004  7 1 1 2 42 20 3         0        -.5   0        2.5   0    0    0
    1200004  7 2 1 2 37 20 3         0         .5   0       -2.5   0    0    .
    1200005  8 1 1 2 49 14 2        .5        -.5   0         .5   0    0    0
    1200005  8 2 0 2 48 14 2       -.5         .5   0        -.5   0    0    .
    1200007 12 1 1 3 38 16 .         0         -1   0  -2.799999 -.5    .    .
    1200007 12 2 . 3 35 16 .         .          0   0  -5.799999 -.5    .    .
    1200007 12 3 1 3  . 16 .         0          1   0          . -.5    .    .
    1200007 13 1 1 3 46 17 4         0         -1   0   5.200001  .5    0    0
    1200007 13 2 1 3 43 17 4         0          0   0  2.2000008  .5    0    .
    1200007 13 3 1 3 42 17 4         0          1   0  1.2000008  .5    0    .
    1200009 15 1 1 9 50 13 9         0      -3.25   3   3.583332 -.5    0    0
    1200009 15 2 1 9 48 13 9         0      -2.25   3   1.583332 -.5    0    .
    1200009 15 3 1 9 47 13 9         0      -1.25   3  .58333206 -.5    0    .
    1200009 15 4 1 9 46 13 9         0       -.25   3  -.4166679 -.5    0    .
    1200009 15 5 1 9 45 13 9         0        .75   3  -1.416668 -.5    0    .
    1200009 15 6 1 9 44 13 9         0       1.75   3  -2.416668 -.5    0    .
    1200009 15 7 1 9 44 13 9         0       2.75   3  -2.416668 -.5    0    .
    1200009 15 8 1 9 41 13 9         0       3.75   3  -5.416668 -.5    0    .
    1200009 15 9 1 9 33 13 9         0       4.75   3 -13.416668 -.5    0    .
    1200009 16 1 1 3 60 14 .         0      -3.25  -3  13.583332  .5    .    .
    1200009 16 2 1 3 53 14 .         0      -2.25  -3   6.583332  .5    .    .
    1200009 16 3 1 3 46 14 .         0      -1.25  -3  -.4166679  .5    .    .
    1200010 18 1 0 2 34 17 .       -.5        -.5   0          2   0    .    .
    1200010 18 2 1 2 30 17 .        .5         .5   0         -2   0    .    .
    1200011 19 1 1 2 45 12 3         0        -.5   0          1   0    0    0
    1200011 19 2 1 2 43 12 3         0         .5   0         -1   0    0    .
    1200012 21 1 1 4 47 12 3       .25       -1.5   0       3.75   0    0    0
    1200012 21 2 1 4 45 12 3       .25        -.5   0       1.75   0    0    .
    1200012 21 3 0 4 43 12 3      -.75         .5   0       -.25   0    0    .
    1200012 21 4 1 4 38 12 3       .25        1.5   0      -5.25   0    0    .
    1200013 23 1 0 3 44 17 2 -.6666667         -1   0          2   0    0    0
    1200013 23 2 1 3 42 17 2  .3333333          0   0          0   0    0    .
    1200013 23 3 1 3 40 17 2  .3333333          1   0         -2   0    0    .
    1200015 28 1 0 2 42 12 4         0        -.5   0        1.5   0    0    0
    1200015 28 2 0 2 39 12 4         0         .5   0       -1.5   0    0    .
    1200016 29 1 1 3 52 13 4  .6666666         -1   0          2   0    0    0
    1200016 29 2 0 3 50 13 4 -.3333333          0   0          0   0    0    .
    1200016 29 3 0 3 48 13 4 -.3333333          1   0         -2   0    0    .
    1200017 31 1 0 2 30 14 5       -.6        -.8 -.5  -8.200001   1  1.5  1.5
    1200017 31 2 0 2 30 14 5       -.6  .20000005 -.5  -8.200001   1  1.5    .
    1200017 32 1 1 3 48 12 2        .4        -.8  .5   9.799999  -1 -1.5 -1.5
    1200017 32 2 1 3 47 12 2        .4  .20000005  .5   8.799999  -1 -1.5    .
    1200017 32 3 1 3 36 12 2        .4        1.2  .5 -2.2000008  -1 -1.5    .
    1200018 33 1 0 3 49 12 . -.3333333         -1   0          0   0    .    .
    1200018 33 2 0 3  . 12 . -.3333333          0   0          .   0    .    .
    1200018 33 3 1 3  . 12 .  .6666666          1   0          .   0    .    .
    1200019 35 1 1 4 44 18 3  .3333333 -1.1666667   1   6.833332   1  1.5  1.5
    end
Working...
X