Announcement

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

  • Testing interactions in logistic regression

    A randomised trail studied the effect of a drug on mortality in low-birth-weight babies. The drug had no effect but, if it *had* been effective, how would I use Stata 15 (Windows) to test whether the effect of the drug in babies weighing <1000 g (baseline) differed from (1) the effect in babies weighing 1000-1499 g and (2) from the effect in babies weighing 1500-1999 g?

    The Stata file has
    died: 0 (survived), 1 (died)
    drug: 0 (control), 1 (treatment)
    wtgp: 0 (0-999g), 1 (1000-1499g), 2 (1500-1999g).

    Code:
    . cs died drug, by(wtgp)
     
               wtgp |       RR       [95% Conf. Interval]   M-H Weight
    -----------------+-------------------------------------------------
              0-999g |    .8643293     .7181096   1.040322     32.19632
          1000-1499g |    1.034783      .831774   1.287339         57.5
          1500-1999g |    .9549525     .6873575   1.326725     34.01655
    ------------------------------------------------------------------------------
    Using the Excel spreadsheet for ratios from http://www.statpages.info/Confidence...0P-values.xlsx
    wtgp 0 vs 1: 0.86 (0.72-1.04) vs 1.03 (0.83-1.29) gives p = 0.22.
    wtgp 0 vs 2: 0.86 (0.72-1.04) vs 0.95 (0.69-1.33) gives p = 0.60.

    Code:
    . logistic died i.drug##i.wtgp
    ------------------------------------------------------------------------------
            died | Odds Ratio   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
          1.drug |   .5721154   .2068869    -1.54   0.123      .281627    1.162232
            wtgp |
              1  |   .0979067   .0287701    -7.91   0.000     .0550408    .1741566
              2  |   .0188347   .0056566   -13.23   0.000     .0104549    .0339312
       drug#wtgp |
            1 1  |   1.832185   .7197436     1.54   0.123     .8483771    3.956852
            1 2  |   1.663846   .6716229     1.26   0.207     .7542577    3.670342
           _cons |   3.764706    1.02721     4.86   0.000     2.205355    6.426634
    ------------------------------------------------------------------------------
     
    . margins wtgp, dydx(drug) pwcompare(effects)
    Pairwise comparisons of conditional marginal effects
    Model VCE    : OIM
    Expression   : Pr(died), predict()
    dy/dx w.r.t. : 1.drug
    ------------------------------------------------------------------------------
                 |   Contrast Delta-method    Unadjusted           Unadjusted
                 |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
    0.drug       |  (base outcome)
    -------------+----------------------------------------------------------------
    1.drug       |
            wtgp |
         1 vs 0  |   .1165643    .074964     1.55   0.120    -.0303625    .2634911
         2 vs 0  |   .1042139   .0693238     1.50   0.133    -.0316582    .2400861
         2 vs 1  |  -.0123504   .0323953    -0.38   0.703     -.075844    .0511433
    ------------------------------------------------------------------------------
    P = 0.22 (from Excel) differs from p = 0.120 (margins)
    P = 0.60 (from Excel) differs from p = 0.133 (margins).

    What is the correct way to compare the effect on drug of wtgp 0 vs 1, and wtgp 0 vs 2?
    I apologise if this problem is very basic, but I’ve spent many hours trying to solve it.
Working...
X