mediation pacakge
The framing data
contains 265 rows and 15 columns of
data from a framing experiment conducted by Brader, Valentino and Suhay
(2008).
Brader et al. (2008) conducted a randomized experiment where subjects are exposed to different media stories about immigration and the authors investigated how their framing influences attitudes and political behavior regarding immigration policy. They posit anxiety as the mediating variable for the causal effect of framing on public opinion. We first fit the mediator model where the measure of anxiety (emo) is modeled as a function of the framing treatment (treat) and pre-treatment covariates (age, educ, gender, and income). Next, we model the outcome variable, which is a binary variable indicating whether or not the participant agreed to send a letter about immigration policy to his or her member of Congress (cong_mesg). The explanatory variables of the outcome model include the mediator, treatment status, and the same set of pre-treatment variables as those used in the mediator model.1 In this example, the treatment is expected to increase the level of respondents’ emotional response, which in turn is hypothesized to make subjects more likely to send a letter to his or her member of Congress. We use the linear regression fit with least squares and the probit regression for the mediator and outcome models, respectively.
https://www.jstor.org/stable/25193860
Abstract: We examine whether and how elite discourse shapes mass opinion and action on immigration policy. One popular but untested suspicion is that reactions to news about the costs of immigration depend upon who the immigrants are. We confirm this suspicion in a nationally representative experiment: news about the costs of immigration boosts white opposition far more when Latino immigrants, rather than European immigrants, are featured. We find these group cues influence opinion and political action by triggering emotions-in particular, anxiety-not simply by changing beliefs about the severity of the immigration problem. A second experiment replicates these findings but also confirms their sensitivity to the stereotypic consistency of group cues and their context. While these results echo recent insights about the power of anxiety, they also suggest the public is susceptible to error and manipulation when group cues trigger anxiety independently of the actual threat posed by the group.
A data frame containing the following variables:
immigr: A four-point scale measuring subjects’ attitudes toward increased immigration. Larger values indicate more negative attitudes.
english: A four-point scale indicating whether subjects favor or oppose a law making English the official language of the U.S.
cong_mesg: Whether subjects requested sending an anti-immigration message to Congress on their behalf.
anti_info: Whether subjects wanted to receive information from anti-immigration organizations.
tone: 1st treatment; whether the news story is framed positively or negatively.
eth: 2nd treatment; whether the news story features a Latino or European immigrant.
cond: Four level measure recording joint treatment status of tone and eth.
treat: Product of the two treatment variables. In the original study the authors only find this cell to be significant.
emo: Measure of subjects’ negative feeling during the experiment. A numeric scale ranging between 3 and 12 where 3 indicates the most negative feeling.
anx: A four-point scale measuring subjects’ anxiety about increased immigration.
p_harm: Subjects’ perceived harm caused by increased immigration. A numeric scale between 2 and 8.
age: Subjects’ age.
educ: Subjects’ highest educational attainments.
gender: Subjects’ gender.
income: Subjects’ income, measured as a 19-point scale.
install.packages("mediation")
##
## The downloaded binary packages are in
## /var/folders/qj/y615pkf53ms_hcxg1f9zjkyc0000gp/T//Rtmp1q72Z3/downloaded_packages
library(mediation)
mediation_data <- mediation::framing
?mediation::framing
head(mediation_data)
## cond anx age educ gender income emo
## 1 3 a little anxious 45 high school male 13 7
## 2 4 somewhat anxious 73 bachelor's degree or higher male 16 6
## 3 2 a little anxious 53 some college female 3 8
## 4 1 not anxious at all 45 high school male 14 9
## 5 3 somewhat anxious 55 some college female 12 5
## 6 1 a little anxious 85 high school female 3 5
## p_harm tone eth treat english immigr anti_info cong_mesg
## 1 6 0 1 0 Oppose 4 0 1
## 2 3 0 0 0 Favor 3 0 0
## 3 7 1 0 0 Strongly Oppose 3 0 0
## 4 8 1 1 1 Strongly Oppose 4 0 1
## 5 5 0 1 0 Strongly Oppose 2 0 0
## 6 6 1 1 1 Strongly Oppose 4 0 0
Is there a mediation effect by emo
(Negative feelings)
on cong_mesg
(Whether subjects requested sending an
anti-immigration message to Congress on their behalf).
med.fit <- lm(emo ~ treat * age + educ + gender + income, data=mediation_data)
med.fit %>% summary
##
## Call:
## lm(formula = emo ~ treat * age + educ + gender + income, data = mediation_data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -4.9074 -1.9722 -0.3288 1.7066 6.6430
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 8.521729 0.930899 9.154 < 2e-16 ***
## treat 1.894624 1.114441 1.700 0.09033 .
## age 0.005333 0.011776 0.453 0.65101
## educhigh school -1.009447 0.637269 -1.584 0.11442
## educsome college -1.801668 0.665487 -2.707 0.00724 **
## educbachelor's degree or higher -3.055484 0.660879 -4.623 5.99e-06 ***
## genderfemale 0.053972 0.316104 0.171 0.86456
## income -0.036319 0.041746 -0.870 0.38512
## treat:age -0.011781 0.022345 -0.527 0.59849
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.535 on 256 degrees of freedom
## Multiple R-squared: 0.1905, Adjusted R-squared: 0.1652
## F-statistic: 7.53 on 8 and 256 DF, p-value: 5.001e-09
out.fit <- glm(cong_mesg ~ emo + treat * age + emo * age + educ + gender + income, data = mediation_data, family = binomial("probit"))
out.fit %>% summary
##
## Call:
## glm(formula = cong_mesg ~ emo + treat * age + emo * age + educ +
## gender + income, family = binomial("probit"), data = mediation_data)
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -2.539202 0.942226 -2.695 0.00704 **
## emo 0.142086 0.111391 1.276 0.20211
## treat 1.347748 0.642344 2.098 0.03589 *
## age 0.002714 0.017513 0.155 0.87683
## educhigh school -0.093956 0.348381 -0.270 0.78740
## educsome college -0.548628 0.374839 -1.464 0.14329
## educbachelor's degree or higher -0.350697 0.379594 -0.924 0.35555
## genderfemale -0.437244 0.178697 -2.447 0.01441 *
## income 0.084713 0.025795 3.284 0.00102 **
## treat:age -0.027831 0.013051 -2.133 0.03296 *
## emo:age 0.001394 0.002293 0.608 0.54329
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 336.89 on 264 degrees of freedom
## Residual deviance: 274.74 on 254 degrees of freedom
## AIC: 296.74
##
## Number of Fisher Scoring iterations: 5
med.out <- mediate(med.fit, out.fit, treat = "treat", mediator = "emo",
robustSE = TRUE, sims = 100)
summary(med.out)
##
## Causal Mediation Analysis
##
## Quasi-Bayesian Confidence Intervals
##
## Estimate 95% CI Lower 95% CI Upper p-value
## ACME (control) 0.0760 0.0364 0.13 <2e-16 ***
## ACME (treated) 0.0760 0.0387 0.13 <2e-16 ***
## ADE (control) 0.0117 -0.0917 0.12 0.80
## ADE (treated) 0.0117 -0.1019 0.13 0.80
## Total Effect 0.0877 -0.0255 0.22 0.16
## Prop. Mediated (control) 0.7684 -6.0076 5.81 0.16
## Prop. Mediated (treated) 0.7503 -5.6165 5.21 0.16
## ACME (average) 0.0760 0.0376 0.13 <2e-16 ***
## ADE (average) 0.0117 -0.0968 0.13 0.80
## Prop. Mediated (average) 0.7594 -5.8121 5.51 0.16
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Sample Size Used: 265
##
##
## Simulations: 100
Where ACME: The average causal mediation effects ADE: The average direct effects
The results suggest that the treatment in the framing experiment may have increased emotional response, which in turn made subjects more likely to send a message to his or her member of Congress. Here, since the outcome is binary all estimated effects are expressed as the increase in probability that the subject sent a message to his or her Congress person.
Mediation analysis with SBP dataset
Before begin..
Let’s load the SBP dataset.
dataset_sbp <- vroom::vroom(file = "/Users/minsikkim/Dropbox (Personal)/Inha/5_Lectures/Advanced biostatistics/scripts/BTE3207_Advanced_Biostatistics/dataset/sbp_dataset_korea_2013-2014.csv")
#vroom does the same thing as read.csv but much faster
head(dataset_sbp)
## # A tibble: 6 × 7
## SEX BTH_G SBP DBP FBS DIS BMI
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 1 1 116 78 94 4 16.6
## 2 1 1 100 60 79 4 22.3
## 3 1 1 100 60 87 4 21.9
## 4 1 1 111 70 72 4 20.2
## 5 1 1 120 80 98 4 20
## 6 1 1 115 79 95 4 23.1
Making a new variable hypertension
dataset_sbp$hypertension <- ifelse(dataset_sbp$SBP > 130 |
dataset_sbp$DBP > 80,
T,
F)
dataset_sbp$history_diabete <- ifelse(dataset_sbp$DIS == 1 |
dataset_sbp$DIS == 3,
T,
F)
Step 1.
lm(SBP ~ BMI + hypertension + DBP + SEX, data = dataset_sbp) %>%
summary
##
## Call:
## lm(formula = SBP ~ BMI + hypertension + DBP + SEX, data = dataset_sbp)
##
## Residuals:
## Min 1Q Median 3Q Max
## -43.581 -5.232 -0.513 6.051 79.546
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 56.288872 0.110804 508.00 <2e-16 ***
## BMI 0.397784 0.002807 141.71 <2e-16 ***
## hypertensionTRUE 11.196886 0.025492 439.24 <2e-16 ***
## DBP 0.706405 0.001239 570.32 <2e-16 ***
## SEX -0.651193 0.018107 -35.96 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 8.813 on 999995 degrees of freedom
## Multiple R-squared: 0.6337, Adjusted R-squared: 0.6337
## F-statistic: 4.325e+05 on 4 and 999995 DF, p-value: < 2.2e-16
Step 2
lm(history_diabete ~ BMI + hypertension + DBP + SEX, data = dataset_sbp) %>%
summary
##
## Call:
## lm(formula = history_diabete ~ BMI + hypertension + DBP + SEX,
## data = dataset_sbp)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.27124 -0.11436 -0.08629 -0.06181 0.99868
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -5.366e-02 3.686e-03 -14.558 <2e-16 ***
## BMI 8.526e-03 9.339e-05 91.299 <2e-16 ***
## hypertensionTRUE 4.768e-02 8.481e-04 56.219 <2e-16 ***
## DBP -9.095e-04 4.121e-05 -22.072 <2e-16 ***
## SEX 7.004e-04 6.024e-04 1.163 0.245
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.2932 on 999995 degrees of freedom
## Multiple R-squared: 0.01415, Adjusted R-squared: 0.01414
## F-statistic: 3588 on 4 and 999995 DF, p-value: < 2.2e-16
Step 3
lm(SBP ~ BMI + history_diabete + hypertension + DBP + SEX, data = dataset_sbp) %>%
summary
##
## Call:
## lm(formula = SBP ~ BMI + history_diabete + hypertension + DBP +
## SEX, data = dataset_sbp)
##
## Residuals:
## Min 1Q Median 3Q Max
## -45.394 -5.218 -0.445 5.968 79.998
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 56.459925 0.110191 512.38 <2e-16 ***
## BMI 0.370607 0.002803 132.22 <2e-16 ***
## history_diabeteTRUE 3.187484 0.029889 106.64 <2e-16 ***
## hypertensionTRUE 11.044914 0.025388 435.04 <2e-16 ***
## DBP 0.709304 0.001232 575.77 <2e-16 ***
## SEX -0.653425 0.018005 -36.29 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 8.763 on 999994 degrees of freedom
## Multiple R-squared: 0.6378, Adjusted R-squared: 0.6378
## F-statistic: 3.522e+05 on 5 and 999994 DF, p-value: < 2.2e-16
Mediation fit, adjusted by status of hypertension
med.fit <- lm(history_diabete ~ BMI + hypertension + DBP + SEX, data = dataset_sbp)
Outcome fit, adjusted by status of hypertension
out.fit <- lm(SBP ~ BMI + history_diabete + hypertension + DBP + SEX, data = dataset_sbp)
Mediation analysis, adjusted for hypertension status (for each group with hypertension and without hypertension)
med.out <- mediate(med.fit, out.fit, treat = "hypertension", mediator = "history_diabete",
robustSE = TRUE, sims = 100)
med.out
## $d0
## [1] 0.1519792
##
## $d1
## [1] 0.1519792
##
## $d0.ci
## 2.5% 97.5%
## 0.1456425 0.1574157
##
## $d1.ci
## 2.5% 97.5%
## 0.1456425 0.1574157
##
## $d0.p
## [1] 0
##
## $d1.p
## [1] 0
##
## $d0.sims
## [,1] [,2] [,3] [,4] [,5] [,6] [,7]
## [1,] 0.1492427 0.1495158 0.1429838 0.1587612 0.151879 0.1509514 0.149975
## [,8] [,9] [,10] [,11] [,12] [,13] [,14]
## [1,] 0.1547097 0.155521 0.1546355 0.1535884 0.1438717 0.1499364 0.1524378
## [,15] [,16] [,17] [,18] [,19] [,20] [,21]
## [1,] 0.1485138 0.1551818 0.1525655 0.1550163 0.1526774 0.1521057 0.1515608
## [,22] [,23] [,24] [,25] [,26] [,27] [,28]
## [1,] 0.1524267 0.1559051 0.1500456 0.1541712 0.1540395 0.1534648 0.1527811
## [,29] [,30] [,31] [,32] [,33] [,34] [,35]
## [1,] 0.1485136 0.1547741 0.1521751 0.1528793 0.1569677 0.1539717 0.1480667
## [,36] [,37] [,38] [,39] [,40] [,41] [,42]
## [1,] 0.1492946 0.1513802 0.1532115 0.1545958 0.1460112 0.1526245 0.1556408
## [,43] [,44] [,45] [,46] [,47] [,48] [,49]
## [1,] 0.154903 0.1487474 0.1460328 0.1511042 0.149078 0.14924 0.1564456
## [,50] [,51] [,52] [,53] [,54] [,55] [,56]
## [1,] 0.1525593 0.1497311 0.1539671 0.1523164 0.1536853 0.1469819 0.1515726
## [,57] [,58] [,59] [,60] [,61] [,62] [,63]
## [1,] 0.1515456 0.1558625 0.1591451 0.1463466 0.1509702 0.1477079 0.148001
## [,64] [,65] [,66] [,67] [,68] [,69] [,70]
## [1,] 0.15385 0.1498622 0.1515471 0.1506911 0.1517766 0.1554256 0.1502839
## [,71] [,72] [,73] [,74] [,75] [,76] [,77]
## [1,] 0.145309 0.1551414 0.1514355 0.154452 0.1505923 0.1545065 0.1507176
## [,78] [,79] [,80] [,81] [,82] [,83] [,84]
## [1,] 0.1547162 0.1535516 0.1482686 0.1535817 0.1517571 0.1497825 0.1495267
## [,85] [,86] [,87] [,88] [,89] [,90] [,91]
## [1,] 0.1575879 0.1486527 0.155646 0.1572045 0.1558254 0.1473367 0.1570618
## [,92] [,93] [,94] [,95] [,96] [,97] [,98]
## [1,] 0.1482097 0.1515786 0.1517147 0.1470801 0.1536504 0.1560986 0.1462542
## [,99] [,100]
## [1,] 0.1572255 0.1555028
##
## $d1.sims
## [,1] [,2] [,3] [,4] [,5] [,6] [,7]
## [1,] 0.1492427 0.1495158 0.1429838 0.1587612 0.151879 0.1509514 0.149975
## [,8] [,9] [,10] [,11] [,12] [,13] [,14]
## [1,] 0.1547097 0.155521 0.1546355 0.1535884 0.1438717 0.1499364 0.1524378
## [,15] [,16] [,17] [,18] [,19] [,20] [,21]
## [1,] 0.1485138 0.1551818 0.1525655 0.1550163 0.1526774 0.1521057 0.1515608
## [,22] [,23] [,24] [,25] [,26] [,27] [,28]
## [1,] 0.1524267 0.1559051 0.1500456 0.1541712 0.1540395 0.1534648 0.1527811
## [,29] [,30] [,31] [,32] [,33] [,34] [,35]
## [1,] 0.1485136 0.1547741 0.1521751 0.1528793 0.1569677 0.1539717 0.1480667
## [,36] [,37] [,38] [,39] [,40] [,41] [,42]
## [1,] 0.1492946 0.1513802 0.1532115 0.1545958 0.1460112 0.1526245 0.1556408
## [,43] [,44] [,45] [,46] [,47] [,48] [,49]
## [1,] 0.154903 0.1487474 0.1460328 0.1511042 0.149078 0.14924 0.1564456
## [,50] [,51] [,52] [,53] [,54] [,55] [,56]
## [1,] 0.1525593 0.1497311 0.1539671 0.1523164 0.1536853 0.1469819 0.1515726
## [,57] [,58] [,59] [,60] [,61] [,62] [,63]
## [1,] 0.1515456 0.1558625 0.1591451 0.1463466 0.1509702 0.1477079 0.148001
## [,64] [,65] [,66] [,67] [,68] [,69] [,70]
## [1,] 0.15385 0.1498622 0.1515471 0.1506911 0.1517766 0.1554256 0.1502839
## [,71] [,72] [,73] [,74] [,75] [,76] [,77]
## [1,] 0.145309 0.1551414 0.1514355 0.154452 0.1505923 0.1545065 0.1507176
## [,78] [,79] [,80] [,81] [,82] [,83] [,84]
## [1,] 0.1547162 0.1535516 0.1482686 0.1535817 0.1517571 0.1497825 0.1495267
## [,85] [,86] [,87] [,88] [,89] [,90] [,91]
## [1,] 0.1575879 0.1486527 0.155646 0.1572045 0.1558254 0.1473367 0.1570618
## [,92] [,93] [,94] [,95] [,96] [,97] [,98]
## [1,] 0.1482097 0.1515786 0.1517147 0.1470801 0.1536504 0.1560986 0.1462542
## [,99] [,100]
## [1,] 0.1572255 0.1555028
##
## $z0
## [1] 11.04954
##
## $z1
## [1] 11.04954
##
## $z0.ci
## 2.5% 97.5%
## 10.99495 11.10281
##
## $z1.ci
## 2.5% 97.5%
## 10.99495 11.10281
##
## $z0.p
## [1] 0
##
## $z1.p
## [1] 0
##
## $z0.sims
## [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
## [1,] 11.07653 11.00234 11.04517 11.04865 11.05008 11.09232 10.96967 11.07239
## [,9] [,10] [,11] [,12] [,13] [,14] [,15] [,16]
## [1,] 11.03001 11.10959 11.04402 10.99299 11.03328 10.9734 11.04238 11.02791
## [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24]
## [1,] 11.04464 11.05243 11.05256 11.0789 11.04856 11.03042 11.04034 11.07771
## [,25] [,26] [,27] [,28] [,29] [,30] [,31] [,32]
## [1,] 11.04448 11.06506 11.02427 11.06787 11.02587 11.06495 10.99712 11.03802
## [,33] [,34] [,35] [,36] [,37] [,38] [,39] [,40]
## [1,] 11.0452 11.05061 11.06934 11.04726 11.02847 11.05969 11.01997 11.05183
## [,41] [,42] [,43] [,44] [,45] [,46] [,47] [,48]
## [1,] 11.05218 11.05662 11.06771 11.04999 11.03499 11.04819 11.01082 11.01881
## [,49] [,50] [,51] [,52] [,53] [,54] [,55] [,56]
## [1,] 11.05658 11.01162 11.04554 11.07086 11.04087 11.07593 11.09531 11.05763
## [,57] [,58] [,59] [,60] [,61] [,62] [,63] [,64]
## [1,] 11.08918 11.05057 11.05279 11.02201 11.04547 11.0367 11.08307 11.02465
## [,65] [,66] [,67] [,68] [,69] [,70] [,71] [,72]
## [1,] 11.07046 11.02794 11.06175 11.0683 11.05652 11.04716 11.11425 11.03864
## [,73] [,74] [,75] [,76] [,77] [,78] [,79] [,80]
## [1,] 11.03985 11.05514 11.07029 11.05346 11.05065 11.05789 11.0489 11.13408
## [,81] [,82] [,83] [,84] [,85] [,86] [,87] [,88]
## [1,] 11.02593 11.05925 11.04217 11.06647 11.00269 11.04651 11.02655 11.07368
## [,89] [,90] [,91] [,92] [,93] [,94] [,95] [,96]
## [1,] 11.05435 11.05536 11.05683 11.0449 11.0636 11.04469 11.06082 11.05478
## [,97] [,98] [,99] [,100]
## [1,] 11.07583 11.0835 11.0776 11.00844
##
## $z1.sims
## [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
## [1,] 11.07653 11.00234 11.04517 11.04865 11.05008 11.09232 10.96967 11.07239
## [,9] [,10] [,11] [,12] [,13] [,14] [,15] [,16]
## [1,] 11.03001 11.10959 11.04402 10.99299 11.03328 10.9734 11.04238 11.02791
## [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24]
## [1,] 11.04464 11.05243 11.05256 11.0789 11.04856 11.03042 11.04034 11.07771
## [,25] [,26] [,27] [,28] [,29] [,30] [,31] [,32]
## [1,] 11.04448 11.06506 11.02427 11.06787 11.02587 11.06495 10.99712 11.03802
## [,33] [,34] [,35] [,36] [,37] [,38] [,39] [,40]
## [1,] 11.0452 11.05061 11.06934 11.04726 11.02847 11.05969 11.01997 11.05183
## [,41] [,42] [,43] [,44] [,45] [,46] [,47] [,48]
## [1,] 11.05218 11.05662 11.06771 11.04999 11.03499 11.04819 11.01082 11.01881
## [,49] [,50] [,51] [,52] [,53] [,54] [,55] [,56]
## [1,] 11.05658 11.01162 11.04554 11.07086 11.04087 11.07593 11.09531 11.05763
## [,57] [,58] [,59] [,60] [,61] [,62] [,63] [,64]
## [1,] 11.08918 11.05057 11.05279 11.02201 11.04547 11.0367 11.08307 11.02465
## [,65] [,66] [,67] [,68] [,69] [,70] [,71] [,72]
## [1,] 11.07046 11.02794 11.06175 11.0683 11.05652 11.04716 11.11425 11.03864
## [,73] [,74] [,75] [,76] [,77] [,78] [,79] [,80]
## [1,] 11.03985 11.05514 11.07029 11.05346 11.05065 11.05789 11.0489 11.13408
## [,81] [,82] [,83] [,84] [,85] [,86] [,87] [,88]
## [1,] 11.02593 11.05925 11.04217 11.06647 11.00269 11.04651 11.02655 11.07368
## [,89] [,90] [,91] [,92] [,93] [,94] [,95] [,96]
## [1,] 11.05435 11.05536 11.05683 11.0449 11.0636 11.04469 11.06082 11.05478
## [,97] [,98] [,99] [,100]
## [1,] 11.07583 11.0835 11.0776 11.00844
##
## $n0
## [1] 0.0135831
##
## $n1
## [1] 0.0135831
##
## $n0.ci
## 2.5% 97.5%
## 0.01296853 0.01406905
##
## $n1.ci
## 2.5% 97.5%
## 0.01296853 0.01406905
##
## $n0.p
## [1] 0
##
## $n1.p
## [1] 0
##
## $n0.sims
## [,1] [,2] [,3] [,4] [,5] [,6]
## [1,] 0.01329465 0.01340726 0.01277993 0.01416573 0.01355825 0.01342594
## [,7] [,8] [,9] [,10] [,11] [,12]
## [1,] 0.01348739 0.01378003 0.01390376 0.01372802 0.01371618 0.01291851
## [,13] [,14] [,15] [,16] [,17] [,18]
## [1,] 0.01340727 0.01370125 0.01327095 0.01387647 0.01362533 0.01383154
## [,19] [,20] [,21] [,22] [,23] [,24]
## [1,] 0.01362554 0.01354338 0.01353207 0.01363041 0.01392476 0.01336382
## [,25] [,26] [,27] [,28] [,29] [,30]
## [1,] 0.01376694 0.01373011 0.01372951 0.01361606 0.01329054 0.01379482
## [,31] [,32] [,33] [,34] [,35] [,36]
## [1,] 0.01364886 0.01366104 0.01401226 0.01374184 0.01319972 0.01333398
## [,37] [,38] [,39] [,40] [,41] [,42]
## [1,] 0.01354045 0.01366386 0.01383462 0.01303922 0.01362135 0.0138813
## [,43] [,44] [,45] [,46] [,47] [,48]
## [1,] 0.01380276 0.01328251 0.01306078 0.0134923 0.01335837 0.01336312
## [,49] [,50] [,51] [,52] [,53] [,54]
## [1,] 0.01395213 0.01366507 0.0133745 0.01371665 0.01360796 0.01368572
## [,55] [,56] [,57] [,58] [,59] [,60]
## [1,] 0.01307401 0.01352216 0.01348184 0.01390831 0.01419426 0.01310368
## [,61] [,62] [,63] [,64] [,65] [,66]
## [1,] 0.01348378 0.01320658 0.01317782 0.01376302 0.01335631 0.01355582
## [,67] [,68] [,69] [,70] [,71] [,72]
## [1,] 0.01343963 0.01352723 0.0138625 0.01342127 0.01290539 0.01385961
## [,73] [,74] [,75] [,76] [,77] [,78]
## [1,] 0.01353156 0.01377855 0.01342072 0.01378541 0.01345529 0.01379841
## [,79] [,80] [,81] [,82] [,83] [,84]
## [1,] 0.01370697 0.01314163 0.01373779 0.01353643 0.01338306 0.01333156
## [,85] [,86] [,87] [,88] [,89] [,90] [,91]
## [1,] 0.01412042 0.01327829 0.01391909 0.01399752 0.01390035 0.01315189 0.014006
## [,92] [,93] [,94] [,95] [,96] [,97]
## [1,] 0.01324115 0.01351548 0.01355031 0.01312289 0.01370847 0.01389776
## [,98] [,99] [,100]
## [1,] 0.01302381 0.01399448 0.01392902
##
## $n1.sims
## [,1] [,2] [,3] [,4] [,5] [,6]
## [1,] 0.01329465 0.01340726 0.01277993 0.01416573 0.01355825 0.01342594
## [,7] [,8] [,9] [,10] [,11] [,12]
## [1,] 0.01348739 0.01378003 0.01390376 0.01372802 0.01371618 0.01291851
## [,13] [,14] [,15] [,16] [,17] [,18]
## [1,] 0.01340727 0.01370125 0.01327095 0.01387647 0.01362533 0.01383154
## [,19] [,20] [,21] [,22] [,23] [,24]
## [1,] 0.01362554 0.01354338 0.01353207 0.01363041 0.01392476 0.01336382
## [,25] [,26] [,27] [,28] [,29] [,30]
## [1,] 0.01376694 0.01373011 0.01372951 0.01361606 0.01329054 0.01379482
## [,31] [,32] [,33] [,34] [,35] [,36]
## [1,] 0.01364886 0.01366104 0.01401226 0.01374184 0.01319972 0.01333398
## [,37] [,38] [,39] [,40] [,41] [,42]
## [1,] 0.01354045 0.01366386 0.01383462 0.01303922 0.01362135 0.0138813
## [,43] [,44] [,45] [,46] [,47] [,48]
## [1,] 0.01380276 0.01328251 0.01306078 0.0134923 0.01335837 0.01336312
## [,49] [,50] [,51] [,52] [,53] [,54]
## [1,] 0.01395213 0.01366507 0.0133745 0.01371665 0.01360796 0.01368572
## [,55] [,56] [,57] [,58] [,59] [,60]
## [1,] 0.01307401 0.01352216 0.01348184 0.01390831 0.01419426 0.01310368
## [,61] [,62] [,63] [,64] [,65] [,66]
## [1,] 0.01348378 0.01320658 0.01317782 0.01376302 0.01335631 0.01355582
## [,67] [,68] [,69] [,70] [,71] [,72]
## [1,] 0.01343963 0.01352723 0.0138625 0.01342127 0.01290539 0.01385961
## [,73] [,74] [,75] [,76] [,77] [,78]
## [1,] 0.01353156 0.01377855 0.01342072 0.01378541 0.01345529 0.01379841
## [,79] [,80] [,81] [,82] [,83] [,84]
## [1,] 0.01370697 0.01314163 0.01373779 0.01353643 0.01338306 0.01333156
## [,85] [,86] [,87] [,88] [,89] [,90] [,91]
## [1,] 0.01412042 0.01327829 0.01391909 0.01399752 0.01390035 0.01315189 0.014006
## [,92] [,93] [,94] [,95] [,96] [,97]
## [1,] 0.01324115 0.01351548 0.01355031 0.01312289 0.01370847 0.01389776
## [,98] [,99] [,100]
## [1,] 0.01302381 0.01399448 0.01392902
##
## $tau.coef
## [1] 11.20152
##
## $tau.ci
## 2.5% 97.5%
## 11.14277 11.25182
##
## $tau.p
## [1] 0
##
## $tau.sims
## [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
## [1,] 11.22577 11.15185 11.18815 11.20742 11.20196 11.24327 11.11965 11.2271
## [,9] [,10] [,11] [,12] [,13] [,14] [,15] [,16]
## [1,] 11.18553 11.26422 11.19761 11.13686 11.18322 11.12583 11.1909 11.18309
## [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24]
## [1,] 11.1972 11.20745 11.20524 11.231 11.20012 11.18285 11.19625 11.22775
## [,25] [,26] [,27] [,28] [,29] [,30] [,31] [,32]
## [1,] 11.19865 11.2191 11.17774 11.22065 11.17439 11.21972 11.14929 11.1909
## [,33] [,34] [,35] [,36] [,37] [,38] [,39] [,40]
## [1,] 11.20217 11.20458 11.21741 11.19655 11.17985 11.2129 11.17456 11.19784
## [,41] [,42] [,43] [,44] [,45] [,46] [,47] [,48]
## [1,] 11.2048 11.21226 11.22262 11.19874 11.18102 11.1993 11.1599 11.16805
## [,49] [,50] [,51] [,52] [,53] [,54] [,55] [,56]
## [1,] 11.21302 11.16418 11.19527 11.22483 11.19319 11.22961 11.2423 11.2092
## [,57] [,58] [,59] [,60] [,61] [,62] [,63] [,64]
## [1,] 11.24073 11.20643 11.21193 11.16836 11.19644 11.18441 11.23107 11.1785
## [,65] [,66] [,67] [,68] [,69] [,70] [,71] [,72]
## [1,] 11.22032 11.17948 11.21245 11.22008 11.21195 11.19744 11.25956 11.19378
## [,73] [,74] [,75] [,76] [,77] [,78] [,79] [,80]
## [1,] 11.19129 11.20959 11.22088 11.20797 11.20137 11.21261 11.20245 11.28235
## [,81] [,82] [,83] [,84] [,85] [,86] [,87] [,88]
## [1,] 11.17951 11.21101 11.19195 11.216 11.16028 11.19517 11.1822 11.23088
## [,89] [,90] [,91] [,92] [,93] [,94] [,95] [,96]
## [1,] 11.21018 11.2027 11.21389 11.19311 11.21518 11.1964 11.2079 11.20843
## [,97] [,98] [,99] [,100]
## [1,] 11.23193 11.22976 11.23482 11.16394
##
## $d.avg
## [1] 0.1519792
##
## $d.avg.p
## [1] 0
##
## $d.avg.ci
## 2.5% 97.5%
## 0.1456425 0.1574157
##
## $d.avg.sims
## [,1] [,2] [,3] [,4] [,5] [,6] [,7]
## [1,] 0.1492427 0.1495158 0.1429838 0.1587612 0.151879 0.1509514 0.149975
## [,8] [,9] [,10] [,11] [,12] [,13] [,14]
## [1,] 0.1547097 0.155521 0.1546355 0.1535884 0.1438717 0.1499364 0.1524378
## [,15] [,16] [,17] [,18] [,19] [,20] [,21]
## [1,] 0.1485138 0.1551818 0.1525655 0.1550163 0.1526774 0.1521057 0.1515608
## [,22] [,23] [,24] [,25] [,26] [,27] [,28]
## [1,] 0.1524267 0.1559051 0.1500456 0.1541712 0.1540395 0.1534648 0.1527811
## [,29] [,30] [,31] [,32] [,33] [,34] [,35]
## [1,] 0.1485136 0.1547741 0.1521751 0.1528793 0.1569677 0.1539717 0.1480667
## [,36] [,37] [,38] [,39] [,40] [,41] [,42]
## [1,] 0.1492946 0.1513802 0.1532115 0.1545958 0.1460112 0.1526245 0.1556408
## [,43] [,44] [,45] [,46] [,47] [,48] [,49]
## [1,] 0.154903 0.1487474 0.1460328 0.1511042 0.149078 0.14924 0.1564456
## [,50] [,51] [,52] [,53] [,54] [,55] [,56]
## [1,] 0.1525593 0.1497311 0.1539671 0.1523164 0.1536853 0.1469819 0.1515726
## [,57] [,58] [,59] [,60] [,61] [,62] [,63]
## [1,] 0.1515456 0.1558625 0.1591451 0.1463466 0.1509702 0.1477079 0.148001
## [,64] [,65] [,66] [,67] [,68] [,69] [,70]
## [1,] 0.15385 0.1498622 0.1515471 0.1506911 0.1517766 0.1554256 0.1502839
## [,71] [,72] [,73] [,74] [,75] [,76] [,77]
## [1,] 0.145309 0.1551414 0.1514355 0.154452 0.1505923 0.1545065 0.1507176
## [,78] [,79] [,80] [,81] [,82] [,83] [,84]
## [1,] 0.1547162 0.1535516 0.1482686 0.1535817 0.1517571 0.1497825 0.1495267
## [,85] [,86] [,87] [,88] [,89] [,90] [,91]
## [1,] 0.1575879 0.1486527 0.155646 0.1572045 0.1558254 0.1473367 0.1570618
## [,92] [,93] [,94] [,95] [,96] [,97] [,98]
## [1,] 0.1482097 0.1515786 0.1517147 0.1470801 0.1536504 0.1560986 0.1462542
## [,99] [,100]
## [1,] 0.1572255 0.1555028
##
## $z.avg
## [1] 11.04954
##
## $z.avg.p
## [1] 0
##
## $z.avg.ci
## 2.5% 97.5%
## 10.99495 11.10281
##
## $z.avg.sims
## [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
## [1,] 11.07653 11.00234 11.04517 11.04865 11.05008 11.09232 10.96967 11.07239
## [,9] [,10] [,11] [,12] [,13] [,14] [,15] [,16]
## [1,] 11.03001 11.10959 11.04402 10.99299 11.03328 10.9734 11.04238 11.02791
## [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24]
## [1,] 11.04464 11.05243 11.05256 11.0789 11.04856 11.03042 11.04034 11.07771
## [,25] [,26] [,27] [,28] [,29] [,30] [,31] [,32]
## [1,] 11.04448 11.06506 11.02427 11.06787 11.02587 11.06495 10.99712 11.03802
## [,33] [,34] [,35] [,36] [,37] [,38] [,39] [,40]
## [1,] 11.0452 11.05061 11.06934 11.04726 11.02847 11.05969 11.01997 11.05183
## [,41] [,42] [,43] [,44] [,45] [,46] [,47] [,48]
## [1,] 11.05218 11.05662 11.06771 11.04999 11.03499 11.04819 11.01082 11.01881
## [,49] [,50] [,51] [,52] [,53] [,54] [,55] [,56]
## [1,] 11.05658 11.01162 11.04554 11.07086 11.04087 11.07593 11.09531 11.05763
## [,57] [,58] [,59] [,60] [,61] [,62] [,63] [,64]
## [1,] 11.08918 11.05057 11.05279 11.02201 11.04547 11.0367 11.08307 11.02465
## [,65] [,66] [,67] [,68] [,69] [,70] [,71] [,72]
## [1,] 11.07046 11.02794 11.06175 11.0683 11.05652 11.04716 11.11425 11.03864
## [,73] [,74] [,75] [,76] [,77] [,78] [,79] [,80]
## [1,] 11.03985 11.05514 11.07029 11.05346 11.05065 11.05789 11.0489 11.13408
## [,81] [,82] [,83] [,84] [,85] [,86] [,87] [,88]
## [1,] 11.02593 11.05925 11.04217 11.06647 11.00269 11.04651 11.02655 11.07368
## [,89] [,90] [,91] [,92] [,93] [,94] [,95] [,96]
## [1,] 11.05435 11.05536 11.05683 11.0449 11.0636 11.04469 11.06082 11.05478
## [,97] [,98] [,99] [,100]
## [1,] 11.07583 11.0835 11.0776 11.00844
##
## $n.avg
## [1] 0.0135831
##
## $n.avg.p
## [1] 0
##
## $n.avg.ci
## 2.5% 97.5%
## 0.01296853 0.01406905
##
## $n.avg.sims
## [,1] [,2] [,3] [,4] [,5] [,6]
## [1,] 0.01329465 0.01340726 0.01277993 0.01416573 0.01355825 0.01342594
## [,7] [,8] [,9] [,10] [,11] [,12]
## [1,] 0.01348739 0.01378003 0.01390376 0.01372802 0.01371618 0.01291851
## [,13] [,14] [,15] [,16] [,17] [,18]
## [1,] 0.01340727 0.01370125 0.01327095 0.01387647 0.01362533 0.01383154
## [,19] [,20] [,21] [,22] [,23] [,24]
## [1,] 0.01362554 0.01354338 0.01353207 0.01363041 0.01392476 0.01336382
## [,25] [,26] [,27] [,28] [,29] [,30]
## [1,] 0.01376694 0.01373011 0.01372951 0.01361606 0.01329054 0.01379482
## [,31] [,32] [,33] [,34] [,35] [,36]
## [1,] 0.01364886 0.01366104 0.01401226 0.01374184 0.01319972 0.01333398
## [,37] [,38] [,39] [,40] [,41] [,42]
## [1,] 0.01354045 0.01366386 0.01383462 0.01303922 0.01362135 0.0138813
## [,43] [,44] [,45] [,46] [,47] [,48]
## [1,] 0.01380276 0.01328251 0.01306078 0.0134923 0.01335837 0.01336312
## [,49] [,50] [,51] [,52] [,53] [,54]
## [1,] 0.01395213 0.01366507 0.0133745 0.01371665 0.01360796 0.01368572
## [,55] [,56] [,57] [,58] [,59] [,60]
## [1,] 0.01307401 0.01352216 0.01348184 0.01390831 0.01419426 0.01310368
## [,61] [,62] [,63] [,64] [,65] [,66]
## [1,] 0.01348378 0.01320658 0.01317782 0.01376302 0.01335631 0.01355582
## [,67] [,68] [,69] [,70] [,71] [,72]
## [1,] 0.01343963 0.01352723 0.0138625 0.01342127 0.01290539 0.01385961
## [,73] [,74] [,75] [,76] [,77] [,78]
## [1,] 0.01353156 0.01377855 0.01342072 0.01378541 0.01345529 0.01379841
## [,79] [,80] [,81] [,82] [,83] [,84]
## [1,] 0.01370697 0.01314163 0.01373779 0.01353643 0.01338306 0.01333156
## [,85] [,86] [,87] [,88] [,89] [,90] [,91]
## [1,] 0.01412042 0.01327829 0.01391909 0.01399752 0.01390035 0.01315189 0.014006
## [,92] [,93] [,94] [,95] [,96] [,97]
## [1,] 0.01324115 0.01351548 0.01355031 0.01312289 0.01370847 0.01389776
## [,98] [,99] [,100]
## [1,] 0.01302381 0.01399448 0.01392902
##
## $boot
## [1] FALSE
##
## $boot.ci.type
## [1] "perc"
##
## $treat
## [1] "hypertension"
##
## $mediator
## [1] "history_diabete"
##
## $covariates
## NULL
##
## $INT
## [1] FALSE
##
## $conf.level
## [1] 0.95
##
## $model.y
##
## Call:
## lm(formula = SBP ~ BMI + history_diabete + hypertension + DBP +
## SEX, data = dataset_sbp)
##
## Coefficients:
## (Intercept) BMI history_diabeteTRUE
## 56.4599 0.3706 3.1875
## hypertensionTRUE DBP SEX
## 11.0449 0.7093 -0.6534
##
##
## $model.m
##
## Call:
## lm(formula = history_diabete ~ BMI + hypertension + DBP + SEX,
## data = dataset_sbp)
##
## Coefficients:
## (Intercept) BMI hypertensionTRUE DBP
## -0.0536640 0.0085262 0.0476778 -0.0009095
## SEX
## 0.0007004
##
##
## $control.value
## [1] 0
##
## $treat.value
## [1] 1
##
## $nobs
## [1] 1000000
##
## $sims
## [1] 100
##
## $call
## mediate(model.m = med.fit, model.y = out.fit, sims = 100, treat = "hypertension",
## mediator = "history_diabete", robustSE = TRUE)
##
## $robustSE
## [1] TRUE
##
## $cluster
## NULL
##
## attr(,"class")
## [1] "mediate"
summary(med.out)
##
## Causal Mediation Analysis
##
## Quasi-Bayesian Confidence Intervals
##
## Estimate 95% CI Lower 95% CI Upper p-value
## ACME 0.1520 0.1456 0.16 <2e-16 ***
## ADE 11.0495 10.9949 11.10 <2e-16 ***
## Total Effect 11.2015 11.1428 11.25 <2e-16 ***
## Prop. Mediated 0.0136 0.0130 0.01 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Sample Size Used: 1000000
##
##
## Simulations: 100
Bibliography
## Computing. R Foundation for Statistical Computing, Vienna, Austria. <https://www.R-project.org/>. We have invested a lot of time and effort in creating R, please cite it when using it for data analysis. See also 'citation("pkgname")' for citing R packages.
## Grolemund G, Hayes A, Henry L, Hester J, Kuhn M, Pedersen TL, Miller E, Bache SM, Müller K, Ooms J, Robinson D, Seidel DP, Spinu V, Takahashi K, Vaughan D, Wilke C, Woo K, Yutani H (2019). "Welcome to the tidyverse." Journal of Open Source Software_, *4*(43), 1686. doi:10.21105/joss.01686 <https://doi.org/10.21105/joss.01686>.
## R. version 0.5.0. Buffalo, New York. http://github.com/trinker/pacman
## J, reikoch, Beasley W, O'Connor B, Warnes GR, Quinn M, Kamvar ZN (2023). yaml: Methods to Convert R Data to YAML and Back_. R package version 2.3.7, <https://CRAN.R-project.org/package=yaml>. ATTENTION: This citation information has been auto-generated from the package DESCRIPTION file and may need manual editing, see 'help("citation")'.