-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCDA-mediation.Rmd
More file actions
48 lines (42 loc) · 1.18 KB
/
CDA-mediation.Rmd
File metadata and controls
48 lines (42 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
---
title: "Mediation Analysis with Logistic Regression"
author: "Riley Smith"
date: "`r format(Sys.Date(), '%d %B %Y')`"
---
```{r setup, echo=FALSE, results='hide', message=FALSE, warning=FALSE, cache=FALSE}
source("../SETUP.R")
knitr::opts_chunk$set(
tidy = FALSE,
echo = TRUE,
cache = FALSE,
fig.keep = 'high',
fig.show = 'asis',
results = 'asis',
autodep = T,
Rplot = TRUE,
dev = 'pdf',
fig.path = 'graphics/mediation/rplot-',
fig.width = 7,
fig.height = 7,
out.width = "\\linewidth"
)
```
```{r medmodel}
set.seed(42)
dat <- R.rspss("data/heart.sav", vlabs = TRUE)
library(mediation)
dat <- na.omit(dat)
# dat$w1neg.d <- sapply(dat$w1neg, R.dich)
treatment <- c("w1neg")
mediators <- c("w1cesd9")
outcome <- c("w1hheart")
datasets <- list(dat = dat)
m.model <- mediations(datasets, treatment, mediators, outcome,
families = c("gaussian", "binomial"),
interaction = FALSE,
conf.level = .95, sims = 50)
summary(m.model)
plot.mediations(m.model, labels = c("Indirect", "Direct", "Total"))
```
\newpage
# References`r R.cite_r("~/GitHub/auxDocs/REFs.bib", footnote = TRUE)`