Announcement

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

  • Using margins following ordered logistic regression

    Hello all,

    I performed an ordered logistic regression.
    ASA - categorical variable - index of how sick patients are 1-3 (3 is the sickest patient; 1 is the healthiest patient)
    Anaestethictype - categorical variable 0 or 1 (0 - Local ; 1 - General anaestethic)

    Code:
    ologit ASA anaestethictype age [pw=attweight], or
    I then wanted to obtain the predicted probabilities of the degress of sickliness of the patient according to the anaesthethic used

    So I used margins

    Code:
    margins, at (anaesthethictype=(0/1)) predict(outcome(1)) at means //ASA1
    margins, at (anaesthethictype=(0/1)) predict(outcome(1)) at means //ASA2
    margins, at (anaesthethictype=(0/1)) predict(outcome(1)) at means //ASA3

    My question:
    Stata correctly for each ASA level generates probabilities for anaesthethic type 0 & 1 for each ASA level (1-3) - hoorah
    However, I just want to know how does Stata know I wanted to generate these probabilities for ASA - when I have never specified them in my code?

    Having following the tutorial by Statacorp
    -margins- always seems to be used with other covariates
    https://www.youtube.com/watch?v=7maMbX_65b0

    But as my Asa is my dependent variable - its not a covariate, if I type
    -margins ASA-
    Stata says: factor asa not found in list of covariates

    I've use the above following another tutorial, but I'm still curious how Stata knew it had to generate those probabilities for each ASA level


    In addition I also tried margins with -logit-

    largemandible - depedent variable - categorical variable - 0 (absent) 1 (present)

    Code:
    logit largemandible anaesthethictype age
    I then tried to use the -margins command-
    Code:
    margins largemandible
    Stata error: Factor largmandible not found in list of covariates (of course as this is the dependent variable)

    I then tried

    Code:
    margins, at (anaesthethictype=(0/1)) predict(outcome(0)) at means // Absent large mandible
    Stata error: Equation 0 not found
    Last edited by Rose Matthews; 10 Oct 2023, 04:36.

  • #2
    Seems like outcome should be 1 2 or 3 in the first set of margins. Otherwise you'd get the same result. ?

    margins is only for regressors, not DV.

    so margins anaesthethictype

    logit does not have outcomes, so drop predict(outcome(0)).

    could also do

    margins, dydx(anaesthethictype)

    but the "at" option will give you the levels at the 0 and 1






    Comment


    • #3
      Originally posted by George Ford View Post
      Seems like outcome should be 1 2 or 3 in the first set of margins. Otherwise you'd get the same result. ?
      I assume you're referring to this :

      Code:
       
       ologit ASA anaestethictype age [pw=attweight], or  
       margins, at (anaesthethictype=(0/1)) predict(outcome(1)) at means //ASA1
      And to change 1 to 2 and 3 subsequentyl for each ASA level

      However, my question still remains unanswered...how does Stata know it has to give predicted probabilities for ASA - when it's the DV. And there is age as another covariate...




      [QUTOE]
      logit does not have outcomes, so drop predict(outcome(0)).
      [/QUOTE]

      What do you mean by this logit does not have outcomes?

      I wanted to use the margins to use with DV (see below).... it;s only used for regressors, what's the alternative?


      Code:
      margins anaesthethictype
      This would only give the margins for anaesthethic type (local or General Anaesthethic) when I'm interested if the person had a large mandible or not (mandible) and whether this was more likely to influence the decision of the doctor to give a General Anaesthethic or not.


      Comment


      • #4
        1. margins always gives you some type of effect on the DV. that's what it does because that's what's interesting. but keep in mind if you're trying to predict the outcome (1,2, or 3), that's a whole 'nother issue and tricky to do.
        2. the predict(outcomes(n)) is telling Stata to predict the probability (in your case) for a particular outcome. with Logit, it's just 0/1 for one outcome so you don't need the predict(outcome(n)) part. with ologit, you have many outcomes (1, 2, and 3 in your case), so you have to tell Stata which one you want.
        3. mandible is the DV, it does not belong in the margins command. anaethetictype is 0/1, so the margins command will return the effect on mandible for moving from 0 to 1 on anesthetictype. can also do (at(anasthetictype = 0 1)) to get the predictions at 0 and 1.


        Comment


        • #5
          If you interested in how things affect anethetictype, then you're models are backwards and you don't need ologit. And why not put it all in one model to avoid mispecification?

          I would think that anesthetictype would be affected by illness (unless the anes is causing the illness), but I'm not that sort of doctor. If as you see it, then models are provided.

          Code:
          reg  anesthetictype largemandible i.ASA age, r
          logit anesthetictype largemandible i.ASA age, or
          margins, dydx(anesthetictype age)
          margins, over(ASA)
          ** the margins should be nearly identical to the coefficients from the LPM.
          
          ** or
          reg  anesthetictype largemandible age, r
          logit anesthetictype largemandible age, or
          margins, dydx(anesthetictype age)
          
          ologit ASA anesthetictype age, or
          margins, dydx(anesthetictype) predict(outcome(1))
          margins, dydx(anesthetictype) predict(outcome(2))
          margins, dydx(anesthetictype) predict(outcome(3))


          Last edited by George Ford; 11 Oct 2023, 12:23.

          Comment

          Working...
          X