Dear Statalisters,
I am trying to replicate a toy instrumental variable model estimated with Stata's "sem" command with the "gmm" command. In the toy models below, I assume that "k" and "cap" are the excluded instruments for the endogenous regressor "m" and that "n" is the dependent variable. I am aware that that the first "sem" model (the model stored as "sem1") is misspecified in that the covariance between the error terms for both endogenous variables--cov(e.n*e.wage)--need to be modeled (see Paul Allison's discussion here: https://statisticalhorizons.com/iv-in-sem/). However, I do not do so in order to show that I am able to replicate that model with the "gmm" command (the model stored as "gmm1").
The third model (stored as "sem2") represents the correctly specified model (correctly in the sense that it models the covariance in the error terms of both endogenous variables--again see Paul Allision's discussion at the link above).
My question is: how can I replicate the "correctly" specified "sem" model above (the third model above, "stored as "sem2") with Stata's "gmm" command and in "structural form" (i.e., not a single equation model)? Something akin to:
I am trying to replicate a toy instrumental variable model estimated with Stata's "sem" command with the "gmm" command. In the toy models below, I assume that "k" and "cap" are the excluded instruments for the endogenous regressor "m" and that "n" is the dependent variable. I am aware that that the first "sem" model (the model stored as "sem1") is misspecified in that the covariance between the error terms for both endogenous variables--cov(e.n*e.wage)--need to be modeled (see Paul Allison's discussion here: https://statisticalhorizons.com/iv-in-sem/). However, I do not do so in order to show that I am able to replicate that model with the "gmm" command (the model stored as "gmm1").
The third model (stored as "sem2") represents the correctly specified model (correctly in the sense that it models the covariance in the error terms of both endogenous variables--again see Paul Allision's discussion at the link above).
Code:
webuse abdata, clear sem (n <- wage emp yr1977 - yr1984) /// (wage <- emp yr1977 - yr1984 k cap), vce(cluster id) estimate store sem1 gen c0 = 1 gmm (eq1: n - {xb1: wage emp yr1977 - yr1984 c0}) /// (eq2: wage - {wage: emp yr1977 - yr1984 k cap c0 }), /// instruments(eq1: wage emp yr1977 - yr1984) /// instruments(eq2: emp yr1977 - yr1984 k cap) /// winitial(unadjusted,independent) twostep vce(cluster id) estimate store gmm1 sem (n <- wage emp yr1977 - yr1984) /// (wage <- emp yr1977 - yr1984 k cap ), vce(cluster id) cov(e.n*e.wage) estimate store sem2 esttab sem1 gmm1 sem2 , order(k wage emp) b(3) se(3) drop(yr*) ------------------------------------------------------------ (1) (2) (3) ------------------------------------------------------------ main wage 0.017 0.017 0.715* (0.012) (0.012) (0.291) emp 0.063*** 0.063*** 0.090*** (0.007) (0.007) (0.018) c0 0.184 (0.316) _cons 0.184 -18.440* (0.318) (7.763) ------------------------------------------------------------ wage k 0.992** 0.992** 1.048** (0.380) (0.379) (0.401) emp -0.165*** -0.165*** -0.082*** (0.024) (0.023) (0.024) cap 0.183** 0.183** -0.083* (0.057) (0.057) (0.033) c0 27.710*** (0.808) _cons 27.710*** 27.644*** (0.810) (0.834) ------------------------------------------------------------ / var(e.n) 0.780*** 15.705 (0.094) (12.874) var(e.wage) 28.685*** 29.528*** (3.688) (3.717) cov(e.n,e.~) -21.382* (9.376) ------------------------------------------------------------ N 1031 1031 1031 ------------------------------------------------------------ Standard errors in parentheses * p<0.05, ** p<0.01, *** p<0.001
HTML Code:
gmm (eq1: n - {xb1: wage emp yr1977 - yr1984 c0}) /// (wage: wage - {wage: emp yr1977 - yr1984 k cap c0 }), /// instruments(eq1: wage emp yr1977 - yr1984) /// instruments(eq2: emp yr1977 - yr1984 k cap) /// wmatrix(cluster id) winitial(unadjusted) vce(cluster id)