Announcement

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

  • Running and interpreting interaction (with simple slopes) in logistic regression in complex survey sample

    I am using a dataset which used a complex sampling design and trying to interpret an interaction (2 binary IVs) in logistic regression. The interaction was significant, so I need to get simple slopes as well. I also need to run the model once more with several covariates included. I am creating tables with results in terms of odds ratios and 95% CIs as well as an interaction plot with probability on the Y-axis.

    How can I go about this in Stata? The original model gives me the main effects and interaction term in terms of OR, but not simple slopes (for IV2) or probabilities of each condition (e.g., p(DV=1) when IV1=0 IV2=1). Here is the original model code:
    Code:
       use "/data.dta";  svyset _psu, strata(_ststr) weight(_finalwt) vce(linearized) singleunit(centered) ; svy linearized: logistic DV i.IV1##i.IV2; svy linearized: logistic DV i.IV1##i.IV2 i.cov1 i.cov2 i.cov3
    I know there are commands which can get me the simple slopes (I think 'margins' and 'contrast'?) in terms of OR with 95% CI as well as the probabilities, but the type of survey means that some of these commands won't work. I would of course like to avoid making calculations by hand to avoid error.
    Last edited by Declan Gilmer; 05 Feb 2020, 10:42. Reason: added tags

  • #2
    This is what the -margins- command is for. As you have already used factor-variable notation in your regressions, you are good to go.

    Code:
    svy: logit …. i.IV1##i.IV2...
    margins IV2, dydx(IV1) // SIMPLE SLOPES OF IV1 CONDITIONAL ON IV2 VALUES
    margins IV1, dydx(IV2) // SIMPLE SLOPES OF IV2 CONDITIONAL ON IV1 VALUES
    It works the same way with or without the covariates.

    Comment


    • #3
      Hi Clyde, thank you so much for your help! So I ran as a logistic regression (not logit) and used the margins command as you specified. Now I want to make sure I understand the interpretation. Would the simple slopes be in terms of probability (change in probability of DV=1 when IV1 increases by 1 unit)? I will also need this info in terms of OR and 95% CI, as well as specific probability of DV=1 when IVs are at different levels (for plotting). Here is what I get as an output in Stata:

      Click image for larger version

Name:	marginal effects.png
Views:	2
Size:	12.6 KB
ID:	1535791
      Attached Files

      Comment


      • #4
        I would love to respond to your question. But it appears you have not read the FAQ explaining that screenshots are not helpful. In particular, your screenshot shows up on my computer as a tiny rectangle that has contents that are way too small to read. Please post back showing the output in a readable way: follow the advice in FAQ #12 on how to do that. Or perhaps somebody else's computer displays this in a readable way and they will respond.

        Comment


        • #5
          Hi Clyde, thank you for pointing this out; I am a newbie and had not read through the FAQ yet. Hopefully the following is more readable. First, I am checking that the following table gives me the change in probability of DV=1 when IV mari increases by 1 (for both levels of my other IV rsnmrjna).

          Code:
          . margins rsnmrjna, dydx(mari) 
          
          Conditional marginal effects    Number of    obs     =      1,318
          Model VCE    : Linearized
          
          Expression   : Pr(addepev2), predict()
          dy/dx w.r.t. : 2.mari
          
                  
          Delta-method
                dy/dx       Std. Err.     t      P>t    [95% Conf. Interval]
                  
          1.mari         (base outcome)
                  
          2.mari       
          rsnmrjna 
          0     .4156902   .0976643     4.26    0.000    .2240427    .6073377
          1     .0519224   .0631166     0.82    0.411    .0719318    .1757766
                  
          Note: dy/dx for factor levels is the discrete    change from    the base level.
          Second, I want to confirm that the following table gives me the predicted probabilities of DV=1 at each level of the IVs (e.g., mari=1 and rsnmrjna=0):

          Code:
          . mtable, at (rsnmrjna=(0 1) mari=(1 2))
          
          Expression: Pr(addepev2), predict()
          
                 mari  rsnmrjna     Pr(y)
          
          1         1         0     0.178
          2         1         1     0.404
          3         2         0     0.593
          4         2         1     0.456
          If this is the case, it helps me create my interaction plot, but I still need to figure out the code to get the simple slopes of mari when rsnmrjna=0 and 1 in terms of odds ratios.

          Comment


          • #6
            Both of your interpretations of the -margins- output are correct.

            To get simple odds ratios, you have to go back to the regression output itself and do some fancy footwork with -nlcom-. For example, to get the simple odds ratio for rsnmrjna = 1 and mari = 2, compamred to rsnmrjna = 0 and mari = 1, you would run
            Code:
            nlcom exp(_b[1.rsnmrjna] + _b[2.mari] + _b[1.rsnmrjna#2.mari])

            Comment

            Working...
            X