-
Notifications
You must be signed in to change notification settings - Fork 0
/
DAG.Rmd
163 lines (148 loc) · 3.11 KB
/
DAG.Rmd
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
---
title: "DAG"
author: "Matthew Hoctor, Bryon Langford"
date: "6/24/2021"
output:
html_document:
number_sections: no
theme: lumen
toc: yes
toc_float:
collapsed: yes
smooth_scroll: no
pdf_document:
toc: yes
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r libraries, include=FALSE}
#library(dplyr)
#library(readxl)
#library(tidyverse)
#library(ggplot2)
#library(CarletonStats)
#library(pwr)
#library(BSDA)
#library(exact2x2)
#library(car)
#library(dvmisc)
#library(emmeans)
#library(gridExtra)
#library(DescTools)
#library(epitools)
#library(pROC)
#library(rje)
#library(lmtest)
#library(gtsummary)
#library(mfp)
#library(linearspline)
library(dagitty)
```
# Preliminary DAG
This DAG is based on Vidot et al.'s causal scheme [link](https://pubmed.ncbi.nlm.nih.gov/31439096/):
```{r Vidot DAG}
g0 <- dagitty("dag {
Survey_Year -> Cannabis
Survey_Year -> Hypertension
Age -> Cannabis
Age -> Hypertension
Alcohol -> Hypertension
BMI -> Hypertension
Cannabis -> Alcohol
Cannabis -> BMI
Cannabis -> Hypertension
Cannabis -> Tobacco
Education -> Cannabis
Education -> Hypertension
Gender -> Cannabis
Gender -> Hypertension
Race -> Cannabis
Race -> Hypertension
Tobacco -> Hypertension
}
")
coordinates(g0) <-
list(
x=c(Cannabis=0,
Alcohol=1,Tobacco=1,BMI=1,Gender=1,Age=1,Race=1,Survey_Year=1,Education=1,
Hypertension=2),
y=c(Alcohol=0,Tobacco=1,BMI=2,
Cannabis=3,
Hypertension=3,
Gender=4,Age=5,Race=6,Survey_Year=7,Education=8)
)
plot(g0)
```
## Code for Daggity.net
dag {
bb="0,0,1,1"
"Survey Year" [adjusted,pos="0.340,0.791"]
Age [adjusted,pos="0.336,0.573"]
Alcohol [pos="0.355,0.105"]
BMI [pos="0.347,0.313"]
Cannabis [exposure,pos="0.169,0.401"]
Gender [adjusted,pos="0.336,0.466"]
Hypertension [outcome,pos="0.554,0.402"]
Race [adjusted,pos="0.340,0.685"]
Tobacco [pos="0.344,0.209"]
"Survey Year" -> Cannabis
"Survey Year" -> Hypertension
Age -> Cannabis
Age -> Hypertension
Alcohol -> Hypertension
BMI -> Hypertension
Cannabis -> Alcohol
Cannabis -> BMI
Cannabis -> Hypertension
Cannabis -> Tobacco
Gender -> Cannabis
Gender -> Hypertension
Race -> Cannabis
Race -> Hypertension
Tobacco -> Hypertension
}
# Diet as a mediator
```{r diet DAG}
g1 <- dagitty("dag {
Survey_Year -> Cannabis
Survey_Year -> Hypertension
Age -> Cannabis
Age -> Hypertension
Alcohol -> Hypertension
BMI -> Hypertension
Cannabis -> Alcohol
Cannabis -> BMI
Cannabis -> Diet
Cannabis -> Hypertension
Cannabis -> Tobacco
Diet -> BMI
Diet -> Hypertension
Education -> Cannabis
Education -> Hypertension
Gender -> Cannabis
Gender -> Hypertension
Income -> Cannabis
Income -> Hypertension
Race -> Cannabis
Race -> Hypertension
Tobacco -> Hypertension
Cannabis [exposure]
Hypertension [outcome]
}
")
coordinates(g1) <-
list(
x=c(Cannabis=0,
Diet=0.66,
Alcohol=1,Tobacco=1,Gender=1,Age=1,Race=1,Survey_Year=1,Education=1,Income=1,
BMI=1.33,
Hypertension=2),
y=c(Alcohol=0,Tobacco=1,
Diet=2,BMI=2,
Cannabis=3,
Hypertension=3,
Gender=4,Age=5,Race=6,Survey_Year=7,Education=8,Income=9)
)
plot(g1)
```