Back to schedule


Within the APIM both the causal variable and the mediator may be several variables and so it can be quite complicated.

Mediator between-dyads or within-dyads (2-1-2 Mediation)

Mediation Diagram 

Mediator mixed variable with actor and partner effects (2-2-2 Mediation)

Example: Acitelli Data

Distinguishable Dyads with a Mixed Mediator

Predictor: Other Positivitity
Mediator: Tension (mixed)
Outcome: Satisfaction

There are four total effects (c) that can be mediated:

  1. Wife Actor Effect from Other Positivity (Wife) to Satisfaction (Wife)
  2. Husband Actor Effect from Other Positivity (Husband) to Satisfaction (Husband)
  3. H to W Partner Effect from Other Positivity (Husband) to Satisfaction (Wife)
  4. W to H Partner Effect from Other Positivity (Wife) to Satisfaction (Husband)

Each of the four total effects had two indirect effects, creating are eight mediated or indirect effects. They each involve a tracing from Other Positivity to Satisfaction via Tension. Each indirect effect involves the product of two effects: a path from Other Positivity to Tension (a path) times a path from Tension to Satisfaction (b path). To differentiate effects, we note whose Satisfaction score we have. So ActorW is the actor effect for the wife and PartnerW is the partner effect for wife where the wife provides the outcome variable.

The four effects to be mediated and their two indirect effects are:

  1. Actor: Wife
  • ActorW-ActorW: Wife
  • PartnerHW-PartnerWH: Wife
  1. Actor: Husband
  • ActorH-ActorH: Husband
  • PartnerWH-PartnerHW: Husband
  1. Partner: Wife
  • ActorH-PartnerHW: Wife
  • PartnerHW-ActorW: Wife
  1. Partner: Husband
  • ActorW-PartnerWH: Husband
  • PartnerWH-ActorH: Husband

For example, “PartnerWH-PartnerHW: Wife” is the path from wife’s perception of positivity to husband’s feeling of tension times the path from husband’s feeling of tension to the wife’s satisfaction.

1. Actor-Actor

Actor-Actor 

2. Partner-Partner

Partner-Partner 

3. Actor-Partner

Actor-Partner 

4. Partner-Actor

Partner-Actor 

Data Example

Read in the individual data (or a pairwise dataset)

library(tidyr)
library(dplyr)
library(nlme)

acitelli_ind <- read.csv(file.choose(), header=TRUE)

Convert individual data to pairwise.

tempA <- acitelli_ind %>% 
  mutate(genderE = gender, partnum = 1) %>%
  mutate(gender = ifelse(gender == 1, "A", "P")) %>%
  gather(variable, value, self_pos:genderE) %>%
  unite(var_gender, variable, gender) %>%
  spread(var_gender, value)

tempB <- acitelli_ind %>% 
  mutate(genderE = gender, partnum = 2) %>%
  mutate(gender = ifelse(gender == 1, "P", "A")) %>%
  gather(variable, value, self_pos:genderE)%>%
  unite(var_gender, variable, gender) %>%
  spread(var_gender, value)

acitelli_pair <- bind_rows(tempA, tempB) %>%
  arrange(cuplid) %>%
  mutate(gender_A = ifelse(genderE_A == 1, "hus", "wife"), 
         gender_A = as.factor(gender_A)) 
  
rm(tempA, tempB)

The Four Baron & Kenny Steps Using Multilevel Modeling

Step 1: Estimating and testing the total effect (c) of Other Positivity (X) on Satisfaction (Y)

apim_stp1 <- gls(satisfaction_A ~ gender_A + other_pos_A:gender_A + other_pos_P:gender_A - 1,
                 data = acitelli_pair,
                 correlation = corCompSymm(form=~1|cuplid), 
                 weights = varIdent(form=~1|genderE_A), 
                 na.action = na.omit)

summary(apim_stp1)
## Generalized least squares fit by REML
##   Model: satisfaction_A ~ gender_A + other_pos_A:gender_A + other_pos_P:gender_A -      1 
##   Data: acitelli_pair 
##        AIC      BIC    logLik
##   318.2216 351.2505 -150.1108
## 
## Correlation Structure: Compound symmetry
##  Formula: ~1 | cuplid 
##  Parameter estimate(s):
##       Rho 
## 0.4751092 
## Variance function:
##  Structure: Different standard deviations per stratum
##  Formula: ~1 | genderE_A 
##  Parameter estimates:
##        1       -1 
## 1.000000 1.203894 
## 
## Coefficients:
##                              Value Std.Error  t-value p-value
## gender_Ahus              0.6904589 0.3429034 2.013567  0.0450
## gender_Awife             0.6112485 0.4128195 1.480668  0.1398
## gender_Ahus:other_pos_A  0.4243866 0.0677157 6.267184  0.0000
## gender_Awife:other_pos_A 0.3777000 0.0739222 5.109428  0.0000
## gender_Ahus:other_pos_P  0.2616498 0.0614025 4.261221  0.0000
## gender_Awife:other_pos_P 0.3214782 0.0815225 3.943427  0.0001
## 
##  Correlation: 
##                          gndr_Ah gndr_Aw gndr_Ah:__A gndr_Aw:__A
## gender_Awife              0.475                                 
## gender_Ahus:other_pos_A  -0.667  -0.317                         
## gender_Awife:other_pos_A -0.267  -0.562  -0.111                 
## gender_Ahus:other_pos_P  -0.562  -0.267  -0.234       0.475     
## gender_Awife:other_pos_P -0.317  -0.667   0.475      -0.234     
##                          gndr_Ah:__P
## gender_Awife                        
## gender_Ahus:other_pos_A             
## gender_Awife:other_pos_A            
## gender_Ahus:other_pos_P             
## gender_Awife:other_pos_P -0.111     
## 
## Standardized residuals:
##        Min         Q1        Med         Q3        Max 
## -4.6821686 -0.4599787  0.1298148  0.6321989  1.9431082 
## 
## Residual standard error: 0.3783372 
## Degrees of freedom: 296 total; 290 residual

Interpretation:

All four paths are positive and statistically significant: Seeing your partner positively leads you and your partner to be more satisfied. All four of these paths could potentially be mediated.

Step 2: Testing the effects of the Other Positivity (X) on the mediators of Wife and Husband Tension (M).

apim_stp2 <- gls(tension_A ~ gender_A + other_pos_A:gender_A + other_pos_P:gender_A - 1,
                 data = acitelli_pair,
                 correlation = corCompSymm(form=~1|cuplid), 
                 weights = varIdent(form=~1|genderE_A), 
                 na.action = na.omit)

summary(apim_stp2)
## Generalized least squares fit by REML
##   Model: tension_A ~ gender_A + other_pos_A:gender_A + other_pos_P:gender_A -      1 
##   Data: acitelli_pair 
##        AIC      BIC    logLik
##   584.5836 617.6125 -283.2918
## 
## Correlation Structure: Compound symmetry
##  Formula: ~1 | cuplid 
##  Parameter estimate(s):
##       Rho 
## 0.2128715 
## Variance function:
##  Structure: Different standard deviations per stratum
##  Formula: ~1 | genderE_A 
##  Parameter estimates:
##       1      -1 
## 1.00000 1.07448 
## 
## Coefficients:
##                              Value Std.Error   t-value p-value
## gender_Ahus               5.271990 0.5452208  9.669459  0.0000
## gender_Awife              5.659212 0.5858291  9.660176  0.0000
## gender_Ahus:other_pos_A  -0.397403 0.1076688 -3.690974  0.0003
## gender_Awife:other_pos_A -0.469411 0.1049024 -4.474745  0.0000
## gender_Ahus:other_pos_P  -0.289561 0.0976308 -2.965878  0.0033
## gender_Awife:other_pos_P -0.267653 0.1156880 -2.313580  0.0214
## 
##  Correlation: 
##                          gndr_Ah gndr_Aw gndr_Ah:__A gndr_Aw:__A
## gender_Awife              0.213                                 
## gender_Ahus:other_pos_A  -0.667  -0.142                         
## gender_Awife:other_pos_A -0.120  -0.562  -0.050                 
## gender_Ahus:other_pos_P  -0.562  -0.120  -0.234       0.213     
## gender_Awife:other_pos_P -0.142  -0.667   0.213      -0.234     
##                          gndr_Ah:__P
## gender_Awife                        
## gender_Ahus:other_pos_A             
## gender_Awife:other_pos_A            
## gender_Ahus:other_pos_P             
## gender_Awife:other_pos_P -0.050     
## 
## Standardized residuals:
##         Min          Q1         Med          Q3         Max 
## -2.53728320 -0.73465986  0.03599313  0.70301005  2.75349391 
## 
## Residual standard error: 0.601561 
## Degrees of freedom: 296 total; 290 residual

Interpretation:

All four paths of the “a” paths are negative and statistically significant: Seeing your partner positively leads you and your partner to have lower levels of tension.

Steps 3 and 4: Testing the effects of the Tension (M) and Other Positivity (X) on the Satisfaction (Y).

apim_stp3 <- gls(satisfaction_A ~ gender_A + other_pos_A:gender_A + other_pos_P:gender_A 
                 + tension_A:gender_A + tension_P:gender_A - 1,
                 data = acitelli_pair,
                 correlation = corCompSymm(form=~1|cuplid), 
                 weights = varIdent(form=~1|genderE_A), 
                 na.action = na.omit)

summary(apim_stp3)
## Generalized least squares fit by REML
##   Model: satisfaction_A ~ gender_A + other_pos_A:gender_A + other_pos_P:gender_A +      tension_A:gender_A + tension_P:gender_A - 1 
##   Data: acitelli_pair 
##       AIC      BIC   logLik
##   269.444 316.9719 -121.722
## 
## Correlation Structure: Compound symmetry
##  Formula: ~1 | cuplid 
##  Parameter estimate(s):
##       Rho 
## 0.3658348 
## Variance function:
##  Structure: Different standard deviations per stratum
##  Formula: ~1 | genderE_A 
##  Parameter estimates:
##       1      -1 
## 1.00000 1.16611 
## 
## Coefficients:
##                               Value Std.Error   t-value p-value
## gender_Ahus               2.7371420 0.4312192  6.347449  0.0000
## gender_Awife              3.0967750 0.5028491  6.158458  0.0000
## gender_Ahus:other_pos_A   0.2905377 0.0624977  4.648772  0.0000
## gender_Awife:other_pos_A  0.1854834 0.0677461  2.737919  0.0066
## gender_Ahus:other_pos_P   0.1288525 0.0580958  2.217931  0.0273
## gender_Awife:other_pos_P  0.1899445 0.0728792  2.606291  0.0096
## gender_Ahus:tension_A    -0.2502362 0.0468100 -5.345783  0.0000
## gender_Awife:tension_A   -0.3512396 0.0508019 -6.913908  0.0000
## gender_Ahus:tension_P    -0.1285409 0.0435653 -2.950538  0.0034
## gender_Awife:tension_P   -0.0944212 0.0545856 -1.729780  0.0847
## 
##  Correlation: 
##                          gndr_Ah gndr_Aw gndr_Ah:__A gndr_Aw:__A
## gender_Awife              0.366                                 
## gender_Ahus:other_pos_A  -0.659  -0.241                         
## gender_Awife:other_pos_A -0.229  -0.626  -0.037                 
## gender_Ahus:other_pos_P  -0.626  -0.229  -0.102       0.366     
## gender_Awife:other_pos_P -0.241  -0.659   0.366      -0.102     
## gender_Ahus:tension_A    -0.451  -0.165   0.258       0.058     
## gender_Awife:tension_A   -0.165  -0.450   0.045       0.302     
## gender_Ahus:tension_P    -0.450  -0.165   0.123       0.111     
## gender_Awife:tension_P   -0.165  -0.451   0.094       0.158     
##                          gndr_Ah:__P gndr_Aw:__P gndr_Ah:_A gndr_Aw:_A
## gender_Awife                                                          
## gender_Ahus:other_pos_A                                               
## gender_Awife:other_pos_A                                              
## gender_Ahus:other_pos_P                                               
## gender_Awife:other_pos_P -0.037                                       
## gender_Ahus:tension_A     0.158       0.094                           
## gender_Awife:tension_A    0.111       0.123      -0.078               
## gender_Ahus:tension_P     0.302       0.045      -0.213      0.366    
## gender_Awife:tension_P    0.058       0.258       0.366     -0.213    
##                          gndr_Ah:_P
## gender_Awife                       
## gender_Ahus:other_pos_A            
## gender_Awife:other_pos_A           
## gender_Ahus:other_pos_P            
## gender_Awife:other_pos_P           
## gender_Ahus:tension_A              
## gender_Awife:tension_A             
## gender_Ahus:tension_P              
## gender_Awife:tension_P   -0.078    
## 
## Standardized residuals:
##         Min          Q1         Med          Q3         Max 
## -4.86728877 -0.58600349  0.09090316  0.62619627  2.27779033 
## 
## Residual standard error: 0.3313086 
## Degrees of freedom: 296 total; 286 residual

Interpretation:

Step 3: All four “b” paths from Tension to Satisfaction are negative and three are statistically significant: Seeing more tension in the relationship leads to less satisfaction for you and your partner, even after controlling for how positively you and your partner see each other. The one effect that is not statistically significant is the effect of male’s level of tension on his wife’s level of satisfaction.
Step 4: All paths from Other Positivity to Satisfaction, the direct of c’, are positive and statistically significant: Seeing your partner positively leads you and your partner to have higher levels of satisfaction, even after controlling for yours and your partner’s tension.

 

(Figure drawn in Amos. You might want to drop curved lines and error terms.)

Testing Indirect Effects Using Multilevel Modeling

Sobel Test

sobel <- function(aval, bval, seA, seB){
  
  ab <- aval*bval
  ab_se <- sqrt(aval^2*seB^2+bval^2*seA^2)
  z <- ab/ab_se
  p <- 2*pnorm(z, lower.tail=FALSE)
  
  return(data.frame(indirect_effect = ab, z_value = z, p_value = p))
   
}
act_H_a <- coef(summary(apim_stp2))[3,1]
act_H_a_se <- coef(summary(apim_stp2))[3,2]
act_H_b <- coef(summary(apim_stp3))[7,1]
act_H_b_se <- coef(summary(apim_stp3))[7,2]

sobel(act_H_a, act_H_b, act_H_a_se, act_H_b_se)
##   indirect_effect  z_value     p_value
## 1      0.09944454 3.037334 0.002386809

Bootstrapping

Here is an example bootstrap function, but it is not general at all. It is also very slow, but it gives you an idea.

bootstrapCI <- function(data, m){

  N <- dim(data)[1]
  ab <- rep(0, m)
  conf <- 95

  for(i in 1:m){
    samp_new <- sample_n(data, N, replace = TRUE)
  
    apim_stp2_new <- gls(tension_A ~ gender_A + other_pos_A:gender_A + other_pos_P:gender_A - 1,
                   data = samp_new,
                   correlation = corCompSymm(form=~1|cuplid), 
                    weights = varIdent(form=~1|genderE_A), 
                    na.action = na.omit)
  
    apim_stp3_new <- gls(satisfaction_A ~ gender_A + other_pos_A:gender_A + other_pos_P:gender_A 
                  + tension_A:gender_A + tension_P:gender_A - 1,
                   data = samp_new,
                   correlation = corCompSymm(form=~1|cuplid), 
                  weights = varIdent(form=~1|genderE_A), 
                   na.action = na.omit)
  
    a <- coef(summary(apim_stp2_new))[3,1]
    b <- coef(summary(apim_stp3_new))[7,1]
    
    ab[i] <- a*b
  }
  
  low <- (1-conf/100)/2
  upp <- ((1-conf/100)/2) + (conf/100)

  LL <- quantile(ab,low)
  UL <- quantile(ab,upp)
  LL <- format(LL,digits=3)
  UL <- format(UL,digits=3)
  
  return(data.frame(Lower = LL, Upper = UL))
}

bootstrapCI(acitelli_pair, 2000)
##      Lower Upper
## 2.5% 0.041 0.168

MCMAM Selig & Preacher, 2008

#Function that returns mcmc CI. 
mcmamCI <- function(aval, bval, varA, varB, n){

#code (Selig & Preacher, 2008).
  require(MASS)
  
  a=aval
  b=bval
  rep=n
  conf=95
  pest=c(a,b)
  acov <- matrix(c(varA, 0, 0, varB),2,2)

  mcmc <- mvrnorm(rep,pest,acov,empirical=FALSE)

  ab <- mcmc[,1]*mcmc[,2]

  low=(1-conf/100)/2
  upp=((1-conf/100)/2)+(conf/100)

  LL=quantile(ab,low)
  UL=quantile(ab,upp)
  LL=format(LL,digits=3)
  UL=format(UL,digits=3)

  CI <- cbind.data.frame(LL, UL)
  return(CI)

}

For example, we can find the MCMC 95% CI for the Actor-Actor: Husband indirect effect like this.

act_H_a <- coef(summary(apim_stp2))[3,1]
act_H_a_se <- coef(summary(apim_stp2))[3,2]
act_H_b <- coef(summary(apim_stp3))[7,1]
act_H_b_se <- coef(summary(apim_stp3))[7,2]

mcmamCI(act_H_a, act_H_b, act_H_a_se^2, act_H_b_se^2, 3000)
##          LL    UL
## 2.5% 0.0415 0.167

Summary of Indirect Effects

Name Indirect Effects Estim. p 95% CIa Lower Upper
Actor-Actor: W Xw -> Mw -> Yw 0.165 <.001 0.086 0.257
Actor-Actor: H Xh -> Mh -> Yh 0.099 <.001 0.042 0.172
Partner-Partner: W Xw -> Mh -> Yw 0.027 .090 -0.003 0.070
Partner-Partner: H Xh -> Mw -> Yh 0.034 .024 0.003 0.079
Actor-Partner: W Xh -> Mh -> Yw 0.038 .086 -0.005 0.092
Actor-Partner: H Xw -> Mw -> Yh 0.060 .004 0.017 0.115
Partner-Actor: W Xh -> Mw -> Yw 0.094 .023 0.013 0.186
Partner-Actor: H Xw -> Mh -> Yh 0.072 .003 0.023 0.134

aBootstrapped CI using MCM (The above table was produced by an Excel spreadsheet: IndirectEffects.xls.)

Summary Direct and Total Effects

Name Direct Effects Direct p Totala % Mediated
Actor: Wife Xw -> Yw 0.185 .007 0.378 50.9
Actor: Husband Xh -> Yh 0.291 <.001 0.424 31.5
Partner: Wife Xh -> Yw 0.190 .010 0.321 40.9
Partner: Husband Xw -> Yh 0.129 .028 0.262 50.8

aComputed as ab + c' and c with results agreeing.

Note that % Mediated equals ab/c or equivalently 1 - c'/c. This value can be larger than one or negative. First, make sure that c is substantial. If it is, then if % Mediated is greater than 100 or negative, you have “inconsistent mediation”: the direct and indirect effects are of opposite signs.

Interpretation:

Actor-Actor: Wife —Wives who see their husbands positively report less tension and are more satisfied.
Actor-Actor: Husband —Husbands who see their wives positively report less tension and are more satisfied.
Partner-Partner: Wife —Wives who see their husbands positively have husbands who report less tension and the wives are more satisfied.
Partner-Partner: Husband —Husbands who see their wives positively have wives who report less tension and the husbands are more satisfied.
Actor-Partner: Wife —Husbands who see their wives positively report less tension and have wives who are more satisfied.
Actor-Partner: Husband —Wives who see their husband positively report less tension and have husbands who are more satisfied.
Partner-Actor: Wife —Husbands who see their wives positively have wives who report less tension and the wives are more satisfied.
Partner-Actor: Husband —Wives who see their husbands positively have husbands who report less tension and the husbands are more satisfied.


Back to schedule