Announcement

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

  • Fixed effects instrumental variable estimator using the sem command

    Dear Stata forum

    I am currently trying to run a fixed effects instrumental variable estimator on a panel dataset using the sem command, similar as to what xtivreg, fe does (step 1). The reason I would like to use the sem command, is to then in the second step run a fixed effects instrumental variable estimator on a mediation model, which is only possible with the sem command, and not with the xtivreg, fe command. I have not found any examples in the manual, nor on the Statalist forum. I therefore tried to code it myself using one of Stata's online available datasets as an example. However, the models do not converge.

    Code:
    Code:
    webuse nlswork, clear
    tsset idcode year
    
    ** fixed effects instrumental variable estimation on a single equation model (treatment = tenure; outcome = ln_wage) using xtivreg, fe
    xtivreg ln_wage age c.age#c.age not_smsa (tenure = union south), fe
    
    ** Step 1: fixed effects instrumental variable estimation on a single equation model (treatment = tenure; outcome = ln_wage) using sem: no convergence
    gen age_sq = c.age#c.age
    keep ln_wage age age_sq not_smsa tenure union south idcode year
    reshape wide ln_wage age age_sq not_smsa tenure union south, i(idcode) j(year)
    sem (ln_wage68 <- age68@a age_sq68@b not_smsa68@c tenure68@d union68@e south68@f Alpha@1) ///
            (ln_wage69 <- age69@a age_sq69@b not_smsa69@c tenure69@d union69@e south69@f Alpha@1) ///
            (ln_wage70 <- age70@a age_sq70@b not_smsa70@c tenure70@d union70@e south70@f Alpha@1) ///
            (ln_wage71 <- age71@a age_sq71@b not_smsa71@c tenure71@d union71@e south71@f Alpha@1) ///
            (ln_wage72 <- age72@a age_sq72@b not_smsa72@c tenure72@d union72@e south72@f Alpha@1) ///
            (ln_wage73 <- age73@a age_sq73@b not_smsa73@c tenure73@d union73@e south73@f Alpha@1) ///
            (ln_wage75 <- age75@a age_sq75@b not_smsa75@c tenure75@d union75@e south75@f Alpha@1) ///
            (ln_wage77 <- age77@a age_sq77@b not_smsa77@c tenure77@d union77@e south77@f Alpha@1) ///
            (ln_wage78 <- age78@a age_sq78@b not_smsa78@c tenure78@d union78@e south78@f Alpha@1) ///
            (ln_wage80 <- age80@a age_sq80@b not_smsa80@c tenure80@d union80@e south80@f Alpha@1) ///
            (ln_wage82 <- age82@a age_sq82@b not_smsa82@c tenure82@d union82@e south82@f Alpha@1) ///
            (ln_wage83 <- age83@a age_sq83@b not_smsa83@c tenure83@d union83@e south83@f Alpha@1) ///
            (ln_wage85 <- age85@a age_sq85@b not_smsa85@c tenure85@d union85@e south85@f Alpha@1) ///
            (ln_wage87 <- age87@a age_sq87@b not_smsa87@c tenure87@d union87@e south87@f Alpha@1) ///
            (ln_wage88 <- age88@a age_sq88@b not_smsa88@c tenure88@d union88@e south88@f Alpha@1) ///
            (tenure68 <- union68@g south68@h age68@i age_sq68@j not_smsa68@k Beta@1) ///
            (tenure69 <- union69@g south69@h age69@i age_sq69@j not_smsa69@k Beta@1) ///
            (tenure70 <- union70@g south70@h age70@i age_sq70@j not_smsa70@k Beta@1) ///
            (tenure71 <- union71@g south71@h age71@i age_sq71@j not_smsa71@k Beta@1) ///
            (tenure72 <- union72@g south72@h age72@i age_sq72@j not_smsa72@k Beta@1) ///
            (tenure73 <- union73@g south73@h age73@i age_sq73@j not_smsa73@k Beta@1) ///
            (tenure75 <- union75@g south75@h age75@i age_sq75@j not_smsa75@k Beta@1) ///
            (tenure77 <- union77@g south77@h age77@i age_sq77@j not_smsa77@k Beta@1) ///
            (tenure78 <- union78@g south78@h age78@i age_sq78@j not_smsa78@k Beta@1) ///
            (tenure80 <- union80@g south80@h age80@i age_sq80@j not_smsa80@k Beta@1) ///
            (tenure82 <- union82@g south82@h age82@i age_sq82@j not_smsa82@k Beta@1) ///
            (tenure83 <- union83@g south83@h age83@i age_sq83@j not_smsa83@k Beta@1) ///
            (tenure85 <- union85@g south85@h age85@i age_sq85@j not_smsa85@k Beta@1) ///
            (tenure87 <- union87@g south87@h age87@i age_sq87@j not_smsa87@k Beta@1) ///
            (tenure88 <- union88@g south88@h age88@i age_sq88@j not_smsa88@k Beta@1), var((e.ln_wage*)@l) cov((e.ln_wage68)*(e.tenure68)) cov((e.ln_wage69)*(e.tenure69)) cov((e.ln_wage70)*(e.tenure70)) cov((e.ln_wage71)*(e.tenure71)) cov((e.ln_wage72)*(e.tenure72)) cov((e.ln_wage73)*(e.tenure73)) cov((e.ln_wage75)*(e.tenure75)) cov((e.ln_wage77)*(e.tenure77)) cov((e.ln_wage78)*(e.tenure78)) cov((e.ln_wage80)*(e.tenure80)) cov((e.ln_wage82)*(e.tenure82)) cov((e.ln_wage83)*(e.tenure83)) cov((e.ln_wage85)*(e.tenure85)) cov((e.ln_wage87)*(e.tenure87)) cov((e.ln_wage88)*(e.tenure88)) nolog method(mlmv)
    
    ** Step 2: fixed effects instrumental variable estimation on a mediation model (treatment = tenure; mediator = not_smsa; outcome = ln_wage) using sem: no convergence
    sem (ln_wage68 <- age68@a age_sq68@b not_smsa68@c tenure68@d Alpha@1) ///
        (ln_wage69 <- age69@a age_sq69@b not_smsa69@c tenure69@d Alpha@1) ///
        (ln_wage70 <- age70@a age_sq70@b not_smsa70@c tenure70@d Alpha@1) ///
        (ln_wage71 <- age71@a age_sq71@b not_smsa71@c tenure71@d Alpha@1) ///
        (ln_wage72 <- age72@a age_sq72@b not_smsa72@c tenure72@d Alpha@1) ///
        (ln_wage73 <- age73@a age_sq73@b not_smsa73@c tenure73@d Alpha@1) ///
        (ln_wage75 <- age75@a age_sq75@b not_smsa75@c tenure75@d Alpha@1) ///
        (ln_wage77 <- age77@a age_sq77@b not_smsa77@c tenure77@d Alpha@1) ///
        (ln_wage78 <- age78@a age_sq78@b not_smsa78@c tenure78@d Alpha@1) ///
        (ln_wage80 <- age80@a age_sq80@b not_smsa80@c tenure80@d Alpha@1) ///
        (ln_wage82 <- age82@a age_sq82@b not_smsa82@c tenure82@d Alpha@1) ///
        (ln_wage83 <- age83@a age_sq83@b not_smsa83@c tenure83@d Alpha@1) ///
        (ln_wage85 <- age85@a age_sq85@b not_smsa85@c tenure85@d Alpha@1) ///
        (ln_wage87 <- age87@a age_sq87@b not_smsa87@c tenure87@d Alpha@1) ///
        (ln_wage88 <- age88@a age_sq88@b not_smsa88@c tenure88@d Alpha@1) ///
        (not_smsa68 <- tenure68 age68@i age_sq68@j Beta@1) ///
        (not_smsa69 <- tenure69 age69@i age_sq69@j Beta@1) ///
        (not_smsa70 <- tenure70 age70@i age_sq70@j Beta@1) ///
        (not_smsa71 <- tenure71 age71@i age_sq71@j Beta@1) ///
        (not_smsa72 <- tenure72 age72@i age_sq72@j Beta@1) ///
        (not_smsa73 <- tenure73 age73@i age_sq73@j Beta@1) ///
        (not_smsa75 <- tenure75 age75@i age_sq75@j Beta@1) ///
        (not_smsa77 <- tenure77 age77@i age_sq77@j Beta@1) ///
        (not_smsa78 <- tenure78 age78@i age_sq78@j Beta@1) ///
        (not_smsa80 <- tenure80 age80@i age_sq80@j Beta@1) ///
        (not_smsa82 <- tenure82 age82@i age_sq82@j Beta@1) ///
        (not_smsa83 <- tenure83 age83@i age_sq83@j Beta@1) ///
        (not_smsa85 <- tenure85 age85@i age_sq85@j Beta@1) ///
        (not_smsa87 <- tenure87 age87@i age_sq87@j Beta@1) ///
        (not_smsa88 <- tenure88 age88@i age_sq88@j Beta@1) ///
        (tenure68 <- union68@g south68@h age68@i age_sq68@j Gamma@1) ///
        (tenure69 <- union69@g south69@h age69@i age_sq69@j Gamma@1) ///
        (tenure70 <- union70@g south70@h age70@i age_sq70@j Gamma@1) ///
        (tenure71 <- union71@g south71@h age71@i age_sq71@j Gamma@1) ///
        (tenure72 <- union72@g south72@h age72@i age_sq72@j Gamma@1) ///
        (tenure73 <- union73@g south73@h age73@i age_sq73@j Gamma@1) ///
        (tenure75 <- union75@g south75@h age75@i age_sq75@j Gamma@1) ///
        (tenure77 <- union77@g south77@h age77@i age_sq77@j Gamma@1) ///
        (tenure78 <- union78@g south78@h age78@i age_sq78@j Gamma@1) ///
        (tenure80 <- union80@g south80@h age80@i age_sq80@j Gamma@1) ///
        (tenure82 <- union82@g south82@h age82@i age_sq82@j Gamma@1) ///
        (tenure83 <- union83@g south83@h age83@i age_sq83@j Gamma@1) ///
        (tenure85 <- union85@g south85@h age85@i age_sq85@j Gamma@1) ///
        (tenure87 <- union87@g south87@h age87@i age_sq87@j Gamma@1) ///
        (tenure88 <- union88@g south88@h age88@i age_sq88@j Gamma@1), var((e.ln_wage*)@l) cov((e.not_smsa68)*(e.tenure68)) cov((e.not_smsa69)*(e.tenure69)) cov((e.not_smsa70)*(e.tenure70)) cov((e.not_smsa71)*(e.tenure71)) cov((e.not_smsa72)*(e.tenure72)) cov((e.not_smsa73)*(e.tenure73)) cov((e.not_smsa75)*(e.tenure75)) cov((e.not_smsa77)*(e.tenure77)) cov((e.not_smsa78)*(e.tenure78)) cov((e.not_smsa80)*(e.tenure80)) cov((e.not_smsa82)*(e.tenure82)) cov((e.not_smsa83)*(e.tenure83)) cov((e.not_smsa85)*(e.tenure85)) cov((e.not_smsa87)*(e.tenure87)) cov((e.not_smsa88)*(e.tenure88)) method(mlmv)
    Does anyone know how to code this? Any suggestions would be highly appreciated.

    Kind regards,

    Eva
Working...
X