transfer from old repo

This commit is contained in:
Andreas Gammelgaard Damsbo 2026-08-19 09:27:27 +02:00
commit 277e2b8cf3
No known key found for this signature in database
1111 changed files with 83736 additions and 0 deletions

View file

@ -0,0 +1,114 @@
---
title: "Project B - DAG"
author: "AGDamsbo"
date: "`r Sys.Date()`"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
# Hypothesis
```{r}
labels_all<-list(rtreat~"Trial treatment",
pase_0~"PASE score",
age~"Age",
sex~"Sex",
smoker~"History of smoking",
civil~"Cohabitation",
diabetes~"Known diabetes",
hypertension~"Known hypertension",
afli~"Known Atrialfibrillation",
ami~"Previos myocardial infarction",
tci~"Previos TIA",
pad~"Known peripheral artery disease",
nihss_0~"Acute NIHSS score",
thrombolysis~"Thrombolytic therapy",
thrombechtomy~"Endovascular treatment",
SES~"Socio economic status",
education~"Education",
ad_treat~"Anti depression treatment",
vasc_event~"Vascular event")
```
```{r}
vars <- c(
"pase_0",
"age",
"sex",
"civil",
"smoker",
"rtreat",
"alc",
"afli",
"hypertension",
"diabetes",
"mrs_0",
"nihss_c",
"thrombolysis",
"pad",
"thrombechtomy",
"ami",
"tci",
"compliant",
"SES",
"education"
)
```
```{r}
library(ggdag)
library(ggplot2)
```
```{r}
dag <-
dagify(
vasc_event ~ pase_0 + age + sex + civil + smoker + rtreat + alc + afli +
hypertension + diabetes + mrs_0 + nihss_0 + thrombolysis + pad + thrombechtomy +
ami + tci + SES + education + ad_treat + svd,
pase_0 ~ sex + civil + alc + pad + SES + education + hypertension + diabetes,
diabetes ~ civil,
svd~hypertension + diabetes + alc,
mrs_0 ~ tci + ami + hypertension + diabetes + svd,
age ~ smoker+SES+education,
civil ~ sex + age + SES + civil,
# smoker~ ,
alc ~ sex+SES+education,
# afli~ ,
hypertension~ alc,
nihss_0 ~ hypertension + diabetes + pase_0 + age,
thrombolysis ~ mrs_0+nihss_0,
# pad~ ,
thrombechtomy ~ mrs_0+nihss_0,
# ami~ ,
# tci~ ,
# compliant~ ,
# SES~ ,
# education,
ad_treat~education+SES,
# labels = labels_all,
latent = c("svd"),
exposure = "pase_0",
outcome = "vasc_event"
)
```
```{r}
dag |> ggdag(text = TRUE) + theme_dag(6) + geom_dag_edges_arc()
```
```{r}
dag |> ggdag_parents("svd")
```
```{r}
dag |> ggdag_paths(text = TRUE, shadow = TRUE)
```
```{r}
dag |> ggdag_adjustment_set(text = TRUE, shadow = TRUE,stylized = TRUE)
```