Announcement

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

  • Margins with gsem, random effects, and nominal dependent variable

    I used gsem to estimate a model with a nominal dependent variable and a random slope.
    Code:
     gsem (ctype <- c.age##c.age i.qpercbaR M1[zcta]), mlogit
    I would like to estimate margins, but I am running into this error:

    Code:
    . margins, at(qpercbaR=(1 5)) predict(outcome(2)) post
    invalid outcome() option;
    depvar 2 not found
    r(198);
    
    . margins, at(totscore_cntr=(-1.5(.5)1.5) qpercbaR=(1 5)) predict(outcome(1)) post
    invalid outcome() option;
    depvar 1 not found
    r(198);
    This occurs even as the output contains the categories of 1.ctype and 2.ctype.

    Is there a way to estimate the margins for each level of the dependent variable?

  • #2
    Easy enough to provide a reproducible example here. See FAQ Advice #12 on how best to pose questions. You need to specify the full outcome.

    Code:
    webuse sysdsn1, clear
    gsem (insure <- c.age##c.age i.male i.nonwhite i.site), mlogit
    
    *WHAT YO HAVE
    margins, at(site=(2 3)) predict(outcome(2)) post
    
    *WHAT YO NEED
    margins, at(site=(2 3)) predict(outcome(2.insure)) post
    Res.:

    Code:
    . 
    . *WHAT YO HAVE
    
    . 
    . margins, at(site=(2 3)) predict(outcome(2)) post
    invalid outcome() option;
    depvar 2 not found
    r(198);
    
    . 
    . 
    . 
    . *WHAT YO NEED
    
    . 
    . margins, at(site=(2 3)) predict(outcome(2.insure)) post
    
    Predictive margins                                         Number of obs = 615
    Model VCE: OIM
    
    Expression: Predicted mean (2.insure), predict(outcome(2.insure))
    1._at: site = 2
    2._at: site = 3
    
    ------------------------------------------------------------------------------
                 |            Delta-method
                 |     Margin   std. err.      z    P>|z|     [95% conf. interval]
    -------------+----------------------------------------------------------------
             _at |
              1  |   .5295559   .0326818    16.20   0.000     .4655007    .5936111
              2  |   .3408466    .033945    10.04   0.000     .2743155    .4073776
    ------------------------------------------------------------------------------

    Comment

    Working...
    X