Announcement

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

  • Margins Command for Multilevel mixed-effects logistic regression

    Hello,

    I'm currently trying to run predicted probability for a multilevel mixed-effects logistic regression using survey data. All the independent variables are categorical while the dependent is binary. The model looks like this:

    xi: melogit covid i.income i.education i.ethnicity i.age [weighting] || id:, or nolog

    When running the margins command, I used:

    margins i.age

    I keep getting age not found in list of covariates. I was wondering how I'd go about fixing that. Apologies if this is not enough information and/or too simple of a question, but I've been struggling trying to figure this out,

    Thanks!
    Last edited by Craig Lewis; 17 Mar 2024, 09:03.

  • #2
    Remove the xi prefix

    Comment


    • #3
      Hello,

      Thank you, that worked! if I wanted to include an interaction term within the model and then do predicted probability, how would I code that? For example, I wanted to do this:, but removing the xi prefix doesn't allow me to include the interaction term.

      xi: melogit covid i.income i.education i.ethnicity i.age i.income*state_funding [weighting] || id:, or nolog

      Would I still do margins or something else? Sorry again if this doesn't make any sense, I'm still trying to wrap my head around this!
      Last edited by Craig Lewis; 17 Mar 2024, 11:08.

      Comment


      • #4
        You need to read -help fvvarlist- so that you understand the syntax and meaning of factor variable notation. That way you won't have to post this kind of question here and then wait around for hours or days for somebody to answer them for you.

        For learning more about -margins-, and specifically in relation to interaction models, I think the most helpful materials are https://www3.nd.edu/~rwilliam/stats/Margins01.pdf and
        https://www3.nd.edu/~rwilliam/stats2/l53.pdf, both by Richard Williams and both uncommonly clear.

        Code:
        melogit covid i.income i.education i.ethnicity i.age i.income##c.state_funding [weighting] || id:, or nolog
        I'm not showing code for the use of -margins- here because from your description of the problem, I can't determine which predictive margins or marginal effects are relevant to your research question(s).

        Comment

        Working...
        X