Announcement

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

  • Contrast of marginal predicted mean

    Dear all,

    I am estimating the following model:

    Code:
    melogit tradeoff c.vote_share##c.lfirstp  || cntrynum: vote_share
    I have estimated the marginal predicted mean across values of lfirstp for two values of the variable vote_share (1 and 51) using the margins command.

    Code:
    margins, at(lfirstp=(-2.4(2)2.4) vote_share=(1 51))
    What I want to do next is to estimate the difference in the predicted mean (and the corresponding statistical significance of the difference) for values vote share 1 and 51 at different values of lfirstp. I thought something like this would work.

    Code:
    margins r1.vote_share#r51.vote_share, at(lfirstp=(-2.4(.4)2.4)) level(95)
    However, trying to estimate this leads to the following error:

    Code:
    vote_share:  factor variables may not contain noninteger values
    Do you have any idea about how I could do this?

    Thanks!
    Last edited by Enrique Hernandez; 04 Jun 2019, 08:43.

  • #2
    It seems the command is trying to consider vote_share a categorical variable in order to apply contrasts, but it is a continuous variable, hence the error message. In short, with "r." you're supposed to have a categorical variable.
    Best regards,

    Marcos

    Comment


    • #3
      Dear Marcos,

      Thank you for your answer.

      Yes, the "r." only works for categorical variables.

      I wonder if there is any way to perform such a test with a continuos variable. That is, comparing the predicted mean of two specific values of a given continuos variable.

      Comment


      • #4
        I am not entirely sure I get exactly what you have in mind, but you can apply contrasts to margins:


        Code:
        sysuse auto, clear
        reg price mpg weight
        margins, at(weight = (1000(1000)5000) mpg = (10 20))
        margins, at(weight = (1000(1000)5000) mpg = (10 20)) contrast(atcontrast(ar._at) wald)
        You can also post the results of margins and then manipulate the coefficients with test, lincom and nlcom as if they were estimation results:
        Code:
        margins, at(weight = (1000(1000)5000) mpg = (10 20)) post coefl
        test _b[2._at] = _b[6._at]
        test (_b[2._at] = _b[6._at]) (_b[3._at] = _b[7._at])

        Comment

        Working...
        X