Announcement

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

  • Test whether coefficients that are stored in stata matrices are equal

    Hello,

    I am running two multinomial logistic regressions and I store the results:

    Code:
    mlogit A i.wave##c.B, noconstant base(0) noomitted noemptycells
    est store m1
    
    mlogit C i.wave##c.B, noconstant base(0) noomitted noemptycells
    est store m2
    ( 1) = -.0004935

    Then, I run the margins commands to get the marginal effects, which I save in two matrices:

    Code:
    forval i = 1/1 {
    est res m1
    margins, dydx(B) over(wave) pr(out(`i')) atmeans post  
    margins, coeflegend
    matrix b_1 = e(b)
    est res m2
    margins, dydx(B) over(wave) pr(out(`i')) atmeans post
    margins, coeflegend
    matrix b_2 = e(b)
    }
    Finally, I am trying to compare the marginal effects,


    Code:
    test b_1[1,1]=b_2[1,1]
    test b_1[1,2]=b_2[1,2]
    test b_1[1,3]=b_2[1,3]
    but I am getting an error:

    Code:
    . test b_1[1,1]=b_2[1,1]
    
     ( 1) = -.0004935
           Constraint 1 dropped
    
               chi2(  0) =       .
             Prob > chi2 =         .
    
    . test b_1[1,2]=b_2[1,2]
    
     ( 1) = -.0781045
           Constraint 1 dropped
    
               chi2(  0) =       .
             Prob > chi2 =         .
    
    . test b_1[1,3]=b_2[1,3]
    
     ( 1) = -.0161702
           Constraint 1 dropped
    
               chi2(  0) =       .
             Prob > chi2 =         .

    What am I doing wrong?

    What do these
    Code:
    ( 1) = -.0004935
    mean?

    How can I fix it and compare whether the marginal effects are equal or not?

    Thanks
    Last edited by Andreas Tetlock; 08 Mar 2016, 07:48.

  • #2
    You can't "fix" this -test- command. -test- is designed for testing of coefficients from the current estimates in e(). While it can have a scalar (which could be a matrix element) on one side of the equation, you can't even run -test 2 = 3- and get anything better than what you have. Actually, it would have been better for -test to just declare a syntax error rather than give you some number whose meaning is an enigma to everyone, except perhaps the person who coded -test- for Stata Corp.

    In general, if you wanted to test equality of coefficients across models, you would store both sets of model estimates and then combine them with -suest-. Following -suest-, you can then use -test- to contrast coefficients from different models.

    But -suest- will not accept the estimates that come out of -margins, dydx()-, so that path is blocked. I do not know of any way to contrast marginal effects across models in Stata. And I think at least some statisticians would say that it isn't meaningful to do in any case even if you figure out a way.

    Comment


    • #3
      Hi Clyde,

      How can I then compare whether the effect of B on A is any different than the effect of B on C for each of the outcomes?

      Comment


      • #4
        As I said, if you back away from marginal effects and look at the coefficients in -mlogit-, you can do it with -suest- followed by -test-. I will leave it to you to think about whether that is even a reasonable thing to do, but that is how you could do it. If you really want a contrast of the marginal effect of B on A with B on C, I don't know how it can be done, and I don't think it can.

        Comment


        • #5
          Hi Clyde,

          Thanks. You gave me some good information, and at least I can try to do the suest with the coefficients of the mlogit, as you suggested.
          My econometrics knowledge is not too advanced, so I would imagine that such a comparison would make sense.

          But I guess this discussion is more philosophical, since there is no obvious way to do it in Stata. And I searched on line and I couldn't find a way in R as well.

          Actually this is requested by a reviewer in a journal, to check whether any difference exists between the effect of the independent variable on the two different dependent variables. So I gotta do something so that the reviewer doesn't get completely pissed off, if (s)he thinks I ignore him (her)!
          But I am not sure if the reviewer was aware of the story with the marginal effects and whether this can actually be implemented.

          I will try to do something with the suest and see what happens!

          Thanks for your help Clyde, you were really helpful!
          Last edited by Andreas Tetlock; 08 Mar 2016, 11:16.

          Comment

          Working...
          X