Announcement

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

  • Identifying estimates stored in two classes

    Hi all,

    I'm analysing findings from a discrete choice experiment, and one model I'm using is a latent class model to explore heterogeneity in preferences. After running the model and getting coefficients on two classes, I want to use these estimates for each class separately to run some post-estimation predictions. I'm unsure of how to tell Stata to distinguish between the two classes, and how to use estimations from each class separately to generate predictions.

    The command I am using for the latent class model is the user contributed commands lclogit2 and lclogitml2. The code for my model is:

    Code:
    lclogit2 y, rand(ASC_IP ASC_MIX ASC_TH $X $X_x $Z $blocks) id(id) gr(id_cset) ncl(2)
    matrix from = e(b)
    lclogitml2 y, rand(ASC_IP ASC_MIX ASC_TH $X $X_x $Z $blocks) id(id) gr(id_cset) ncl(2) from(from)
    est save lc2_XxZ, replace
    Inspecting the estimates after running the model by class, produces the following:

    Code:
    matrix list  e(B)
    
    
    e(B)[2,20]
                 Coef of:      Coef of:      Coef of:      Coef of:      Coef of:
                  ASC_IP       ASC_MIX        ASC_TH  base_visit~M  base_visitTH
    Class1     6.5180372     6.1541348     5.2449522    -.12755688     .16726271
    Class2     1.4586006     1.3976973     .49437823    -.08254781    -.20532341
    
                 Coef of:      Coef of:      Coef of:      Coef of:      Coef of:
            base_urbanTH     time_cont     wait_cont       wait_qd     cost_cont
    Class1    -.14689643    -.45008707     -.4077067     .02376927    -.01418531
    Class2    -.27767452    -.29528015    -.45787678     .02667609    -.01508211
    
                 Coef of:      Coef of:      Coef of:      Coef of:      Coef of:
                    hub1     first_th1  time_cont~b1  time_con~th1  wait_con~th1
    Class1    -.05989128     .14971095     .20593715    -.01181941    -.05975712
    Class2      .4120373    -.58833088    -.09912711      .2570673    -.06389725
    
                 Coef of:      Coef of:      Coef of:      Coef of:      Coef of:
             block2_NONE   block3_NONE   block4_NONE   block5_NONE   block6_NONE
    Class1     1.1050251     5.4273555     .28909495     5.0739116     4.9461815
    Class2     .51920226    -3.3110282     .02396668     -3.692282     -4.157104

    How do I use these saved estimates to run post-estimation predictions by each class separately (tell Stata to give me separate predictions for Class1 and Class2?

    Many thanks.

  • #2
    Most estimation commands in Stata produce coefficient matrices with \(1\) row and \(k\) columns \((1 \times k)\). In your example, each class would therefore be an equation in the \(1 \times k\) matrix. I am not sure whether the official post-estimation commands, such as predict, can handle this matrix structure. If you are performing a linear prediction manually, this simply requires referring to the appropriate elements of the displayed \(B\) matrix. See:

    Code:
    help matrix extraction
    There is no reproducible example provided here, so it is not possible to illustrate this directly. You may want to post one if you are unable to make further progress.

    Comment


    • #3
      Thanks very much Andrew. I have uploaded a sample of the dataset here, along with the code for running the latent class model (it takes awhile for the model to run). I want to be able to use estimates from this model (lc2_Xx) but separately by the two classes, to run predictions using the predict command under different scenarios (using different values for the variables).

      Code:
      * Example generated by -dataex-. For more info, type help dataex
      clear
      input float id str5 id_cset float(y ASC_IP ASC_MIX ASC_TH base_visitIPM base_visitTH base_urbanTH time_cont wait_cont wait_qd cost_cont hub1 first_th1 time_contXhub1 time_contXfirst_th1 wait_contXfirst_th1)
      1 "11" 0 1 0 0 0 0 0 2.5   2     4 120 0 0   0   0   0
      1 "11" 0 0 1 0 1 0 0 1.5   2     4  90 0 1   0 1.5   2
      1 "11" 1 0 0 1 0 0 0   0   5    25  50 0 0   0   0   0
      1 "11" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
      1 "12" 0 1 0 0 1 0 0 1.5   9    81  50 0 0   0   0   0
      1 "12" 0 0 1 0 0 0 0 1.5 .75 .5625 120 1 0 1.5   0   0
      1 "12" 1 0 0 1 0 0 1   0   5    25  50 1 0   0   0   0
      1 "12" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
      1 "13" 1 1 0 0 1 0 0 1.5   5    25   0 0 0   0   0   0
      1 "13" 0 0 1 0 1 0 0 2.5 .25 .0625 120 0 0   0   0   0
      1 "13" 0 0 0 1 0 0 1   0 .75 .5625 120 0 0   0   0   0
      1 "13" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
      1 "14" 0 1 0 0 0 0 0 3.5 .75 .5625 120 0 0   0   0   0
      1 "14" 0 0 1 0 1 0 0  .5 .25 .0625   0 0 1   0  .5 .25
      1 "14" 1 0 0 1 0 1 0   0 .25 .0625   0 0 0   0   0   0
      1 "14" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
      1 "15" 0 1 0 0 1 0 0 1.5   2     4 120 0 0   0   0   0
      1 "15" 0 0 1 0 1 0 0 1.5   2     4  50 1 0 1.5   0   0
      1 "15" 1 0 0 1 0 1 0   0   2     4  50 1 0   0   0   0
      1 "15" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
      1 "16" 0 1 0 0 0 0 0 2.5   5    25  90 0 0   0   0   0
      1 "16" 0 0 1 0 1 0 0  .5   2     4  90 0 1   0  .5   2
      1 "16" 0 0 0 1 0 0 0   0 .25 .0625  90 0 0   0   0   0
      1 "16" 1 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
      1 "17" 0 1 0 0 1 0 0  .5   9    81  50 0 0   0   0   0
      1 "17" 1 0 1 0 0 0 0 3.5   5    25   0 1 1 3.5 3.5   5
      1 "17" 0 0 0 1 0 0 0   0 .75 .5625 120 1 0   0   0   0
      1 "17" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
      1 "18" 0 1 0 0 0 0 0 1.5   2     4  90 0 0   0   0   0
      1 "18" 1 0 1 0 0 0 0  .5   2     4  50 1 1  .5  .5   2
      1 "18" 0 0 0 1 0 0 0   0 .75 .5625  90 1 0   0   0   0
      1 "18" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
      2 "21" 1 1 0 0 0 0 0 2.5   2     4 120 0 0   0   0   0
      2 "21" 0 0 1 0 1 0 0 1.5   2     4  90 0 1   0 1.5   2
      2 "21" 0 0 0 1 0 0 0   0   5    25  50 0 0   0   0   0
      2 "21" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
      2 "22" 0 1 0 0 1 0 0 1.5   9    81  50 0 0   0   0   0
      2 "22" 1 0 1 0 0 0 0 1.5 .75 .5625 120 1 0 1.5   0   0
      2 "22" 0 0 0 1 0 0 1   0   5    25  50 1 0   0   0   0
      2 "22" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
      2 "23" 0 1 0 0 1 0 0 1.5   5    25   0 0 0   0   0   0
      2 "23" 1 0 1 0 1 0 0 2.5 .25 .0625 120 0 0   0   0   0
      2 "23" 0 0 0 1 0 0 1   0 .75 .5625 120 0 0   0   0   0
      2 "23" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
      2 "24" 0 1 0 0 0 0 0 3.5 .75 .5625 120 0 0   0   0   0
      2 "24" 1 0 1 0 1 0 0  .5 .25 .0625   0 0 1   0  .5 .25
      2 "24" 0 0 0 1 0 1 0   0 .25 .0625   0 0 0   0   0   0
      2 "24" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
      2 "25" 1 1 0 0 1 0 0 1.5   2     4 120 0 0   0   0   0
      2 "25" 0 0 1 0 1 0 0 1.5   2     4  50 1 0 1.5   0   0
      2 "25" 0 0 0 1 0 1 0   0   2     4  50 1 0   0   0   0
      2 "25" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
      2 "26" 0 1 0 0 0 0 0 2.5   5    25  90 0 0   0   0   0
      2 "26" 1 0 1 0 1 0 0  .5   2     4  90 0 1   0  .5   2
      2 "26" 0 0 0 1 0 0 0   0 .25 .0625  90 0 0   0   0   0
      2 "26" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
      2 "27" 0 1 0 0 1 0 0  .5   9    81  50 0 0   0   0   0
      2 "27" 0 0 1 0 0 0 0 3.5   5    25   0 1 1 3.5 3.5   5
      2 "27" 1 0 0 1 0 0 0   0 .75 .5625 120 1 0   0   0   0
      2 "27" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
      2 "28" 0 1 0 0 0 0 0 1.5   2     4  90 0 0   0   0   0
      2 "28" 0 0 1 0 0 0 0  .5   2     4  50 1 1  .5  .5   2
      2 "28" 1 0 0 1 0 0 0   0 .75 .5625  90 1 0   0   0   0
      2 "28" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
      3 "31" 1 1 0 0 1 0 0  .5   2     4  90 0 0   0   0   0
      3 "31" 0 0 1 0 0 0 0 2.5   5    25  50 0 0   0   0   0
      3 "31" 0 0 0 1 0 0 0   0   5    25  90 0 0   0   0   0
      3 "31" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
      3 "32" 0 1 0 0 1 0 0 1.5 .75 .5625  90 0 0   0   0   0
      3 "32" 0 0 1 0 0 0 0 2.5 .25 .0625  90 1 1 2.5 2.5 .25
      3 "32" 1 0 0 1 0 0 1   0 .75 .5625   0 1 0   0   0   0
      3 "32" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
      3 "33" 0 1 0 0 0 0 0 1.5 .75 .5625 120 0 0   0   0   0
      3 "33" 1 0 1 0 1 0 0 1.5 .25 .0625   0 1 1 1.5 1.5 .25
      3 "33" 0 0 0 1 0 1 0   0   2     4  50 1 0   0   0   0
      3 "33" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
      3 "34" 0 1 0 0 1 0 0 3.5   5    25 120 0 0   0   0   0
      3 "34" 0 0 1 0 0 0 0 1.5   5    25 120 0 0   0   0   0
      3 "34" 0 0 0 1 0 0 0   0 .75 .5625 120 0 0   0   0   0
      3 "34" 1 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
      3 "35" 0 1 0 0 0 0 0 1.5   5    25  50 0 0   0   0   0
      3 "35" 0 0 1 0 0 0 0 3.5 .75 .5625  50 1 1 3.5 3.5 .75
      3 "35" 0 0 0 1 0 0 1   0 .75 .5625  90 1 0   0   0   0
      3 "35" 1 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
      3 "36" 0 1 0 0 1 0 0 3.5   9    81  50 0 0   0   0   0
      3 "36" 0 0 1 0 1 0 0  .5   5    25  90 0 1   0  .5   5
      3 "36" 0 0 0 1 0 1 0   0   2     4  90 0 0   0   0   0
      3 "36" 1 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
      3 "37" 0 1 0 0 1 0 0 2.5 .75 .5625 120 0 0   0   0   0
      3 "37" 0 0 1 0 0 0 0 3.5   2     4  90 1 0 3.5   0   0
      3 "37" 1 0 0 1 0 0 1   0 .25 .0625  50 1 0   0   0   0
      3 "37" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
      3 "38" 0 1 0 0 0 0 0 2.5   2     4   0 0 0   0   0   0
      3 "38" 1 0 1 0 0 0 0  .5 .25 .0625  50 1 1  .5  .5 .25
      3 "38" 0 0 0 1 0 0 0   0   2     4  50 1 0   0   0   0
      3 "38" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
      4 "41" 0 1 0 0 1 0 0 3.5   2     4 120 0 0   0   0   0
      4 "41" 0 0 1 0 1 0 0 2.5   5    25   0 1 1 2.5 2.5   5
      4 "41" 0 0 0 1 0 0 0   0   5    25  90 1 0   0   0   0
      4 "41" 1 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
      4 "42" 1 1 0 0 1 0 0  .5 .75 .5625  50 0 0   0   0   0
      4 "42" 0 0 1 0 1 0 0  .5   2     4   0 0 0   0   0   0
      4 "42" 0 0 0 1 0 1 0   0 .25 .0625   0 0 0   0   0   0
      4 "42" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
      4 "43" 0 1 0 0 1 0 0 2.5   2     4  50 0 0   0   0   0
      4 "43" 0 0 1 0 0 0 0 3.5 .75 .5625 120 0 0   0   0   0
      4 "43" 0 0 0 1 0 1 0   0   5    25 120 0 0   0   0   0
      4 "43" 1 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
      4 "44" 0 1 0 0 0 0 0 1.5   9    81   0 0 0   0   0   0
      4 "44" 0 0 1 0 1 0 0 2.5 .75 .5625  90 0 1   0 2.5 .75
      4 "44" 0 0 0 1 0 0 1   0   2     4  50 0 0   0   0   0
      4 "44" 1 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
      4 "45" 0 1 0 0 0 0 0 3.5   9    81 120 0 0   0   0   0
      4 "45" 0 0 1 0 0 0 0 1.5 .75 .5625  50 0 1   0 1.5 .75
      4 "45" 0 0 0 1 0 1 0   0 .75 .5625   0 0 0   0   0   0
      4 "45" 1 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
      4 "46" 1 1 0 0 0 0 0  .5   2     4  90 0 0   0   0   0
      4 "46" 0 0 1 0 0 0 0  .5   5    25  90 1 1  .5  .5   5
      4 "46" 0 0 0 1 0 0 1   0   2     4  90 1 0   0   0   0
      4 "46" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
      4 "47" 0 1 0 0 0 0 0 3.5   2     4  90 0 0   0   0   0
      4 "47" 0 0 1 0 1 0 0 3.5 .25 .0625  90 1 1 3.5 3.5 .25
      4 "47" 0 0 0 1 0 0 1   0   2     4 120 1 0   0   0   0
      4 "47" 1 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
      4 "48" 1 1 0 0 0 0 0  .5   5    25   0 0 0   0   0   0
      4 "48" 0 0 1 0 0 0 0 2.5   2     4 120 0 0   0   0   0
      4 "48" 0 0 0 1 0 0 0   0 .75 .5625  90 0 0   0   0   0
      4 "48" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
      5 "51" 1 1 0 0 0 0 0 1.5   2     4   0 0 0   0   0   0
      5 "51" 0 0 1 0 1 0 0 3.5   5    25  50 1 0 3.5   0   0
      5 "51" 0 0 0 1 0 0 1   0   5    25  50 1 0   0   0   0
      5 "51" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
      5 "52" 0 1 0 0 0 0 0  .5   9    81 120 0 0   0   0   0
      5 "52" 1 0 1 0 0 0 0 3.5 .25 .0625   0 0 0   0   0   0
      5 "52" 0 0 0 1 0 0 1   0   2     4 120 0 0   0   0   0
      5 "52" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
      5 "53" 0 1 0 0 0 0 0 3.5   5    25   0 0 0   0   0   0
      5 "53" 0 0 1 0 1 0 0  .5 .75 .5625 120 1 1  .5  .5 .75
      5 "53" 1 0 0 1 0 0 0   0   5    25   0 1 0   0   0   0
      5 "53" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
      5 "54" 0 1 0 0 0 0 0 3.5 .75 .5625  50 0 0   0   0   0
      5 "54" 1 0 1 0 1 0 0  .5 .75 .5625   0 1 0  .5   0   0
      5 "54" 0 0 0 1 0 0 1   0 .75 .5625  50 1 0   0   0   0
      5 "54" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
      5 "55" 0 1 0 0 1 0 0 2.5 .75 .5625   0 0 0   0   0   0
      5 "55" 0 0 1 0 1 0 0 1.5   5    25  50 1 1 1.5 1.5   5
      5 "55" 1 0 0 1 0 0 1   0 .25 .0625   0 1 0   0   0   0
      5 "55" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
      5 "56" 0 1 0 0 0 0 0 2.5   9    81  90 0 0   0   0   0
      5 "56" 0 0 1 0 1 0 0 3.5   2     4  90 1 1 3.5 3.5   2
      5 "56" 0 0 0 1 0 0 0   0   2     4 120 1 0   0   0   0
      5 "56" 1 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
      5 "57" 0 1 0 0 0 0 0 2.5   5    25  90 0 0   0   0   0
      5 "57" 0 0 1 0 1 0 0 2.5 .75 .5625 120 1 0 2.5   0   0
      5 "57" 0 0 0 1 0 1 0   0 .25 .0625  90 1 0   0   0   0
      5 "57" 1 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
      5 "58" 0 1 0 0 1 0 0  .5 .75 .5625  50 0 0   0   0   0
      5 "58" 0 0 1 0 0 0 0  .5   5    25  50 0 0   0   0   0
      5 "58" 1 0 0 1 0 0 0   0   2     4   0 0 0   0   0   0
      5 "58" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
      6 "61" 1 1 0 0 1 0 0  .5   2     4  90 0 0   0   0   0
      6 "61" 0 0 1 0 0 0 0 2.5   5    25  50 0 0   0   0   0
      6 "61" 0 0 0 1 0 0 0   0   5    25  90 0 0   0   0   0
      6 "61" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
      6 "62" 1 1 0 0 1 0 0 1.5 .75 .5625  90 0 0   0   0   0
      6 "62" 0 0 1 0 0 0 0 2.5 .25 .0625  90 1 1 2.5 2.5 .25
      6 "62" 0 0 0 1 0 0 1   0 .75 .5625   0 1 0   0   0   0
      6 "62" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
      6 "63" 1 1 0 0 0 0 0 1.5 .75 .5625 120 0 0   0   0   0
      6 "63" 0 0 1 0 1 0 0 1.5 .25 .0625   0 1 1 1.5 1.5 .25
      6 "63" 0 0 0 1 0 1 0   0   2     4  50 1 0   0   0   0
      6 "63" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
      6 "64" 0 1 0 0 1 0 0 3.5   5    25 120 0 0   0   0   0
      6 "64" 0 0 1 0 0 0 0 1.5   5    25 120 0 0   0   0   0
      6 "64" 1 0 0 1 0 0 0   0 .75 .5625 120 0 0   0   0   0
      6 "64" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
      6 "65" 1 1 0 0 0 0 0 1.5   5    25  50 0 0   0   0   0
      6 "65" 0 0 1 0 0 0 0 3.5 .75 .5625  50 1 1 3.5 3.5 .75
      6 "65" 0 0 0 1 0 0 1   0 .75 .5625  90 1 0   0   0   0
      6 "65" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
      6 "66" 0 1 0 0 1 0 0 3.5   9    81  50 0 0   0   0   0
      6 "66" 0 0 1 0 1 0 0  .5   5    25  90 0 1   0  .5   5
      6 "66" 1 0 0 1 0 1 0   0   2     4  90 0 0   0   0   0
      6 "66" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
      6 "67" 1 1 0 0 1 0 0 2.5 .75 .5625 120 0 0   0   0   0
      6 "67" 0 0 1 0 0 0 0 3.5   2     4  90 1 0 3.5   0   0
      6 "67" 0 0 0 1 0 0 1   0 .25 .0625  50 1 0   0   0   0
      6 "67" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
      6 "68" 0 1 0 0 0 0 0 2.5   2     4   0 0 0   0   0   0
      6 "68" 1 0 1 0 0 0 0  .5 .25 .0625  50 1 1  .5  .5 .25
      6 "68" 0 0 0 1 0 0 0   0   2     4  50 1 0   0   0   0
      6 "68" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
      7 "71" 0 1 0 0 1 0 0 3.5   2     4 120 0 0   0   0   0
      7 "71" 0 0 1 0 1 0 0 2.5   5    25   0 1 1 2.5 2.5   5
      7 "71" 0 0 0 1 0 0 0   0   5    25  90 1 0   0   0   0
      7 "71" 1 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
      7 "72" 1 1 0 0 1 0 0  .5 .75 .5625  50 0 0   0   0   0
      7 "72" 0 0 1 0 1 0 0  .5   2     4   0 0 0   0   0   0
      7 "72" 0 0 0 1 0 1 0   0 .25 .0625   0 0 0   0   0   0
      7 "72" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
      end
      Code:
      global X base_visitIPM base_visitTH base_urbanTH time_cont wait_cont wait_qd cost_cont hub1 first_th1
      global X_x time_contXhub1 time_contXfirst_th1 wait_contXfirst_th1 
      
      lclogit2 y, rand(ASC_IP ASC_MIX ASC_TH $X $X_x) id(id) gr(id_cset) ncl(2)
      matrix from = e(b)
      lclogitml2 y, rand(ASC_IP ASC_MIX ASC_TH $X $X_x) id(id) gr(id_cset) ncl(2) from(from)
      est save lc2_Xx, replace

      Comment


      • #4
        The coefficients matrix created by lclogitm12 is indeed of dimension \(1\times k\). Therefore, if you simply want to generate linear predictions by equation, you could use margins. You can generate the predictions at the observation level or average across groups as you have grouped data. Both cases are illustrated below.

        Code:
        * Example generated by -dataex-. For more info, type help dataex
        clear
        input float id str5 id_cset float(y ASC_IP ASC_MIX ASC_TH base_visitIPM base_visitTH base_urbanTH time_cont wait_cont wait_qd cost_cont hub1 first_th1 time_contXhub1 time_contXfirst_th1 wait_contXfirst_th1)
        1 "11" 0 1 0 0 0 0 0 2.5   2     4 120 0 0   0   0   0
        1 "11" 0 0 1 0 1 0 0 1.5   2     4  90 0 1   0 1.5   2
        1 "11" 1 0 0 1 0 0 0   0   5    25  50 0 0   0   0   0
        1 "11" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
        1 "12" 0 1 0 0 1 0 0 1.5   9    81  50 0 0   0   0   0
        1 "12" 0 0 1 0 0 0 0 1.5 .75 .5625 120 1 0 1.5   0   0
        1 "12" 1 0 0 1 0 0 1   0   5    25  50 1 0   0   0   0
        1 "12" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
        1 "13" 1 1 0 0 1 0 0 1.5   5    25   0 0 0   0   0   0
        1 "13" 0 0 1 0 1 0 0 2.5 .25 .0625 120 0 0   0   0   0
        1 "13" 0 0 0 1 0 0 1   0 .75 .5625 120 0 0   0   0   0
        1 "13" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
        1 "14" 0 1 0 0 0 0 0 3.5 .75 .5625 120 0 0   0   0   0
        1 "14" 0 0 1 0 1 0 0  .5 .25 .0625   0 0 1   0  .5 .25
        1 "14" 1 0 0 1 0 1 0   0 .25 .0625   0 0 0   0   0   0
        1 "14" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
        1 "15" 0 1 0 0 1 0 0 1.5   2     4 120 0 0   0   0   0
        1 "15" 0 0 1 0 1 0 0 1.5   2     4  50 1 0 1.5   0   0
        1 "15" 1 0 0 1 0 1 0   0   2     4  50 1 0   0   0   0
        1 "15" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
        1 "16" 0 1 0 0 0 0 0 2.5   5    25  90 0 0   0   0   0
        1 "16" 0 0 1 0 1 0 0  .5   2     4  90 0 1   0  .5   2
        1 "16" 0 0 0 1 0 0 0   0 .25 .0625  90 0 0   0   0   0
        1 "16" 1 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
        1 "17" 0 1 0 0 1 0 0  .5   9    81  50 0 0   0   0   0
        1 "17" 1 0 1 0 0 0 0 3.5   5    25   0 1 1 3.5 3.5   5
        1 "17" 0 0 0 1 0 0 0   0 .75 .5625 120 1 0   0   0   0
        1 "17" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
        1 "18" 0 1 0 0 0 0 0 1.5   2     4  90 0 0   0   0   0
        1 "18" 1 0 1 0 0 0 0  .5   2     4  50 1 1  .5  .5   2
        1 "18" 0 0 0 1 0 0 0   0 .75 .5625  90 1 0   0   0   0
        1 "18" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
        2 "21" 1 1 0 0 0 0 0 2.5   2     4 120 0 0   0   0   0
        2 "21" 0 0 1 0 1 0 0 1.5   2     4  90 0 1   0 1.5   2
        2 "21" 0 0 0 1 0 0 0   0   5    25  50 0 0   0   0   0
        2 "21" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
        2 "22" 0 1 0 0 1 0 0 1.5   9    81  50 0 0   0   0   0
        2 "22" 1 0 1 0 0 0 0 1.5 .75 .5625 120 1 0 1.5   0   0
        2 "22" 0 0 0 1 0 0 1   0   5    25  50 1 0   0   0   0
        2 "22" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
        2 "23" 0 1 0 0 1 0 0 1.5   5    25   0 0 0   0   0   0
        2 "23" 1 0 1 0 1 0 0 2.5 .25 .0625 120 0 0   0   0   0
        2 "23" 0 0 0 1 0 0 1   0 .75 .5625 120 0 0   0   0   0
        2 "23" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
        2 "24" 0 1 0 0 0 0 0 3.5 .75 .5625 120 0 0   0   0   0
        2 "24" 1 0 1 0 1 0 0  .5 .25 .0625   0 0 1   0  .5 .25
        2 "24" 0 0 0 1 0 1 0   0 .25 .0625   0 0 0   0   0   0
        2 "24" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
        2 "25" 1 1 0 0 1 0 0 1.5   2     4 120 0 0   0   0   0
        2 "25" 0 0 1 0 1 0 0 1.5   2     4  50 1 0 1.5   0   0
        2 "25" 0 0 0 1 0 1 0   0   2     4  50 1 0   0   0   0
        2 "25" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
        2 "26" 0 1 0 0 0 0 0 2.5   5    25  90 0 0   0   0   0
        2 "26" 1 0 1 0 1 0 0  .5   2     4  90 0 1   0  .5   2
        2 "26" 0 0 0 1 0 0 0   0 .25 .0625  90 0 0   0   0   0
        2 "26" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
        2 "27" 0 1 0 0 1 0 0  .5   9    81  50 0 0   0   0   0
        2 "27" 0 0 1 0 0 0 0 3.5   5    25   0 1 1 3.5 3.5   5
        2 "27" 1 0 0 1 0 0 0   0 .75 .5625 120 1 0   0   0   0
        2 "27" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
        2 "28" 0 1 0 0 0 0 0 1.5   2     4  90 0 0   0   0   0
        2 "28" 0 0 1 0 0 0 0  .5   2     4  50 1 1  .5  .5   2
        2 "28" 1 0 0 1 0 0 0   0 .75 .5625  90 1 0   0   0   0
        2 "28" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
        3 "31" 1 1 0 0 1 0 0  .5   2     4  90 0 0   0   0   0
        3 "31" 0 0 1 0 0 0 0 2.5   5    25  50 0 0   0   0   0
        3 "31" 0 0 0 1 0 0 0   0   5    25  90 0 0   0   0   0
        3 "31" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
        3 "32" 0 1 0 0 1 0 0 1.5 .75 .5625  90 0 0   0   0   0
        3 "32" 0 0 1 0 0 0 0 2.5 .25 .0625  90 1 1 2.5 2.5 .25
        3 "32" 1 0 0 1 0 0 1   0 .75 .5625   0 1 0   0   0   0
        3 "32" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
        3 "33" 0 1 0 0 0 0 0 1.5 .75 .5625 120 0 0   0   0   0
        3 "33" 1 0 1 0 1 0 0 1.5 .25 .0625   0 1 1 1.5 1.5 .25
        3 "33" 0 0 0 1 0 1 0   0   2     4  50 1 0   0   0   0
        3 "33" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
        3 "34" 0 1 0 0 1 0 0 3.5   5    25 120 0 0   0   0   0
        3 "34" 0 0 1 0 0 0 0 1.5   5    25 120 0 0   0   0   0
        3 "34" 0 0 0 1 0 0 0   0 .75 .5625 120 0 0   0   0   0
        3 "34" 1 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
        3 "35" 0 1 0 0 0 0 0 1.5   5    25  50 0 0   0   0   0
        3 "35" 0 0 1 0 0 0 0 3.5 .75 .5625  50 1 1 3.5 3.5 .75
        3 "35" 0 0 0 1 0 0 1   0 .75 .5625  90 1 0   0   0   0
        3 "35" 1 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
        3 "36" 0 1 0 0 1 0 0 3.5   9    81  50 0 0   0   0   0
        3 "36" 0 0 1 0 1 0 0  .5   5    25  90 0 1   0  .5   5
        3 "36" 0 0 0 1 0 1 0   0   2     4  90 0 0   0   0   0
        3 "36" 1 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
        3 "37" 0 1 0 0 1 0 0 2.5 .75 .5625 120 0 0   0   0   0
        3 "37" 0 0 1 0 0 0 0 3.5   2     4  90 1 0 3.5   0   0
        3 "37" 1 0 0 1 0 0 1   0 .25 .0625  50 1 0   0   0   0
        3 "37" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
        3 "38" 0 1 0 0 0 0 0 2.5   2     4   0 0 0   0   0   0
        3 "38" 1 0 1 0 0 0 0  .5 .25 .0625  50 1 1  .5  .5 .25
        3 "38" 0 0 0 1 0 0 0   0   2     4  50 1 0   0   0   0
        3 "38" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
        4 "41" 0 1 0 0 1 0 0 3.5   2     4 120 0 0   0   0   0
        4 "41" 0 0 1 0 1 0 0 2.5   5    25   0 1 1 2.5 2.5   5
        4 "41" 0 0 0 1 0 0 0   0   5    25  90 1 0   0   0   0
        4 "41" 1 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
        4 "42" 1 1 0 0 1 0 0  .5 .75 .5625  50 0 0   0   0   0
        4 "42" 0 0 1 0 1 0 0  .5   2     4   0 0 0   0   0   0
        4 "42" 0 0 0 1 0 1 0   0 .25 .0625   0 0 0   0   0   0
        4 "42" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
        4 "43" 0 1 0 0 1 0 0 2.5   2     4  50 0 0   0   0   0
        4 "43" 0 0 1 0 0 0 0 3.5 .75 .5625 120 0 0   0   0   0
        4 "43" 0 0 0 1 0 1 0   0   5    25 120 0 0   0   0   0
        4 "43" 1 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
        4 "44" 0 1 0 0 0 0 0 1.5   9    81   0 0 0   0   0   0
        4 "44" 0 0 1 0 1 0 0 2.5 .75 .5625  90 0 1   0 2.5 .75
        4 "44" 0 0 0 1 0 0 1   0   2     4  50 0 0   0   0   0
        4 "44" 1 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
        4 "45" 0 1 0 0 0 0 0 3.5   9    81 120 0 0   0   0   0
        4 "45" 0 0 1 0 0 0 0 1.5 .75 .5625  50 0 1   0 1.5 .75
        4 "45" 0 0 0 1 0 1 0   0 .75 .5625   0 0 0   0   0   0
        4 "45" 1 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
        4 "46" 1 1 0 0 0 0 0  .5   2     4  90 0 0   0   0   0
        4 "46" 0 0 1 0 0 0 0  .5   5    25  90 1 1  .5  .5   5
        4 "46" 0 0 0 1 0 0 1   0   2     4  90 1 0   0   0   0
        4 "46" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
        4 "47" 0 1 0 0 0 0 0 3.5   2     4  90 0 0   0   0   0
        4 "47" 0 0 1 0 1 0 0 3.5 .25 .0625  90 1 1 3.5 3.5 .25
        4 "47" 0 0 0 1 0 0 1   0   2     4 120 1 0   0   0   0
        4 "47" 1 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
        4 "48" 1 1 0 0 0 0 0  .5   5    25   0 0 0   0   0   0
        4 "48" 0 0 1 0 0 0 0 2.5   2     4 120 0 0   0   0   0
        4 "48" 0 0 0 1 0 0 0   0 .75 .5625  90 0 0   0   0   0
        4 "48" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
        5 "51" 1 1 0 0 0 0 0 1.5   2     4   0 0 0   0   0   0
        5 "51" 0 0 1 0 1 0 0 3.5   5    25  50 1 0 3.5   0   0
        5 "51" 0 0 0 1 0 0 1   0   5    25  50 1 0   0   0   0
        5 "51" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
        5 "52" 0 1 0 0 0 0 0  .5   9    81 120 0 0   0   0   0
        5 "52" 1 0 1 0 0 0 0 3.5 .25 .0625   0 0 0   0   0   0
        5 "52" 0 0 0 1 0 0 1   0   2     4 120 0 0   0   0   0
        5 "52" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
        5 "53" 0 1 0 0 0 0 0 3.5   5    25   0 0 0   0   0   0
        5 "53" 0 0 1 0 1 0 0  .5 .75 .5625 120 1 1  .5  .5 .75
        5 "53" 1 0 0 1 0 0 0   0   5    25   0 1 0   0   0   0
        5 "53" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
        5 "54" 0 1 0 0 0 0 0 3.5 .75 .5625  50 0 0   0   0   0
        5 "54" 1 0 1 0 1 0 0  .5 .75 .5625   0 1 0  .5   0   0
        5 "54" 0 0 0 1 0 0 1   0 .75 .5625  50 1 0   0   0   0
        5 "54" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
        5 "55" 0 1 0 0 1 0 0 2.5 .75 .5625   0 0 0   0   0   0
        5 "55" 0 0 1 0 1 0 0 1.5   5    25  50 1 1 1.5 1.5   5
        5 "55" 1 0 0 1 0 0 1   0 .25 .0625   0 1 0   0   0   0
        5 "55" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
        5 "56" 0 1 0 0 0 0 0 2.5   9    81  90 0 0   0   0   0
        5 "56" 0 0 1 0 1 0 0 3.5   2     4  90 1 1 3.5 3.5   2
        5 "56" 0 0 0 1 0 0 0   0   2     4 120 1 0   0   0   0
        5 "56" 1 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
        5 "57" 0 1 0 0 0 0 0 2.5   5    25  90 0 0   0   0   0
        5 "57" 0 0 1 0 1 0 0 2.5 .75 .5625 120 1 0 2.5   0   0
        5 "57" 0 0 0 1 0 1 0   0 .25 .0625  90 1 0   0   0   0
        5 "57" 1 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
        5 "58" 0 1 0 0 1 0 0  .5 .75 .5625  50 0 0   0   0   0
        5 "58" 0 0 1 0 0 0 0  .5   5    25  50 0 0   0   0   0
        5 "58" 1 0 0 1 0 0 0   0   2     4   0 0 0   0   0   0
        5 "58" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
        6 "61" 1 1 0 0 1 0 0  .5   2     4  90 0 0   0   0   0
        6 "61" 0 0 1 0 0 0 0 2.5   5    25  50 0 0   0   0   0
        6 "61" 0 0 0 1 0 0 0   0   5    25  90 0 0   0   0   0
        6 "61" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
        6 "62" 1 1 0 0 1 0 0 1.5 .75 .5625  90 0 0   0   0   0
        6 "62" 0 0 1 0 0 0 0 2.5 .25 .0625  90 1 1 2.5 2.5 .25
        6 "62" 0 0 0 1 0 0 1   0 .75 .5625   0 1 0   0   0   0
        6 "62" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
        6 "63" 1 1 0 0 0 0 0 1.5 .75 .5625 120 0 0   0   0   0
        6 "63" 0 0 1 0 1 0 0 1.5 .25 .0625   0 1 1 1.5 1.5 .25
        6 "63" 0 0 0 1 0 1 0   0   2     4  50 1 0   0   0   0
        6 "63" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
        6 "64" 0 1 0 0 1 0 0 3.5   5    25 120 0 0   0   0   0
        6 "64" 0 0 1 0 0 0 0 1.5   5    25 120 0 0   0   0   0
        6 "64" 1 0 0 1 0 0 0   0 .75 .5625 120 0 0   0   0   0
        6 "64" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
        6 "65" 1 1 0 0 0 0 0 1.5   5    25  50 0 0   0   0   0
        6 "65" 0 0 1 0 0 0 0 3.5 .75 .5625  50 1 1 3.5 3.5 .75
        6 "65" 0 0 0 1 0 0 1   0 .75 .5625  90 1 0   0   0   0
        6 "65" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
        6 "66" 0 1 0 0 1 0 0 3.5   9    81  50 0 0   0   0   0
        6 "66" 0 0 1 0 1 0 0  .5   5    25  90 0 1   0  .5   5
        6 "66" 1 0 0 1 0 1 0   0   2     4  90 0 0   0   0   0
        6 "66" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
        6 "67" 1 1 0 0 1 0 0 2.5 .75 .5625 120 0 0   0   0   0
        6 "67" 0 0 1 0 0 0 0 3.5   2     4  90 1 0 3.5   0   0
        6 "67" 0 0 0 1 0 0 1   0 .25 .0625  50 1 0   0   0   0
        6 "67" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
        6 "68" 0 1 0 0 0 0 0 2.5   2     4   0 0 0   0   0   0
        6 "68" 1 0 1 0 0 0 0  .5 .25 .0625  50 1 1  .5  .5 .25
        6 "68" 0 0 0 1 0 0 0   0   2     4  50 1 0   0   0   0
        6 "68" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
        7 "71" 0 1 0 0 1 0 0 3.5   2     4 120 0 0   0   0   0
        7 "71" 0 0 1 0 1 0 0 2.5   5    25   0 1 1 2.5 2.5   5
        7 "71" 0 0 0 1 0 0 0   0   5    25  90 1 0   0   0   0
        7 "71" 1 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
        7 "72" 1 1 0 0 1 0 0  .5 .75 .5625  50 0 0   0   0   0
        7 "72" 0 0 1 0 1 0 0  .5   2     4   0 0 0   0   0   0
        7 "72" 0 0 0 1 0 1 0   0 .25 .0625   0 0 0   0   0   0
        7 "72" 0 0 0 0 0 0 0   0   0     0   0 0 0   0   0   0
        end
        
        destring id_cset, replace
        
        global X base_visitIPM base_visitTH base_urbanTH time_cont wait_cont wait_qd cost_cont hub1 first_th1
        global X_x time_contXhub1 time_contXfirst_th1 wait_contXfirst_th1
        
        *lclogit2 y, rand(ASC_IP ASC_MIX ASC_TH $X $X_x) id(id) gr(id_cset) ncl(2)
        *matrix from = e(b)
        lclogitml2 y, rand(ASC_IP ASC_MIX ASC_TH $X $X_x) id(id) gr(id_cset) ncl(2) iterate(5)
        est save lc2_Xx, replace
        
        *VIEW COEFFICIENTS MATRIX
        mat l e(b)
        
        *PREDICTIONS CLASS 1, GROUP LEVEL
        gen obsno=_n
        margins, over(id) predict(outcome(Class1))
        
        *PREDICTIONS CLASS 2, GROUP LEVEL
        margins, over(id) predict(outcome(Class2))
        
        *PREDICTIONS CLASS 1, OBSERVATION LEVEL
        margins, over(obsno) predict(outcome(Class1))
        
        *PREDICTIONS CLASS 2, OBSERVATION LEVEL
        margins, over(obsno) predict(outcome(Class2))
        Res.:

        Code:
         *VIEW COEFFICIENTS MATRIX
        . mat l e(b)
        
        e(b)[1,31]
                  Class1:       Class1:       Class1:       Class1:       Class1:       Class1:       Class1:       Class1:
                  ASC_IP       ASC_MIX        ASC_TH  base_visit~M  base_visitTH  base_urbanTH     time_cont     wait_cont
        y1     16.926909     13.587129    -2.3754802     1.3846156     1.7815032    -10.542766    -7.5476379    -2.1522156
        
                  Class1:       Class1:       Class1:       Class1:       Class1:       Class1:       Class1:       Class2:
                 wait_qd     cost_cont          hub1     first_th1  time_cont~b1  time_cont~h1  wait_contX~1        ASC_IP
        y1     .06436021     .06467724     4.8632059    -6.3724604     -.2981493     .14993427    -.94159669     28.863913
        
                  Class2:       Class2:       Class2:       Class2:       Class2:       Class2:       Class2:       Class2:
                 ASC_MIX        ASC_TH  base_visit~M  base_visitTH  base_urbanTH     time_cont     wait_cont       wait_qd
        y1     34.885146     16.732942    -3.1869149    -.28586573     1.2875691    -9.7367589    -.53979321    -.05763963
        
                  Class2:       Class2:       Class2:       Class2:       Class2:       Class2:       Share1:
               cost_cont          hub1     first_th1  time_cont~b1  time_cont~h1  wait_contX~1         _cons
        y1    -.21240135    -.94772886     -14.88247    -2.0876766     8.3884691     .20363656     -.7007534
        
        .
        . *PREDICTIONS CLASS 1, GROUP LEVEL
        . margins, over(id) predict(outcome(Class1))
        
        Predictive margins                                         Number of obs = 200
        Model VCE: OIM
        
        Expression: Linear prediction, predict(outcome(Class1))
        Over:       id
        
        ------------------------------------------------------------------------------
                     |            Delta-method
                     |     Margin   std. err.      z    P>|z|     [95% conf. interval]
        -------------+----------------------------------------------------------------
                  id |
                  1  |   .2192205   1.821057     0.12   0.904    -3.349986    3.788427
                  2  |   .2192205   1.821057     0.12   0.904    -3.349986    3.788427
                  3  |  -.9102999   2.111809    -0.43   0.666     -5.04937    3.228771
                  4  |  -2.175859   1.835342    -1.19   0.236    -5.773063    1.421344
                  5  |  -2.019352   2.091887    -0.97   0.334    -6.119375     2.08067
                  6  |  -.9102999   2.111809    -0.43   0.666     -5.04937    3.228771
                  7  |  -.3318735    2.79579    -0.12   0.906     -5.81152    5.147773
        ------------------------------------------------------------------------------
        
        .
        . *PREDICTIONS CLASS 2, GROUP LEVEL
        . margins, over(id) predict(outcome(Class2))
        
        Predictive margins                                         Number of obs = 200
        Model VCE: OIM
        
        Expression: Linear prediction, predict(outcome(Class2))
        Over:       id
        
        ------------------------------------------------------------------------------
                     |            Delta-method
                     |     Margin   std. err.      z    P>|z|     [95% conf. interval]
        -------------+----------------------------------------------------------------
                  id |
                  1  |  -3.310531   1.264755    -2.62   0.009    -5.789405   -.8316569
                  2  |  -3.310531   1.264755    -2.62   0.009    -5.789405   -.8316569
                  3  |  -4.466241   1.269279    -3.52   0.000    -6.953983   -1.978499
                  4  |  -3.210663   1.193862    -2.69   0.007    -5.550589   -.8707358
                  5  |  -2.117252   1.399696    -1.51   0.130    -4.860606    .6261017
                  6  |  -4.466241   1.269279    -3.52   0.000    -6.953983   -1.978499
                  7  |   1.633129   1.722404     0.95   0.343    -1.742722    5.008979
        ------------------------------------------------------------------------------

        Comment


        • #5
          Hi Andrew, thanks so much for your help. When I try to run the margins command, I keep getting the following error message: "e(sample) does not identify the estimation sample". I used your exact code so I'm not sure what's wrong.

          What I am trying to do with all of this is to test how people's choices change when the values of each of the variables base_visitIPM base_visitTH base_urbanTH time_cont etc. change. For example, predict uptake when all these variables are equal to 0, and then see how uptake changes when cost, for example, increases to 50. I was able to do this just using the "predict" command for estimates from a multinomial logit model, but I want to do it separately by class for this model.

          Comment


          • #6
            If you are running the code exactly as shown in #4, you should not get this error. You must be doing something in between, such as loading saved estimates or otherwise modifying the data. However, as long as you know what you are doing, the error can be resolved using the -noesample- option of margins. By the way, if you do not need the standard errors of the predictions, you can add the -nose- option to margins. This would substantially speed things up. All in all, you want something like:

            Code:
            margins, over(id) predict(outcome(Class1)) noesample nose

            Comment


            • #7
              Thanks very much, it works now.

              Comment


              • #8
                One more question: it seems that I can't run the margins command twice, I get the error message "option over() not allowed". Is there a way to bypass this error, or do I need to clear the data and rerun it, each time only once?

                Comment


                • #9
                  As long as the estimation results are active, you can run margins as many times as you want. If you clear the estimation results, you need to restore them prior to running margins.

                  Code:
                  lclogitml2 ...
                  est store myres
                  margins ... 
                  est restore myres
                  margins ...

                  Comment


                  • #10
                    Many thanks.

                    Comment

                    Working...
                    X