Announcement

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

  • Fix a coefficient to the value it had in previous mlogit

    Hi everyone,

    this may be a very simple problem and I am just not getting it, but here's what I am trying to do. I want to use -mlogit- on a 4-category dependent variable. The plan is to estimate the model, save the coefficients, fix the value of some of the b's to the value obtained in the previous regression, then run a new model. My problem is I cannot seem to find any syntax that will fix the value. I tried the following:

    Method 1:
    mlogit depvar age c.age#c.age . . . ;

    constraint 1 [#2]age = [#2]_b[age] ;
    mlogit depvar age c.age##c.age . . . , constraints(1) ;
    The constraint is ignored (because the second mlogit has standard errors for the coefficient, instead of just saying the value and then saying (constrained).

    Method 2
    mlogit depvar age c.age##c.age . . . ;

    gen c01 = [#2]_b[age]] ;
    constraint 1 [#2]_cons = c01;
    mlogit depvar age c.age##c.age . . ., constraints(1) ;
    This produces error r(111).

    Method 3 (I knew this would not work, but it was nice confirmation):
    mlogit depvar age c.age#c.age . . . ;

    constraint 1 [#2]age = .0296174 ;
    mlogit depvar age c.age##c.age . . . , constraints(1) ;
    This constrains the coefficient, but other coefficients change their values, which just shows I don't have "all" (or enough of) the digits.

    I think I could display "enough" of the digits and copy them one-by-one into the code, but 1)I am likely to make mistakes; 2)I want to do this for too many variables in a model for it to be feasible, 3)I want to do this for too many models for it to be feasible, and 4)I find it very hard to believe stata has no way for me to use some elements in _b to constrain coefficients in the next regression. I just can't seem to find my way to the write (no pun intended) syntax. I've looked at the manual entries for a)mlogit, b)constraints, c)matrix operations, and a few others. I googled various terms, and I searched the forum as well (google turned up some listserv era discussions, but I could find nothing on my question). It may be a very simple thing I am just missing. But I'm nowhere near converging to a solution. I appreciate any help anyone can offer.

    Thanks!
    Sam

  • #2
    Add the option -coeflegend- to see how to refer to the coefficient.

    Code:
    webuse sysdsn1, clear
    mlogit insure age male nonwhite i.site
    constraint 1 _b[Prepaid:age]=  `=_b[Prepaid:age]' 
    mlogit insure age male nonwhite i.site, constraint(1)
    Res.:

    Code:
    . mlogit insure age male nonwhite i.site
    
    Iteration 0:   log likelihood = -555.85446  
    Iteration 1:   log likelihood = -534.67443  
    Iteration 2:   log likelihood = -534.36284  
    Iteration 3:   log likelihood = -534.36165  
    Iteration 4:   log likelihood = -534.36165  
    
    Multinomial logistic regression                         Number of obs =    615
                                                            LR chi2(10)   =  42.99
                                                            Prob > chi2   = 0.0000
    Log likelihood = -534.36165                             Pseudo R2     = 0.0387
    
    ------------------------------------------------------------------------------
          insure | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
    -------------+----------------------------------------------------------------
    Indemnity    |  (base outcome)
    -------------+----------------------------------------------------------------
    Prepaid      |
             age |   -.011745   .0061946    -1.90   0.058    -.0238862    .0003962
            male |   .5616934   .2027465     2.77   0.006     .1643175    .9590693
        nonwhite |   .9747768   .2363213     4.12   0.000     .5115955    1.437958
                 |
            site |
              2  |   .1130359   .2101903     0.54   0.591    -.2989296    .5250013
              3  |  -.5879879   .2279351    -2.58   0.010    -1.034733   -.1412433
                 |
           _cons |   .2697127   .3284422     0.82   0.412    -.3740222    .9134476
    -------------+----------------------------------------------------------------
    Uninsure     |
             age |  -.0077961   .0114418    -0.68   0.496    -.0302217    .0146294
            male |   .4518496   .3674867     1.23   0.219     -.268411     1.17211
        nonwhite |   .2170589   .4256361     0.51   0.610    -.6171725     1.05129
                 |
            site |
              2  |  -1.211563   .4705127    -2.57   0.010    -2.133751   -.2893747
              3  |  -.2078123   .3662926    -0.57   0.570    -.9257327     .510108
                 |
           _cons |  -1.286943   .5923219    -2.17   0.030    -2.447872   -.1260134
    ------------------------------------------------------------------------------
    
    . 
    . constraint 1 _b[Prepaid:age]=  `=_b[Prepaid:age]' 
    
    . 
    . mlogit insure age male nonwhite i.site, constraint(1)
    
    Iteration 0:   log likelihood = -575.10054  
    Iteration 1:   log likelihood = -535.15947  
    Iteration 2:   log likelihood = -534.37007  
    Iteration 3:   log likelihood = -534.36165  
    Iteration 4:   log likelihood = -534.36165  
    
    Multinomial logistic regression                         Number of obs =    615
                                                            Wald chi2(9)  =  37.13
    Log likelihood = -534.36165                             Prob > chi2   = 0.0000
    
     ( 1)  [Prepaid]age = -.011745
    ------------------------------------------------------------------------------
          insure | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
    -------------+----------------------------------------------------------------
    Indemnity    |  (base outcome)
    -------------+----------------------------------------------------------------
    Prepaid      |
             age |   -.011745  (constrained)
            male |   .5616934   .2013789     2.79   0.005      .166998    .9563889
        nonwhite |   .9747768    .235829     4.13   0.000     .5125605    1.436993
                 |
            site |
              2  |   .1130359   .2093837     0.54   0.589    -.2973486    .5234204
              3  |  -.5879879   .2270832    -2.59   0.010    -1.033063    -.142913
                 |
           _cons |   .2697127   .1732175     1.56   0.119    -.0697874    .6092128
    -------------+----------------------------------------------------------------
    Uninsure     |
             age |  -.0077961   .0110929    -0.70   0.482    -.0295377    .0139455
            male |   .4518496   .3673261     1.23   0.219    -.2680964    1.171796
        nonwhite |    .217059    .425563     0.51   0.610    -.6170291    1.051147
                 |
            site |
              2  |  -1.211563   .4704363    -2.58   0.010    -2.133601   -.2895245
              3  |  -.2078123   .3661794    -0.57   0.570    -.9255107     .509886
                 |
           _cons |  -1.286943   .5779453    -2.23   0.026    -2.419695   -.1541909
    ------------------------------------------------------------------------------

    Comment


    • #3
      Thank you Andrew, that solved my problem. I appreciate it!

      Take care.
      Sam

      Comment

      Working...
      X