Announcement

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

  • error message with estout

    Hi,

    I am encountering an error message when trying to save the the results of a sensitivity analysis to a text file with the "estout" command.
    My primary analysis uses conditional logistic regression on multiply imputed data (m=20). I am now trying to run a sensitivity analysis wherein I alter exposure classification (exposed -->unexposed) among my cases (gsw) by 5%, 10%, etc to demonstrate the impact exposure missclassification might have on my results. I am randomly selecting 5% (up to 40% by increments of 5%) of cases and altering exposure status, and then recalculating my main OR of interest. I would like to run this using a loop with 100 iterations at each missclassification level (5-40%). Ideally, I would then summarize the results across the 100 random iterations and ultimately generate a summary table of the sensitivity analysis results by % missclassification.

    With the code below, I am able to reclassify the exposure status of a random sample of cases (here 5%). I am then able to run my conditional logistic model and have the results show up in the STATA output screen. However, when I run the estout command, I get the following error message:
    "coefficient gsw_connect2 not found
    r(111);"

    It seems that STATA is not storing the model estimates in a format that is compatible with the estout command.

    I tried to manually save the model estimates, and then run the estout command but it still doesn’t work.
    But if I type
    estimates store gsw1
    estimates replay gsw1
    Then STATA will pull the model back up
    However, the estout command still says the gsw_connect2 variable is empty.

    I get the same error message if I try to keep a different variable estimate (one of my model covariates, such as alc)

    I am able to run the estout command if I remove " keep(gsw_connect2)"
    estout using "C:\Users\culyba\Documents\STARS\STARS sensitivity analysis\viol_invlv0_ca1to0for5pct.txt", append cells("b se t p ci_l ci_u") eform
    However, this just creates a text file with the headers "b se t p ci_l ci_u" that is otherwise empty

    Any advice on how to capture the model estimates from each of these runs of my sensitivity analysis is greatly appreciated. Copying and pasting results from 800 models is definitely not an option. Is there a command other than estout that I should use? Is there a better way to save all of the model estimates across the 5-40% missclassification estimates x100 runs, that will work in a loop format?

    Thanks so much!

    ~Alison

    gsort -connect2 -gsw age3
    gen random1=uniform() if gsw==1 & connect2==1
    gsort random1 -connect2 -gsw age3

    gen n= _n if gsw==1 & connect2==1
    gen usingset=1 if _n ~=. & gsw==1 & connect2==1
    bysort usingset: egen bign= max(n) if gsw==1 & connect2==1
    gen keeper= n / bign

    gen gsw_connect2=connect2
    recode gsw_connect2 1=0 if keeper <= 0.05
    tab connect2 if gsw==1
    tab gsw_connect2 if gsw==1


    mi estimate, or: clogit gsw gsw_connect2 sch__ sch_safe_high days_act_y work alc juv_prob nes_sum i.z_hmenvirpscore4 if viol_invlv_score2==0, group(age3)
    estout using "C:\Users\culyba\Documents\STARS\STARS sensitivity analysis\viol_invlv0_ca1to0for5pct.txt", keep(gsw_connect2) append cells("b se t p ci_l ci_u") eform

  • #2
    Welcome to Statalist!

    This is a puzzler: I would expect what you have done to have worked, and cannot find any documentation suggesting why it might fail. Since you haven't gotten any suggestions from more knowledgeable users of estout, let me suggest, not a diagnosis but a further test that may shed some light.

    In the example you show at the bottom of your post, try adding the following between your mi estimate and estout commands.
    Code:
    ereturn list
    mat list e(b)
    In theory, the first command should show e(b) in the matrices portion of its output, and the second command should list your coefficient estimates. It will be interesting to learn the results.

    With that said, a little advice about posting on Statalist. Please review the Statalist FAQ linked to from the top of the page, as well as from the Advice on Posting link on the page you used to create your post. See especially sections 9-12 on how to best pose your question. It's particularly helpful to copy commands and output from your Stata Results window and paste them into your Statalist post using CODE delimiters, as described in section 12 of the FAQ. CODE delimiters can also be inserted manually, for example:

    [code]
    // sample code
    sysuse auto, clear
    describe
    [/code]

    will be presented in the post in the following more readable format:
    Code:
    // sample code
    sysuse auto, clear
    describe

    Comment


    • #3
      William,

      Thank you so much for your suggestion. For clarification, I am using STATA 12.1
      I am unable to post my dataset because it contains patient identifiers. The imputed dataset contains 1,143 variables and 8,337 observations in m=20
      I tried adding the code lines you suggested. I get an analogous error message with the "mat list e(b)" command: "matrix e(b) not found." Any additional guidance you can provide is greatly appreciated.

      Here is the output I received



      Code:
      
      . gsort -connect2  -gsw age3
      
      . gen random1=uniform() if gsw==1 & connect2==1
      (6069 missing values generated)
      
      . gsort random1  -connect2  -gsw age3 
      
      . 
      . gen n= _n if gsw==1 & connect2==1
      (6069 missing values generated)
      
      . gen usingset=1 if _n ~=. & gsw==1 & connect2==1
      (6069 missing values generated)
      
      . bysort usingset: egen bign= max(n) if gsw==1 & connect2==1
      (6069 missing values generated)
      
      . gen keeper= n / bign
      (6069 missing values generated)
      
      . 
      . gen gsw_connect2=connect2
      
      . recode gsw_connect2 1=0 if keeper <= 0.05
      (gsw_connect2: 113 changes made)
      
      . tab connect2 if gsw==1
      
      Presense of |
            adult |
       connection |      Freq.     Percent        Cum.
      ------------+-----------------------------------
                0 |        378       14.29       14.29
                1 |      2,268       85.71      100.00
      ------------+-----------------------------------
            Total |      2,646      100.00
      
      . tab gsw_connect2 if gsw==1
      
      gsw_connect |
                2 |      Freq.     Percent        Cum.
      ------------+-----------------------------------
                0 |        491       18.56       18.56
                1 |      2,155       81.44      100.00
      ------------+-----------------------------------
            Total |      2,646      100.00
      
      .   
      . 
      . mi estimate, or: clogit gsw gsw_connect2 sch__ sch_safe_high days_act_y work alc juv_prob nes_sum i.z_hmenvirpscore4 if v
      > iol_invlv_score2==0, group(age3)
      
      Multiple-imputation estimates                     Imputations     =         20
      Conditional (fixed-effects) logistic regression   Number of obs   =        222
                                                        Average RVI     =     0.0212
                                                        Largest FMI     =     0.1363
      DF adjustment:   Large sample                     DF:     min     =    1047.43
                                                                avg     = 1619108.53
                                                                max     = 8000423.76
      Model F test:       Equal FMI                     F(  11,465635.7)=       2.80
      Within VCE type:          OIM                     Prob > F        =     0.0012
      
      ----------------------------------------------------------------------------------
                   gsw | Odds Ratio   Std. Err.      t    P>|t|     [95% Conf. Interval]
      -----------------+----------------------------------------------------------------
          gsw_connect2 |    .653076   .3337028    -0.83   0.405     .2396191    1.779943
                 sch__ |   .5423781   .2180158    -1.52   0.128     .2466894    1.192487
         sch_safe_high |   1.968524   .7809506     1.71   0.088     .9045897    4.283805
            days_act_y |    .908012   .3315656    -0.26   0.792     .4438572    1.857547
                  work |   .9252271   .3405565    -0.21   0.833     .4497045    1.903573
                   alc |   .7881193   .2915588    -0.64   0.520     .3816773    1.627375
              juv_prob |   5.659724   2.238046     4.38   0.000     2.607359    12.28541
               nes_sum |   .9915713   .0417202    -0.20   0.841     .9130816    1.076808
                       |
      z_hmenvirpscore4 |
                    1  |   1.003535   .4609091     0.01   0.994     .4079325     2.46875
                    2  |   .8391787    .383807    -0.38   0.701     .3424112    2.056653
                    3  |   1.190195   .5450804     0.38   0.704       .48505    2.920449
      ----------------------------------------------------------------------------------
      
      . ereturn list
      
      scalars:
               e(mcerror_mi) =  0
                 e(N_min_mi) =  222
                 e(N_max_mi) =  222
               e(cilevel_mi) =  95
             e(reparm_rc_mi) =  .
            e(k_eq_model_mi) =  1
                e(df_min_mi) =  1047.428114277422
                e(df_avg_mi) =  1619108.528277194
                e(df_max_mi) =  8000423.756894743
               e(fmi_max_mi) =  .136331140938986
               e(rvi_avg_mi) =  .0212270303934094
                     e(p_mi) =  .0011984385365101
                  e(ufmi_mi) =  0
             e(rvi_avg_F_mi) =  .0212270303934094
                     e(F_mi) =  2.79725883963474
                  e(df_m_mi) =  11
                  e(df_r_mi) =  465635.6788777547
                  e(df_c_mi) =  .
                     e(N_mi) =  222
                     e(M_mi) =  20
             e(esampvary_mi) =  0
                e(N_drop_mi) =  33
          e(N_group_drop_mi) =  1
                        e(p) =  .
                     e(df_m) =  .
                       e(ic) =  3
                       e(ll) =  .
                e(k_autoCns) =  1
                e(converged) =  1
                     e(k_dv) =  1
                        e(k) =  12
                       e(rc) =  0
               e(k_eq_model) =  1
                        e(N) =  222
                   e(N_drop) =  33
                     e(ll_0) =  .
                     e(r2_p) =  .
                     e(rank) =  .
             e(N_group_drop) =  1
                     e(chi2) =  .
                     e(k_eq) =  1
               e(_dfnote_mi) =  0
                 e(k_exp_mi) =  0
      
      macros:
                    e(which) : "max"
                      e(vce) : "oim"
                    e(title) : "Conditional (fixed-effects) logistic regression"
              e(marginsprop) : "addcons"
             e(marginsnotok) : "default Pc1 STDP DBeta DX2 GDBeta GDX2 Hat Residuals RSTAndard SCore"
                 e(chi2type) : "LR"
                e(ml_method) : "e2"
          e(singularHmethod) : "m-marquardt"
                   e(depvar) : "gsw"
                      e(opt) : "moptimize"
                 e(crittype) : "log likelihood"
                     e(user) : "clogit_lf"
                 e(multiple) : "multiple"
                    e(group) : "age3"
                e(technique) : "nr"
                  e(cmdline) : "clogit gsw gsw_connect2 sch__ sch_safe_high days_act_y work alc juv_prob nes_sum i.z_hmenvirp.."
             e(names_vvs_mi) : "p ll r2_p chi2"
             e(names_vvm_mi) : "gradient ilog"
                     e(m_mi) : "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20"
                 e(m_est_mi) : "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20"
                    e(rc_mi) : "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0"
              e(dfadjust_mi) : "Large sample"
             e(modeltest_mi) : "Equal FMI"
                e(_efopt_mi) : "or"
                  e(wvce_mi) : "oim"
                 e(title_mi) : "Multiple-imputation estimates"
                e(prefix_mi) : "mi estimate"
                   e(cmd_mi) : "clogit"
                  e(ecmd_mi) : "clogit"
                      e(cmd) : "mi estimate"
                       e(mi) : "mi"
              e(_predict_mi) : "clogit_p"
            e(_marginsok_mi) : "PU0 XB"
              e(multiple_mi) : "multiple"
               e(cmdline_mi) : "mi estimate , or: clogit gsw gsw_connect2 sch__ sch_safe_high days_act_y work alc juv_prob ne.."
             e(_sortseed_mi) : "1885119593"
          e(_sortseedcmd_mi) : "669231289"
      
      matrices:
                 e(gradient) :  1 x 1
                     e(ilog) :  1 x 1
                   e(Cns_mi) :  1 x 13
                    e(re_mi) :  1 x 12
                   e(fmi_mi) :  1 x 12
                  e(pise_mi) :  1 x 12
                   e(rvi_mi) :  1 x 12
                    e(df_mi) :  1 x 12
                     e(W_mi) :  12 x 12
                     e(B_mi) :  12 x 12
                     e(V_mi) :  12 x 12
                     e(b_mi) :  1 x 12
      
      . mat list e(b)
      matrix e(b) not found
      r(111);
      
      end of do-file
      
      r(111);
      
      
      . estout using "C:\Users\culyba\Documents\STARS\STARS sensitivity analysis\viol_invlv0_ca1to0for5pct.txt",  keep(gsw_connec
      > t2) append   cells("b se t p ci_l ci_u") eform
      coefficient gsw_connect2 not found
      r(111);
      
      end of do-file

      Comment


      • #4
        End of the day for me so this will have to be terse.

        Apparently mi does not store its estimates in, for example, e(b) where estout is expecting, but instead in e(b_mi). So if I understand help estout correctly, in your cells option you are going to need something like
        Code:
        cells("b_mi pise_mi ...")
        I suggest you try
        Code:
        matrix list e(b_mi)
        matrix list e(pise_mi)
        ...
        to confirm that the numbers you want (from your output table) are stored in the matrices that seem most likely.

        Comment


        • #5
          Thanks so much for the suggestion. I was able to list all of the matrices. However, aside from the beta coefficient (b_mi) I don't believe any of these correspond to my values of interest. I would like to save the standard error, t statistic, p value and 95% CI for my primary predictor variable.

          Code:
          . mi estimate, or: clogit gsw gsw_connect2 sch__ sch_safe_high days_act_y work alc juv_prob nes_sum i.z_hmenvirpscore4 if v
          > iol_invlv_score2==0, group(age3)
          
          Multiple-imputation estimates                     Imputations     =         20
          Conditional (fixed-effects) logistic regression   Number of obs   =        222
                                                            Average RVI     =     0.0114
                                                            Largest FMI     =     0.0514
          DF adjustment:   Large sample                     DF:     min     =    7255.00
                                                                    avg     = 8084701.40
                                                                    max     =   4.50e+07
          Model F test:       Equal FMI                     F(  11, 1.6e+06)=       2.82
          Within VCE type:          OIM                     Prob > F        =     0.0011
          
          ----------------------------------------------------------------------------------
                       gsw | Odds Ratio   Std. Err.      t    P>|t|     [95% Conf. Interval]
          -----------------+----------------------------------------------------------------
              gsw_connect2 |   .6654205   .3267239    -0.83   0.407     .2541461    1.742244
                     sch__ |   .5434973   .2181616    -1.52   0.129     .2474699    1.193638
             sch_safe_high |   1.973172   .7815892     1.72   0.086     .9078147     4.28877
                days_act_y |   .9092201   .3320961    -0.26   0.794     .4443602    1.860386
                      work |   .9292571     .34083    -0.20   0.841     .4528218    1.906973
                       alc |   .7884944    .291553    -0.64   0.520     .3819962    1.627564
                  juv_prob |   5.653287   2.233188     4.39   0.000     2.606485    12.26159
                   nes_sum |     .99134   .0416821    -0.21   0.836     .9129199    1.076496
                           |
          z_hmenvirpscore4 |
                        1  |   1.000226   .4586413     0.00   1.000     .4071836    2.457005
                        2  |   .8319465   .3790839    -0.40   0.686     .3405946    2.032137
                        3  |   1.182848   .5389504     0.37   0.712      .484272    2.889141
          ----------------------------------------------------------------------------------
          
          
          . ereturn list
          
          (everything but matrices eliminated from output below)
          
          
          matrices:
                     e(gradient) :  1 x 1
                         e(ilog) :  1 x 1
                       e(Cns_mi) :  1 x 13
                        e(re_mi) :  1 x 12
                       e(fmi_mi) :  1 x 12
                      e(pise_mi) :  1 x 12
                       e(rvi_mi) :  1 x 12
                        e(df_mi) :  1 x 12
                         e(W_mi) :  12 x 12
                         e(B_mi) :  12 x 12
                         e(V_mi) :  12 x 12
                         e(b_mi) :  1 x 12
          
          . mat list e(b_mi)
          
          e(b_mi)[1,12]
                       gsw:          gsw:          gsw:          gsw:          gsw:          gsw:          gsw:          gsw:
                                                                                                                             
              gsw_connect2         sch__  sch_safe_h~h    days_act_y          work           alc      juv_prob       nes_sum
          r1    -.40733604    -.60973045     .67964254    -.09516805    -.07336984    -.23762998     1.7322371    -.00869768
          
                       gsw:          gsw:          gsw:          gsw:
                        0b.            1.            2.            3.
              z_hmenvirp~4  z_hmenvirp~4  z_hmenvirp~4  z_hmenvirp~4
          r1             0     .00022615    -.18398719     .16792533
          
          . matrix list e(b_mi)
          
          e(b_mi)[1,12]
                       gsw:          gsw:          gsw:          gsw:          gsw:          gsw:          gsw:          gsw:
                                                                                                                             
              gsw_connect2         sch__  sch_safe_h~h    days_act_y          work           alc      juv_prob       nes_sum
          r1    -.40733604    -.60973045     .67964254    -.09516805    -.07336984    -.23762998     1.7322371    -.00869768
          
                       gsw:          gsw:          gsw:          gsw:
                        0b.            1.            2.            3.
              z_hmenvirp~4  z_hmenvirp~4  z_hmenvirp~4  z_hmenvirp~4
          r1             0     .00022615    -.18398719     .16792533
          
          . matrix list e(pise_mi)
          
          e(pise_mi)[1,12]
                       gsw:          gsw:          gsw:          gsw:          gsw:          gsw:          gsw:          gsw:
                                                                                                                             
              gsw_connect2         sch__  sch_safe_h~h    days_act_y          work           alc      juv_prob       nes_sum
          r1     2.6613434     .09120369     .11402582     1.9823784     .98779077      .0767557     .08488293     .35915039
          
                       gsw:          gsw:          gsw:          gsw:
                        0b.            1.            2.            3.
              z_hmenvirp~4  z_hmenvirp~4  z_hmenvirp~4  z_hmenvirp~4
          r1             0      .0324973     .05871018     .09238879
          
          . matrix list e(ilog)
          
          symmetric e(ilog)[1,1]
              c1
          r1   .
          
          . matrix list e(Cns_mi)
          
          e(Cns_mi)[1,13]
               c1   c2   c3   c4   c5   c6   c7   c8   c9  c10  c11  c12  c13
          r1    0    0    0    0    0    0    0    0    1    0    0    0    0
          
          . matrix list e(re_mi)
          
          e(re_mi)[1,12]
                       gsw:          gsw:          gsw:          gsw:          gsw:          gsw:          gsw:          gsw:
                                                                                                                             
              gsw_connect2         sch__  sch_safe_h~h    days_act_y          work           alc      juv_prob       nes_sum
          r1     .99743477     .99990891     .99988615     .99807128     .99902565     .99992333     .99991522     .99964264
          
                       gsw:          gsw:          gsw:          gsw:
                        0b.            1.            2.            3.
              z_hmenvirp~4  z_hmenvirp~4  z_hmenvirp~4  z_hmenvirp~4
          r1             0     .99996752     .99994134     .99990773
          
          . matrix list e(fmi_mi)
          
          e(fmi_mi)[1,12]
                       gsw:          gsw:          gsw:          gsw:          gsw:          gsw:          gsw:          gsw:
                                                                                                                             
              gsw_connect2         sch__  sch_safe_h~h    days_act_y          work           alc      juv_prob       nes_sum
          r1     .05143647     .00182193     .00227717     .03864901     .01950602      .0015336      .0016958     .00714983
          
                       gsw:          gsw:          gsw:          gsw:
                        0b.            1.            2.            3.
              z_hmenvirp~4  z_hmenvirp~4  z_hmenvirp~4  z_hmenvirp~4
          r1             0     .00064967     .00117332     .00184558
          
          . matrix list e(pise_mi)
          
          e(pise_mi)[1,12]
                       gsw:          gsw:          gsw:          gsw:          gsw:          gsw:          gsw:          gsw:
                                                                                                                             
              gsw_connect2         sch__  sch_safe_h~h    days_act_y          work           alc      juv_prob       nes_sum
          r1     2.6613434     .09120369     .11402582     1.9823784     .98779077      .0767557     .08488293     .35915039
          
                       gsw:          gsw:          gsw:          gsw:
                        0b.            1.            2.            3.
              z_hmenvirp~4  z_hmenvirp~4  z_hmenvirp~4  z_hmenvirp~4
          r1             0      .0324973     .05871018     .09238879
          
          . matrix list e(rvi_mi)
          
          e(rvi_mi)[1,12]
                       gsw:          gsw:          gsw:          gsw:          gsw:          gsw:          gsw:          gsw:
                                                                                                                             
              gsw_connect2         sch__  sch_safe_h~h    days_act_y          work           alc      juv_prob       nes_sum
          r1     .05393514     .00182491     .00228182     .04004055     .01985339      .0015357     .00169838     .00719591
          
                       gsw:          gsw:          gsw:          gsw:
                        0b.            1.            2.            3.
              z_hmenvirp~4  z_hmenvirp~4  z_hmenvirp~4  z_hmenvirp~4
          r1             0     .00065005     .00117455     .00184863
          
          . matrix list  e(df_mi)
          
          e(df_mi)[1,12]
                       gsw:          gsw:          gsw:          gsw:          gsw:          gsw:          gsw:          gsw:
                                                                                                                             
              gsw_connect2         sch__  sch_safe_h~h    days_act_y          work           alc      juv_prob       nes_sum
          r1      7255.005     5726067.3     3665825.9     12818.997     50137.169     8081127.9     6609343.2     372229.22
          
                       gsw:          gsw:          gsw:          gsw:
                        0b.            1.            2.            3.
              z_hmenvirp~4  z_hmenvirp~4  z_hmenvirp~4  z_hmenvirp~4
          r1             0      45021763      13804841     5580307.1
          
          . matrix list e(W_mi)
          
          symmetric e(W_mi)[12,12]
                                     gsw:          gsw:          gsw:          gsw:          gsw:          gsw:          gsw:
                                                                                                                             
                            gsw_connect2         sch__  sch_safe_h~h    days_act_y          work           alc      juv_prob
          gsw:gsw_connect2     .22874711
                 gsw:sch__     .01619146     .16083102
          gsw:sch_safe_h~h    -.02263399    -.00818708     .15654429
            gsw:days_act_y    -.00460304    -.00296443    -.02844741     .12827414
                  gsw:work     .00745803     .02356981     .00127415     .00728341     .13190648
                   gsw:alc     .01767345     .00113314    -.00655394    -.00992138     .00421083     .13651217
              gsw:juv_prob     .02031557     .02752494    -.00769937     .01371641     .02800791     .00398562     .15578001
               gsw:nes_sum      .0005156     .00077069       .002133     .00026702    -.00085163    -.00117589     .00050556
          gsw:0b.z_hmenv~4             0             0             0             0             0             0             0
          gsw:1.z_hmenvi~4     .00508057     .01244133     .00250861    -.00208131     .00327826     .00477046     .00888649
          gsw:2.z_hmenvi~4    -.02140005      -.000571     .00170775    -.00333901       .004184      .0086709    -.01011163
          gsw:3.z_hmenvi~4    -.03941529    -.00598439      .0116493    -.01068948       .002756     .00116926     .03027609
          
                                     gsw:          gsw:          gsw:          gsw:          gsw:
                                                    0b.            1.            2.            3.
                                 nes_sum  z_hmenvirp~4  z_hmenvirp~4  z_hmenvirp~4  z_hmenvirp~4
               gsw:nes_sum     .00175526
          gsw:0b.z_hmenv~4             0             0
          gsw:1.z_hmenvi~4     .00103095             0     .21012011
          gsw:2.z_hmenvi~4    -.00083868             0     .09354537     .20738154
          gsw:3.z_hmenvi~4     .00219493             0     .09927857     .09668102      .2072227
          
          . matrix list e(B_mi)
          
          symmetric e(B_mi)[12,12]
                                     gsw:          gsw:          gsw:          gsw:          gsw:          gsw:          gsw:
                                                                                                                             
                            gsw_connect2         sch__  sch_safe_h~h    days_act_y          work           alc      juv_prob
          gsw:gsw_connect2     .01175001
                 gsw:sch__     .00069797     .00027953
          gsw:sch_safe_h~h    -.00010434    -.00014395      .0003402
            gsw:days_act_y    -.00181069    -.00004343    -.00058979     .00489159
                  gsw:work    -.00026868     .00058425    -.00040424     .00113326     .00249409
                   gsw:alc     .00096747      .0000265     .00004104    -.00064905    -.00015808     .00019966
              gsw:juv_prob     .00056139     .00012648    -.00007607     .00041415     .00048269     1.969e-06     .00025197
               gsw:nes_sum     .00016904     .00001523    -5.001e-06     .00002203     .00001687    -1.223e-06     .00002822
          gsw:0b.z_hmenv~4             0             0             0             0             0             0             0
          gsw:1.z_hmenvi~4    -.00006457      .0000782    -.00003326    -.00010936     .00019175     .00001746     .00006542
          gsw:2.z_hmenvi~4     -.0011834    -.00003247     -.0000227     .00008937      .0001231    -.00009597    -.00001892
          gsw:3.z_hmenvi~4    -.00173122     -.0001122     .00008516    -.00014884     .00003275    -.00012271    -.00006478
          
                                     gsw:          gsw:          gsw:          gsw:          gsw:
                                                    0b.            1.            2.            3.
                                 nes_sum  z_hmenvirp~4  z_hmenvirp~4  z_hmenvirp~4  z_hmenvirp~4
               gsw:nes_sum     .00001203
          gsw:0b.z_hmenv~4             0             0
          gsw:1.z_hmenvi~4     .00001046             0     .00013008
          gsw:2.z_hmenvi~4    -.00001804             0     .00004611     .00023198
          gsw:3.z_hmenvi~4    -.00001151             0     .00003751     .00020556     .00036484
          
          . matrix list e(V_mi)
          
          symmetric e(V_mi)[12,12]
                                     gsw:          gsw:          gsw:          gsw:          gsw:          gsw:          gsw:
                                                                                                                             
                            gsw_connect2         sch__  sch_safe_h~h    days_act_y          work           alc      juv_prob
          gsw:gsw_connect2     .24108462
                 gsw:sch__     .01692433     .16112452
          gsw:sch_safe_h~h    -.02274355    -.00833822     .15690149
            gsw:days_act_y    -.00650427    -.00301003    -.02906669      .1334103
                  gsw:work     .00717591     .02418327      .0008497     .00847333     .13452527
                   gsw:alc     .01868929     .00116097    -.00651085    -.01060288     .00404485     .13672182
              gsw:juv_prob     .02090503     .02765775    -.00777923     .01415127     .02851473     .00398769     .15604458
               gsw:nes_sum     .00069309     .00078668     .00212775     .00029016    -.00083392    -.00117718     .00053519
          gsw:0b.z_hmenv~4             0             0             0             0             0             0             0
          gsw:1.z_hmenvi~4     .00501278     .01252345     .00247369    -.00219613      .0034796     .00478879     .00895518
          gsw:2.z_hmenvi~4    -.02264262    -.00060509     .00168392    -.00324518     .00431326     .00857013    -.01013149
          gsw:3.z_hmenvi~4    -.04123307     -.0061022     .01173871    -.01084577     .00279039     .00104042     .03020806
          
                                     gsw:          gsw:          gsw:          gsw:          gsw:
                                                    0b.            1.            2.            3.
                                 nes_sum  z_hmenvirp~4  z_hmenvirp~4  z_hmenvirp~4  z_hmenvirp~4
               gsw:nes_sum     .00176789
          gsw:0b.z_hmenv~4             0             0
          gsw:1.z_hmenvi~4     .00104194             0      .2102567
          gsw:2.z_hmenvi~4    -.00085762             0     .09359379     .20762512
          I am able to identify all of the values I wish to save with the following command

          Code:
          gsw:3.z_hmenvi~4     .00218284             0     .09931795     .09689685     .20760577
          
          . mat list r(table)
          
          r(table)[9,12]
                           gsw:          gsw:          gsw:          gsw:          gsw:          gsw:          gsw:          gsw:
                                                                                                                                 
                  gsw_connect2         sch__  sch_safe_h~h    days_act_y          work           alc      juv_prob       nes_sum
               b     .66542055     .54349735     1.9731723     .90922013     .92925709     .78849439     5.6532868     .99134004
              se     .32672394     .21816157     .78158919     .33209606     .34083001       .291553     2.2331884     .04168214
               t    -.82959873    -1.5189975     1.7158014    -.26055324    -.20003945    -.64266157     4.3851352    -.20685974
          pvalue     .40679299     .12876317     .08619848     .79444124     .84145054     .52044374     .00001159     .83611951
              ll     .25414606     .24746988      .9078147     .44436017     .45282178     .38199618     2.6064851     .91291994
              ul     1.7422442     1.1936377     4.2887704     1.8603855     1.9069726     1.6275645      12.26159     1.0764964
              df      7255.005     5726067.3     3665825.9     12818.997     50137.169     8081127.9     6609343.2     372229.22
            crit      1.960291     1.9599644     1.9599646     1.9601491     1.9600113     1.9599643     1.9599643     1.9599704
           eform             1             1             1             1             1             1             1             1
          
                           gsw:          gsw:          gsw:          gsw:
                            0b.            1.            2.            3.
                  z_hmenvirp~4  z_hmenvirp~4  z_hmenvirp~4  z_hmenvirp~4
               b             1     1.0002262     .83194646     1.1828483
              se             .     .45864128     .37908389     .53895035
               t             .      .0004932    -.40378263     .36855008
          pvalue             .     .99960648     .68637258     .71246313
              ll             .     .40718364     .34059456     .48427204
              ul             .     2.4570054     2.0321373     2.8891407
              df             0      45021763      13804841     5580307.1
            crit             .      1.959964     1.9599642     1.9599644
           eform             1             1             1             1
          However, I cannot figure out how to save any of these with estout, or any other command

          I also tried running 2 iterations of my model and saving the estimates of each. But again, the estimates are not stored in the proper location to use this approach either.

          Code:
          mi estimate, saving(gswcon5pct_1, replace) or: clogit gsw gsw_connect2 sch__ sch_safe_high days_act_y work alc juv_prob nes_sum i.z_hmenvirpscore4 if viol_invlv_score2==0, group(age3)
          estimates store gswcon5pct_1
            drop random1 gsw_connect2  n usingset bign keeper
          
          mi estimate, saving(gswcon5pct_2, replace) or: clogit gsw gsw_connect2 sch__ sch_safe_high days_act_y work alc juv_prob nes_sum i.z_hmenvirpscore4 if viol_invlv_score2==0, group(age3)
          estimates store gswcon5pct_2
          
          estimates table gswcon5pct_1 gswcon5pct_2
          estimation result gswcon5pct_1 not found
          r(111);
          Anyone with ideas for how to save the standard error, t statistic, p value and 95% CI for my primary predictor variable from an "mi estimate" model?

          Comment


          • #6
            Alison Culyba This problem had been vexing me as well. However, if you can access r(table), then you can use putexcel. I was trying to find a solution, and I did not know that mi estimate posted anything to r(table), but it apparently does.

            Code:
            \
            putexcel set (path)
            mi estimate: (whatever your estimation command)
            matrix a = r(table)'
            putexcel A1 = matrix(a), names
            Now, I wonder if anyone can shed some light on why a simple command like regress posts r(table) when used under mi, and why the mixed command posts r(table) when used outside of mi, but mi estimate: mixed does not post to r(table)? In my case I can, I suppose, export e(b) to Excel, then go calculate the SE by hand from e(V) (it's the square of each diagonal element in the matrix), then go calculate the p-values manually, which probably involves calculating the t-statistics manually and using the degrees of freedom in e(df_mi). But I have no idea how to do that, and at this point, I would be better off just copying the darn table and pasting it into Excel, which is what I've been doing all along, but at least I don't have 800 regressions to paste, and hopefully this soliloquy will at least help Alison.
            Be aware that it can be very hard to answer a question without sample data. You can use the dataex command for this. Type help dataex at the command line.

            When presenting code or results, please use the code delimiters format them. Use the # button on the formatting toolbar, between the " (double quote) and <> buttons.

            Comment


            • #7
              Originally posted by Weiwen Ng View Post
              Alison Culyba This problem had been vexing me as well. However, if you can access r(table), then you can use putexcel. I was trying to find a solution, and I did not know that mi estimate posted anything to r(table), but it apparently does.

              Code:
              \
              putexcel set (path)
              mi estimate: (whatever your estimation command)
              matrix a = r(table)'
              putexcel A1 = matrix(a), names
              Now, I wonder if anyone can shed some light on why a simple command like regress posts r(table) when used under mi, and why the mixed command posts r(table) when used outside of mi, but mi estimate: mixed does not post to r(table)? In my case I can, I suppose, export e(b) to Excel, then go calculate the SE by hand from e(V) (it's the square of each diagonal element in the matrix), then go calculate the p-values manually, which probably involves calculating the t-statistics manually and using the degrees of freedom in e(df_mi). But I have no idea how to do that, and at this point, I would be better off just copying the darn table and pasting it into Excel, which is what I've been doing all along, but at least I don't have 800 regressions to paste, and hopefully this soliloquy will at least help Alison.
              Sorry to keep repeat posting, but I had a brainwave after this post, and I can't edit any longer.

              Apparently, the trick was to use the ereturn display command, and the post option in mi estimate. ereturn display posts to r(table), which then can be used by putexcel. I'm not certain what estout takes; if it takes r(table), there shouldn't be any further issues.

              I have a large sample (11,147 observations), and the t-statistics and p-values in ereturn display appear identical to my estimation results. I know that MI estimate uses parameter-specific degrees of freedom, but ereturn display only takes a scalar for df. Therefore, the p-values might be essentially identical between the mi estimate table and the ereturn display table in large samples, but they might not be identical in small ones. Please be aware.

              Code:
              putexcel set (path)
              mi estimate, post: (whatever your estimation command)
              ereturn display
              matrix a = r(table)'
              putexcel A1 = matrix(a), names
              Be aware that it can be very hard to answer a question without sample data. You can use the dataex command for this. Type help dataex at the command line.

              When presenting code or results, please use the code delimiters format them. Use the # button on the formatting toolbar, between the " (double quote) and <> buttons.

              Comment

              Working...
              X