Announcement

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

  • #16
    Another option is David Roodman's cmp command from SSC that can estimate multiple equation models. If you send him an email, he may be able to suggest if and how to exclude the intercepts in each equation. If you are successful in that, you have solved your problem.

    Code:
    webuse mroz87, clear
    set seed 03302022
    gen outcome2= runiformint(1, 4920)
    tobit whrs75 c.nwinc c.wedyrs c.wexper c.wexper#c.wexper c.wifeage c.kl6 c.k618, ll(0) nolog
    tobit outcome2 c.nwinc c.wedyrs c.wexper c.wexper#c.wexper c.wifeage c.kl6 c.k618, ll(0) nolog
    cmp (whrs75= c.nwinc c.wedyrs c.wexper c.wexper#c.wexper c.wifeage c.kl6 c.k618) ///
    (outcome2= c.nwinc c.wedyrs c.wexper c.wexper#c.wexper c.wifeage c.kl6 c.k618), ///
    ind("cond(whrs75>0, $cmp_cont, $cmp_left)" "cond(outcome2>0, $cmp_cont, $cmp_left)") qui
    Res.:

    Code:
    . tobit whrs75 c.nwinc c.wedyrs c.wexper c.wexper#c.wexper c.wifeage c.kl6 c.k618, ll(0) nolog
    
    Tobit regression                                Number of obs     =        753
                                                       Uncensored     =        428
    Limits: lower = 0                                  Left-censored  =        325
            upper = +inf                               Right-censored =          0
    
                                                    LR chi2(7)        =     271.59
                                                    Prob > chi2       =     0.0000
    Log likelihood = -3819.0946                     Pseudo R2         =     0.0343
    
    -----------------------------------------------------------------------------------
               whrs75 |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    ------------------+----------------------------------------------------------------
                nwinc |  -8.814227   4.459089    -1.98   0.048    -17.56808   -.0603708
               wedyrs |   80.64541   21.58318     3.74   0.000     38.27441    123.0164
               wexper |    131.564   17.27935     7.61   0.000     97.64211     165.486
                      |
    c.wexper#c.wexper |  -1.864153   .5376606    -3.47   0.001    -2.919661   -.8086455
                      |
              wifeage |  -54.40491   7.418483    -7.33   0.000     -68.9685   -39.84133
                  kl6 |  -894.0202   111.8777    -7.99   0.000    -1113.653   -674.3875
                 k618 |  -16.21805    38.6413    -0.42   0.675    -92.07668    59.64057
                _cons |   965.3068   446.4351     2.16   0.031     88.88827    1841.725
    ------------------+----------------------------------------------------------------
         var(e.whrs75)|    1258927   93304.48                       1088458     1456093
    -----------------------------------------------------------------------------------
    
    . tobit outcome2 c.nwinc c.wedyrs c.wexper c.wexper#c.wexper c.wifeage c.kl6 c.k618, ll(0) nolog
    
    Tobit regression                                Number of obs     =        753
                                                       Uncensored     =        753
    Limits: lower = 0                                  Left-censored  =          0
            upper = +inf                               Right-censored =          0
    
                                                    LR chi2(7)        =       5.70
                                                    Prob > chi2       =     0.5753
    Log likelihood = -6550.7516                     Pseudo R2         =     0.0004
    
    -----------------------------------------------------------------------------------
             outcome2 |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    ------------------+----------------------------------------------------------------
                nwinc |    -2.8083   4.923527    -0.57   0.569    -12.47392    6.857317
               wedyrs |   23.37747   25.07164     0.93   0.351    -25.84191    72.59684
               wexper |   25.51334   19.28185     1.32   0.186    -12.33979    63.36648
                      |
    c.wexper#c.wexper |  -.8997776   .6281175    -1.43   0.152    -2.132866    .3333107
                      |
              wifeage |     7.6236   8.445607     0.90   0.367    -8.956385    24.20359
                  kl6 |   159.3098   113.8887     1.40   0.162    -64.27071    382.8903
                 k618 |   47.07904   44.85406     1.05   0.294    -40.97618    135.1343
                _cons |   1768.561   524.0627     3.37   0.001     739.7478    2797.374
    ------------------+----------------------------------------------------------------
       var(e.outcome2)|    2107889   108633.9                       1905058     2332315
    -----------------------------------------------------------------------------------
    
    . cmp (whrs75= c.nwinc c.wedyrs c.wexper c.wexper#c.wexper c.wifeage c.kl6 c.k618) ///
    > (outcome2= c.nwinc c.wedyrs c.wexper c.wexper#c.wexper c.wifeage c.kl6 c.k618), ///
    > ind("cond(whrs75>0, $cmp_cont, $cmp_left)" "cond(outcome2>0, $cmp_cont, $cmp_left)") qui
    
    Fitting individual models as starting point for full model fit.
    
    Fitting constant-only model for LR test of overall model fit.
    
    Fitting full model.
    
    Mixed-process regression                        Number of obs     =        753
                                                    LR chi2(14)       =     277.15
    Log likelihood = -10369.821                     Prob > chi2       =     0.0000
    
    -----------------------------------------------------------------------------------
                      |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    ------------------+----------------------------------------------------------------
    whrs75            |
                nwinc |  -8.810777   4.458305    -1.98   0.048     -17.5489   -.0726592
               wedyrs |   80.56007   21.58372     3.73   0.000     38.25676    122.8634
               wexper |   131.6076    17.2807     7.62   0.000     97.73804    165.4772
                      |
    c.wexper#c.wexper |  -1.865532   .5377009    -3.47   0.001    -2.919406   -.8116571
                      |
              wifeage |   -54.3756   7.418726    -7.33   0.000    -68.91604   -39.83517
                  kl6 |  -893.2394   111.8979    -7.98   0.000    -1112.555   -673.9236
                 k618 |  -16.17063    38.6418    -0.42   0.676    -91.90716    59.56589
                _cons |    964.672   446.4197     2.16   0.031     89.70553    1839.639
    ------------------+----------------------------------------------------------------
    outcome2          |
                nwinc |  -2.808302   4.923525    -0.57   0.568    -12.45823    6.841629
               wedyrs |   23.37749   25.07163     0.93   0.351      -25.762    72.51699
               wexper |   25.51333   19.28184     1.32   0.186    -12.27837    63.30504
                      |
    c.wexper#c.wexper |  -.8997773   .6281172    -1.43   0.152    -2.130864    .3313099
                      |
              wifeage |   7.623598   8.445603     0.90   0.367     -8.92948    24.17668
                  kl6 |   159.3097   113.8886     1.40   0.162    -63.90796    382.5273
                 k618 |   47.07903   44.85404     1.05   0.294    -40.83328    134.9913
                _cons |   1768.561   524.0625     3.37   0.001     741.4172    2795.704
    ------------------+----------------------------------------------------------------
             /lnsig_1 |   7.022846   .0370561   189.52   0.000     6.950217    7.095475
             /lnsig_2 |   7.280598   .0257684   282.54   0.000     7.230093    7.331103
         /atanhrho_12 |  -.0090192   .0401423    -0.22   0.822    -.0876966    .0696582
    ------------------+----------------------------------------------------------------
                sig_1 |   1121.975   41.57604                      1043.376    1206.495
                sig_2 |   1451.857     37.412                      1380.351    1527.066
               rho_12 |  -.0090189    .040139                     -.0874724    .0695458
    -----------------------------------------------------------------------------------
    
    .

    Comment


    • #17
      Actually, answering the question in #16, it's just the standard -nocons-. Whenever this pays off (if you are a student, when you graduate, get a job and receive your first paycheck), send your contribution to David!

      Code:
      webuse mroz87, clear
      set seed 03302022
      gen outcome2= runiformint(1, 4920)
      tobit whrs75 c.nwinc c.wedyrs c.wexper c.wexper#c.wexper c.wifeage c.kl6 c.k618, ll(0) nocons nolog 
      tobit outcome2 c.nwinc c.wedyrs c.wexper c.wexper#c.wexper c.wifeage c.kl6 c.k618, ll(0) nocons nolog
      cmp (whrs75= c.nwinc c.wedyrs c.wexper c.wexper#c.wexper c.wifeage c.kl6 c.k618, nocons) ///
      (outcome2= c.nwinc c.wedyrs c.wexper c.wexper#c.wexper c.wifeage c.kl6 c.k618, nocons), ///
      ind("cond(whrs75>0, $cmp_cont, $cmp_left)" "cond(outcome2>0, $cmp_cont, $cmp_left)") qui
      Res.:

      Code:
      . tobit whrs75 c.nwinc c.wedyrs c.wexper c.wexper#c.wexper c.wifeage c.kl6 c.k618, ll(0) nocons nolog 
      
      Tobit regression                                Number of obs     =        753
                                                         Uncensored     =        428
      Limits: lower = 0                                  Left-censored  =        325
              upper = +inf                               Right-censored =          0
      
                                                      F(   7,    746)   =      52.61
                                                      Prob > F          =     0.0000
      Log likelihood = -3821.3981                     Pseudo R2         =     0.0368
      
       ( 1)  [whrs75]_cons = 0
      -----------------------------------------------------------------------------------
                 whrs75 |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
      ------------------+----------------------------------------------------------------
                  nwinc |  -9.847428    4.48635    -2.19   0.028     -18.6548   -1.040053
                 wedyrs |   109.4473   17.29735     6.33   0.000        75.49    143.4046
                 wexper |   140.9599   17.00301     8.29   0.000     107.5805    174.3394
                        |
      c.wexper#c.wexper |  -2.188859   .5240843    -4.18   0.000    -3.217714   -1.160003
                        |
                wifeage |   -42.4201   4.861033    -8.73   0.000    -51.96304   -32.87717
                    kl6 |  -831.0646   108.6034    -7.65   0.000    -1044.269   -617.8599
                   k618 |    20.3103   35.07418     0.58   0.563    -48.54554    89.16615
                  _cons |          0  (omitted)
      ------------------+----------------------------------------------------------------
           var(e.whrs75)|    1284148   94835.66                       1110838     1484497
      -----------------------------------------------------------------------------------
      
      . tobit outcome2 c.nwinc c.wedyrs c.wexper c.wexper#c.wexper c.wifeage c.kl6 c.k618, ll(0) nocons nolog
      
      Tobit regression                                Number of obs     =        753
                                                         Uncensored     =        753
      Limits: lower = 0                                  Left-censored  =          0
              upper = +inf                               Right-censored =          0
      
                                                      F(   7,    746)   =     322.56
                                                      Prob > F          =     0.0000
      Log likelihood = -6556.4033                     Pseudo R2         =     0.0737
      
       ( 1)  [outcome2]_cons = 0
      -----------------------------------------------------------------------------------
               outcome2 |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
      ------------------+----------------------------------------------------------------
                  nwinc |   -4.47991   4.935452    -0.91   0.364    -14.16894    5.209118
                 wedyrs |   75.32679   19.93851     3.78   0.000     36.18452    114.4691
                 wexper |   39.26225   18.98851     2.07   0.039     1.984987    76.53952
                        |
      c.wexper#c.wexper |  -1.418335   .6136206    -2.31   0.021    -2.622964   -.2137068
                        |
                wifeage |     30.512   5.070643     6.02   0.000     20.55757    40.46642
                    kl6 |   286.6867   108.2618     2.65   0.008     74.15271    499.2207
                   k618 |   112.2164   40.79374     2.75   0.006     32.13222    192.3006
                  _cons |          0  (omitted)
      ------------------+----------------------------------------------------------------
         var(e.outcome2)|    2139770   110276.9                       1933871     2367590
      -----------------------------------------------------------------------------------
      
      . cmp (whrs75= c.nwinc c.wedyrs c.wexper c.wexper#c.wexper c.wifeage c.kl6 c.k618, nocons) ///
      > (outcome2= c.nwinc c.wedyrs c.wexper c.wexper#c.wexper c.wifeage c.kl6 c.k618, nocons), ///
      > ind("cond(whrs75>0, $cmp_cont, $cmp_left)" "cond(outcome2>0, $cmp_cont, $cmp_left)") qui
      
      Fitting individual models as starting point for full model fit.
      
      Fitting full model.
      
      Mixed-process regression                        Number of obs     =        753
                                                      Wald chi2(14)     =    2625.27
      Log likelihood = -10377.801                     Prob > chi2       =     0.0000
      
      -----------------------------------------------------------------------------------
                        |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
      ------------------+----------------------------------------------------------------
      whrs75            |
                  nwinc |  -9.847732   4.486411    -2.20   0.028    -18.64094   -1.054528
                 wedyrs |   109.4588   17.30324     6.33   0.000     75.54513    143.3726
                 wexper |   140.9529   17.00509     8.29   0.000     107.6236    174.2823
                        |
      c.wexper#c.wexper |  -2.188663   .5241348    -4.18   0.000    -3.215948   -1.161378
                        |
                wifeage |  -42.42194   4.861559    -8.73   0.000    -51.95042   -32.89345
                    kl6 |  -831.1396   108.6446    -7.65   0.000    -1044.079   -618.2002
                   k618 |   20.30592    35.0744     0.58   0.563    -48.43865    89.05049
      ------------------+----------------------------------------------------------------
      outcome2          |
                  nwinc |  -4.479911   4.935449    -0.91   0.364    -14.15321    5.193392
                 wedyrs |   75.32682    19.9385     3.78   0.000     36.24807    114.4056
                 wexper |   39.26223    18.9885     2.07   0.039     2.045461      76.479
                        |
      c.wexper#c.wexper |  -1.418335   .6136203    -2.31   0.021    -2.621008   -.2156611
                        |
                wifeage |   30.51199   5.070641     6.02   0.000     20.57372    40.45026
                    kl6 |   286.6866   108.2617     2.65   0.008     74.49749    498.8756
                   k618 |   112.2164   40.79372     2.75   0.006     32.26217    192.1706
      ------------------+----------------------------------------------------------------
               /lnsig_1 |     7.0328   .0369258   190.46   0.000     6.960427    7.105174
               /lnsig_2 |   7.288104   .0257684   282.83   0.000     7.237599    7.338609
           /atanhrho_12 |   .0010275   .0402228     0.03   0.980    -.0778077    .0798627
      ------------------+----------------------------------------------------------------
                  sig_1 |   1133.199   41.84431                      1054.084    1218.254
                  sig_2 |   1462.794   37.69385                       1390.75    1538.571
                 rho_12 |   .0010275   .0402227                      -.077651    .0796933
      -----------------------------------------------------------------------------------
      
      .

      Comment


      • #18
        Hi Andrew,

        I think I might owe both yourself and David - hopefully, it pays well!

        This solution works as you have shown, both results appear in one table and are very close to those calculated individually. When I use margins to get the APE's (margins, predict(ystar(0,.)) dydx(*)), I only get results for the first regression - is there some syntax change to get it for both sets of results?

        Comment


        • #19
          Originally posted by Katy Tabero View Post
          This solution works as you have shown, both results appear in one table and are very close to those calculated individually.
          The results are identical. Just note that tobit outputs t-statistics and cmp outputs z-statistics.

          When I use margins to get the APE's (margins, predict(ystar(0,.)) dydx(*)), I only get results for the first regression - is there some syntax change to get it for both sets of results?
          Code:
          webuse mroz87, clear
          set seed 03302022
          gen outcome2= runiformint(1, 4920)
          tobit whrs75 c.nwinc c.wedyrs c.wexper c.wexper#c.wexper c.wifeage c.kl6 c.k618, ll(0) nocons nolog 
          tobit outcome2 c.nwinc c.wedyrs c.wexper c.wexper#c.wexper c.wifeage c.kl6 c.k618, ll(0) nocons nolog
          cmp (whrs75= c.nwinc c.wedyrs c.wexper c.wexper#c.wexper c.wifeage c.kl6 c.k618, nocons) ///
          (outcome2= c.nwinc c.wedyrs c.wexper c.wexper#c.wexper c.wifeage c.kl6 c.k618, nocons), ///
          ind("cond(whrs75>0, $cmp_cont, $cmp_left)" "cond(outcome2>0, $cmp_cont, $cmp_left)") qui
          margins, predict(ys(0 .) eq(#1)) predict(ys(0 .) eq(#2)) dydx(*)
          Res.:

          Code:
          . margins, predict(ys(0 .) eq(#1)) predict(ys(0 .) eq(#2)) dydx(*)
          
          Average marginal effects                        Number of obs     =        753
          Model VCE    : OIM
          
          dy/dx w.r.t. : nwinc wedyrs wexper wifeage kl6 k618
          1._predict   : E(whrs75*|0<whrs75), predict(ys(0 .) eq(#1))
          2._predict   : E(outcome2*|0<outcome2), predict(ys(0 .) eq(#2))
          
          ------------------------------------------------------------------------------
                       |            Delta-method
                       |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
          -------------+----------------------------------------------------------------
          nwinc        |
              _predict |
                    1  |  -5.750593   2.618037    -2.20   0.028    -10.88185    -.619335
                    2  |  -4.276987   4.711722    -0.91   0.364    -13.51179    4.957819
          -------------+----------------------------------------------------------------
          wedyrs       |
              _predict |
                    1  |   63.91861   10.11868     6.32   0.000     44.08635    83.75086
                    2  |   71.91478    19.0562     3.77   0.000     34.56532    109.2642
          -------------+----------------------------------------------------------------
          wexper       |
              _predict |
                    1  |    48.7461   3.558567    13.70   0.000     41.77143    55.72076
                    2  |   8.679914   8.177933     1.06   0.289    -7.348539    24.70837
          -------------+----------------------------------------------------------------
          wifeage      |
              _predict |
                    1  |  -24.77233   2.671484    -9.27   0.000    -30.00834   -19.53632
                    2  |   29.12991   4.858785     6.00   0.000     19.60686    38.65295
          -------------+----------------------------------------------------------------
          kl6          |
              _predict |
                    1  |  -485.3448   62.04923    -7.82   0.000    -606.9591   -363.7306
                    2  |   273.7007   103.3471     2.65   0.008     71.14416    476.2572
          -------------+----------------------------------------------------------------
          k618         |
              _predict |
                    1  |   11.85766   20.49125     0.58   0.563    -28.30445    52.01978
                    2  |   107.1334   38.95688     2.75   0.006      30.7793    183.4875
          ------------------------------------------------------------------------------

          Comment


          • #20
            Originally posted by Andrew Musau View Post

            The results are identical. Just note that tobit outputs t-statistics and cmp outputs z-statistics.

            [/CODE]
            Thank you for highlighting this and for the correct 'margins' syntax - it all seems to be working now!

            The coefficient results are very slightly different, in your example above it is only after 2-3 decimal places they start to differ, so it is minimal, whereas in mine it is a bit more pronounced (in one case by more than 3.5 in the coefficient of one variable). It is odd as when running the Tobit regressions using cmp command individually e.g. with cmp (team_correct= c.endoimposed c.endonotimposed c.exoimposed c.exonotimposed, nocons), ind("cond(team_correct>0, $cmp_cont, $cmp_left)" ) qui), the results are much closer to those provided by the tobit command. So it seems to be something to do with running them simultaneously that throws things off a little.

            Comment


            • #21
              Just ignore those small differences, the results are equivalent.

              Comment

              Working...
              X