Hi everyone,

I have a question about mediation when there is an interaction between 2
categorical variables, one with two levels and one with three levels.

Using the ‘mediation’ package by Tingley and colleagues in R, I’m trying to
conduct a bootstrapped mediation analysis for an interaction between a
2-level categorical IV (‘condstorm’) and another 3-level categorical IV
(‘condmean’).  The mediator (‘trustmed2’) is dichotomous, and the dependent
variable (‘AttInd’) is continuous.

Categorical 2-level IV ‘condstorm’

    table(d$condstorm)

        nostorm   storm
        604     570

Categorical 3-level IV ‘condmean’

    table(d$condmean)

    both high mean
    413  375  386

Dichotomous mediator ‘trustmed2’

    table(d$trustmed2)

        0   1
        305 866

Continuous DV ‘AttInd’

    summary(d$AttInd)
    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's
    0.0000  0.3571  0.6200  0.5801  0.8214  1.0000       3


The code and output for the model with the mediator is:

    contrasts(d$condstorm)
        storm
    nostorm     0
    storm       1

    contrasts(d$condmean)
         nonevhigh nonevboth
    both         0         1
    high         1         0
    mean         0         0


    med.fit <- glm(trustmed2 ~ condmean*condstorm + gwbelief + trustmed1 +
coastdwell + partyID + polor + gender + age + race + educ + income + region,
weights=weight1, data = d, family = binomial('probit'))

    summary(med.fit)

    Call:
    glm(formula = trustmed2 ~ condmean * condstorm + gwbelief +
trustmed1 +  coastdwell
+ partyID + polor + gender + age + race + educ + income + region, family =
binomial("probit"), data = d, weights = weight1)

    Deviance Residuals:
        Min       1Q   Median       3Q      Max
    -3.9982  -0.1429   0.2196   0.4594   3.2721

    Coefficients:
                         Estimate Std. Error z value Pr(>|z|)
    (Intercept)          -1.876115   0.284494  -6.595 4.27e-11 ***
    condmeannonevhigh     0.170809   0.175454   0.974  0.33029
    condmeannonevboth     0.497041   0.181383   2.740  0.00614 **
    condstormstorm        0.285569   0.182081   1.568  0.11680
    gwbeliefnotvref       0.056512   0.631022   0.090  0.92864
    gwbeliefnotvprobs     0.746556   0.129610   5.760 8.41e-09 ***
    trustmed1             1.908566   0.121064  15.765  < 2e-16 ***
    coastdwellyes         0.320369   0.128445   2.494  0.01262 *
    partyIDvdem           0.585477   0.148862   3.933 8.39e-05 ***
    partyIDvref          -0.468275   0.654078  -0.716  0.47403
    partyIDvrep           0.058146   0.130621   0.445  0.65621
    polorvref            -0.316949   0.508007  -0.624  0.53269
    polorvlib            -0.058482   0.160609  -0.364  0.71577
    polorvcons           -0.369565   0.122246  -3.023  0.00250 **
    genderMale           -0.009229   0.105253  -0.088  0.93013
    agev1824              0.235127   0.194856   1.207  0.22756
    agev2534              0.099723   0.178256   0.559  0.57587
    agev3544              0.119399   0.169987   0.702  0.48243
    agev4554              0.221921   0.176420   1.258  0.20842
    agev5564              0.173343   0.170355   1.018  0.30890
    racevhisp             0.033141   0.177162   0.187  0.85161
    racevblack           -0.323867   0.188305  -1.720  0.08545 .
    racevother            0.475179   0.234313   2.028  0.04256 *
    educhsvsome          -0.002255   0.132574  -0.017  0.98643
    educhsvcollgrad       0.201980   0.146240   1.381  0.16723
    educhsvref            1.304337   0.666427   1.957  0.05032 .
    incomev3050          -0.095963   0.159290  -0.602  0.54688
    incomev5075           0.184528   0.168946   1.092  0.27473
    incomev75100          0.028269   0.191474   0.148  0.88263
    incomev100           -0.249873   0.167648  -1.490  0.13610
    regionvmw            -0.058581   0.163619  -0.358  0.72032
    regionvne             0.315495   0.177227   1.780  0.07505 .
    regionvs              0.204790   0.145384   1.409  0.15895
    condmeannonevhigh:condstormstorm -0.061962   0.263472  -0.235  0.81407

    condmeannonevboth:condstormstorm -0.665467   0.253958  -2.620  0.00878
**
    ---
    Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

    (Dispersion parameter for binomial family taken to be 1)

        Null deviance: 1316.98  on 1170  degrees of freedom
    Residual deviance:  767.03  on 1136  degrees of freedom
      (3 observations deleted due to missingness)
    AIC: 836.49

    Number of Fisher Scoring iterations: 6

And the code and output for the model with the mediator included as a
predictor on the dependent variable:

    out.fit <- lm(AttInd ~ trustmed2 + condmean*condstorm + trustmed1 +
gwbelief + coastdwell + partyID + polor + gender + age + race + educ +
income + region, weights=weight1, data = d)

    summary(out.fit)

    Call:
    lm(formula = AttInd ~ trustmed2 + condmean * condstorm + trustmed1 +
        gwbelief + coastdwell + partyID + polor + gender + age +
        race + educ + income + region, data = d, weights = weight1)

    Weighted Residuals:
         Min       1Q   Median       3Q      Max
    -0.79365 -0.12054  0.00739  0.12351  0.72377

    Coefficients:
                      Estimate Std. Error t value Pr(>|t|)
    (Intercept)         1.754e-01  3.411e-02   5.143 3.18e-07 ***
    trustmed2           2.777e-01  1.940e-02  14.313  < 2e-16 ***
    condmeannonevhigh  -8.754e-03  2.174e-02  -0.403 0.687311
    condmeannonevboth   2.548e-02  2.148e-02   1.186 0.235756
    condstormstorm      3.977e-02  2.250e-02   1.767 0.077433 .
    trustmed1           2.084e-02  2.014e-02   1.035 0.301053
    gwbeliefnotvref    -1.063e-01  9.071e-02  -1.172 0.241589
    gwbeliefnotvprobs   1.574e-01  1.818e-02   8.656  < 2e-16 ***
    coastdwellyes       1.100e-02  1.485e-02   0.740 0.459293
    partyIDvdem         6.283e-02  1.618e-02   3.884 0.000109 ***
    partyIDvref         -2.558e-01  8.716e-02  -2.934 0.003408 **
    partyIDvrep         -4.893e-02  1.688e-02  -2.898 0.003829 **
    polorvref            8.509e-02  6.617e-02   1.286 0.198751
    polorvlib            6.199e-02  1.742e-02   3.558 0.000389 ***
    polorvcons          -7.015e-03  1.571e-02  -0.447 0.655204
    genderMale          -5.778e-03  1.267e-02  -0.456 0.648363
    agev1824             4.624e-03  2.391e-02   0.193 0.846692
    agev2534            -1.773e-02  2.222e-02  -0.798 0.425121
    agev3544             2.952e-02  2.107e-02   1.401 0.161448
    agev4554             1.590e-02  2.159e-02   0.736 0.461613
    agev5564            -9.967e-03  2.073e-02  -0.481 0.630765
    racevhisp            4.936e-02  2.030e-02   2.432 0.015174 *
    racevblack          -1.585e-02  2.224e-02  -0.713 0.476104
    racevother           4.969e-02  2.518e-02   1.973 0.048687 *
    educhsvsome         -1.016e-02  1.612e-02  -0.630 0.528528
    educhsvcollgrad     -1.209e-02  1.713e-02  -0.706 0.480595
    educhsvref           2.383e-01  8.213e-02   2.901 0.003791 **
    incomev3050         -9.128e-04  1.964e-02  -0.046 0.962941
    incomev5075          1.522e-02  1.996e-02   0.762 0.446132
    incomev75100        -3.185e-02  2.280e-02  -1.397 0.162813
    incomev100           1.344e-02  2.013e-02   0.668 0.504422
    regionvmw            3.467e-02  2.027e-02   1.710 0.087541 .
    regionvne            1.861e-02  2.015e-02   0.924 0.355812
    regionvs             -7.531e-05  1.716e-02  -0.004 0.996499
    condmeannonevhigh:condstormstorm -4.354e-03  3.152e-02  -0.138 0.890175

    condmeannonevboth:condstormstorm -5.284e-02  3.090e-02  -1.710 0.087514
.
    ---
    Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

    Residual standard error: 0.2103 on 1135 degrees of freedom
      (3 observations deleted due to missingness)
    Multiple R-squared:  0.4546, Adjusted R-squared:  0.4378
    F-statistic: 27.03 on 35 and 1135 DF,  p-value: < 2.2e-16

The model without the mediator is:

    out.fit <- lm(AttInd ~ condmean*condstorm + trustmed1 + gwbelief +
coastdwell +
                    partyID + polor + gender + age + race + educ + income +
                     region, weights=weight1, data = d)

    summary(out.fit)

    Call:
    lm(formula = AttInd ~ condmean * condstorm + trustmed1 + gwbelief +
        coastdwell + partyID + polor + gender + age + race + educ +
        income + region, data = d, weights = weight1)

    Weighted Residuals:
        Min      1Q  Median      3Q     Max
    -1.1727 -0.1371  0.0130  0.1366  0.8077

    Coefficients:
                               Estimate Std. Error t value Pr(>|t|)
    (Intercept)               0.1940313  0.0370161   5.242 1.89e-07 ***
    condmeannonevhigh        -0.0019461  0.0236085  -0.082  0.93432
    condmeannonevboth         0.0474046  0.0232707   2.037  0.04187 *
    condstormstorm            0.0527524  0.0244159   2.161  0.03094 *
    trustmed1                 0.1833521  0.0180674  10.148  < 2e-16 ***
    gwbeliefnotvref          -0.1093369  0.0985135  -1.110  0.26729
    gwbeliefnotvprobs         0.2074035  0.0193781  10.703  < 2e-16 ***
    coastdwellyes             0.0241253  0.0161011   1.498  0.13432
    partyIDvdem               0.0858665  0.0174835   4.911 1.04e-06 ***
    partyIDvref              -0.2999944  0.0945990  -3.171  0.00156 **
    partyIDvrep              -0.0468268  0.0183366  -2.554  0.01079 *
    polorvref                 0.0560635  0.0718304   0.780  0.43526
    polorvlib                 0.0568556  0.0189179   3.005  0.00271 **
    polorvcons               -0.0293808  0.0169730  -1.731  0.08372 .
    genderMale               -0.0072970  0.0137554  -0.530  0.59588
    agev1824                  0.0162995  0.0259507   0.628  0.53007
    agev2534                 -0.0134314  0.0241301  -0.557  0.57790
    agev3544                  0.0326065  0.0228762   1.425  0.15433
    agev4554                  0.0281826  0.0234333   1.203  0.22935
    agev5564                 -0.0042263  0.0225102  -0.188  0.85111
    racevhisp                 0.0484325  0.0220418   2.197  0.02820 *
    racevblack               -0.0292002  0.0241349  -1.210  0.22658
    racevother                0.0682464  0.0273067   2.499  0.01259 *
    educhsvsome              -0.0130208  0.0175088  -0.744  0.45723
    educhsvcollgrad          -0.0052682  0.0185980  -0.283  0.77703
    educhsvref                0.3522019  0.0887800   3.967 7.73e-05 ***
    incomev3050              -0.0065261  0.0213276  -0.306  0.75967
    incomev5075               0.0200734  0.0216792   0.926  0.35468
    incomev75100             -0.0336651  0.0247648  -1.359  0.17429
    incomev100               -0.0006802  0.0218303  -0.031  0.97515
    regionvmw                 0.0293874  0.0220138   1.335  0.18216
    regionvne                 0.0317515  0.0218553   1.453  0.14655
    regionvs                  0.0085483  0.0186236   0.459  0.64632
    condmeannonevhigh:condstormstorm -0.0068725  0.0342330  -0.201  0.84092

    condmeannonevboth:condstormstorm -0.0860072  0.0334623  -2.570  0.01029
*
    ---
    Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

    Residual standard error: 0.2284 on 1136 degrees of freedom
      (3 observations deleted due to missingness)
    Multiple R-squared:  0.3562, Adjusted R-squared:  0.3369
    F-statistic: 18.49 on 34 and 1136 DF,  p-value: < 2.2e-16

We want to examine mediation in this interaction effect.  We have tried
using the code:

 mediate(med.fit, out.fit,  treat = 'condstorm', control.value = 'nostorm',
treat.value = 'storm', mediator = 'trustmed2',
covariates=list(condmean='both'), boot=TRUE, sims=5000)

Which gave the following output:

    Causal Mediation Analysis

    Confidence Intervals Based on Nonparametric Bootstrap

    (Inference Conditional on the Covariate Values Specified in
`covariates')

    Estimate 95% CI Lower 95% CI Upper p-value

    ACME           -0.017705    -0.036626    -0.003284    0.04
    ADE            -0.014082    -0.045811     0.023155    0.53
    Total Effect   -0.031788    -0.069698     0.012371    0.14
    Prop. Mediated  0.516591     1.174065     8.857665    0.04

    Sample Size Used: 1171

    Simulations: 5000

But this mediation only compares respondents at the level of “both” for the
condmean variable and excludes other conditions, so examines the effect of
"Both Condmean x Condstorm" MINUS the effect "condstorm", which is -.08 -
(.05) = -.03 (the total effect in the output above).

The total effect should instead be the same as the coefficient of
"condmeannonevboth:condstormstorm" in the second interaction term in the
model, which is -.086, p < .01.

Is it possible for us to examine this effect using the ‘mediation’ package
in R?  Any help would be much appreciated!


-------------------------
Lauren C. Howe

PhD Candidate
Stanford University
Department of Psychology
Jordan Hall, Building 420
450 Serra Mall
Stanford, CA 94305

Tel.: +1.434.305.8363
 <Lch4k@virginia.edu>

	[[alternative HTML version deleted]]

