Announcement

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

  • calculating OR with 95% CI from margins output

    How can one calculate 95% CI of OR using output of margins command? For example in the margins output below-
    ------------------------------------------------------------------------------
    | Delta-method
    | Margin Std. Err. z P>|z| [95% Conf. Interval]
    -------------+----------------------------------------------------------------
    _at#var |
    1 0 | .3653013 .0049853 73.28 0.000 .3555303 .3750724
    1 1 | .409233 .017422 23.49 0.000 .3750866 .4433794
    2 0 | .3928284 .0064312 61.08 0.000 .3802235 .4054332
    2 1 | .5142021 .023704 21.69 0.000 .4677432 .5606611
    ------------------------------------------------------------------------------

    The OR for 2 0 vs 1 0 would be .3928284/.3653013 but how can we calculate the corresponding 95% CI of this OR?

  • #2
    If you want odds ratios, don't look at the -margins- output. Look at the output of the logistic regression itself. In fact, to make it easier, run the logistic regression command using the -or- option. It'll be right there in the regression table.

    Comment: You don't show the margins command that generated this output, but it isn't obvious that these are even odds from which you could calculate ratios. I don't think odds is even an option for -margins- output. More likely these are either the linear predictor, or the predicted probability. In either case the ratios you suggested in your post would not be odds ratios anyway.

    Comment


    • #3
      Thanks for the reply Clyde. My regression model is something like -

      logistic outcome i.categorical1 i.categorical2 c.continuous1 c.spline* i.categorical1#c.spline*

      where the spline is the
      restricted cubic spline of variable names continuous2. The margins command used for the output is basically to estimate the odds of outcome at 2 different values of continuous2 with categorical1 being 0 or 1. What I want to estimate is the ORs of the outcome between two different values of continuous2 while categorical1 is either 0 or 1.


      Comment


      • #4
        Well, the cubic spline makes it more complicated. You will have to identify which values of spline correspond to the values of continuous2 you are interested in. Let's assume you've already done that and that the values are stored in local macros c2_1 and c2_2. Then I think the next step is:

        Code:
        margins categorical1, predict(xb) at(spline = (`c2_1'  `c2_2')) pwcompare
        The output from that will get you the contrasts you are interested in the xb (i.e. log odds ratio) metric. You can then exponentiate both the contrast itself (which will give you the odds ratio) and the confidence interval around it (which will get you a CI for the odds ratio).

        Comment


        • #5
          Thanks Clyde

          Comment


          • #6
            You're welcome. It dawns on me that we (both you and I) are slightly inaccurate in our terminology. The ratio of the effect of the difference in the two values of the continuous variable when categorical = 1 to the same effect when the categorical = 0 is not an odds ratio (OR). It is a ratio of odds ratios (ROR). It is analogous in an exponentiated metric, to a difference in differences. (This doesn't change anything about how you calculate it.)

            Comment

            Working...
            X