Skip to content

Commit

Permalink
wordlist, tests
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Aug 3, 2024
1 parent 9b9bb45 commit 5396e4f
Show file tree
Hide file tree
Showing 3 changed files with 130 additions and 0 deletions.
4 changes: 4 additions & 0 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Cribari
Cronbach's
Crujeiras
Csaki
DAGs
DBSCAN
DOI
Datenerhebung
Expand Down Expand Up @@ -162,6 +163,7 @@ Nordhausen
Normed
ORCID
OSF
OSX
Olkin
PNFI
Pek
Expand Down Expand Up @@ -251,6 +253,7 @@ brmsfit
cauchy
clusterable
concurvity
dagitty
datawizard
dbscan
der
Expand All @@ -267,6 +270,7 @@ fixest
fpsyg
gam
geoms
ggdag
ggplot
gjo
glm
Expand Down
92 changes: 92 additions & 0 deletions tests/testthat/_snaps/check_dag.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# check_dag

Code
print(dag)
Output
# Correct adjustments for identifying direct effects
Model is correctly specified.
- Outcome: y
- Exposure: x
No adjustment needed to estimate the direct effect of x on y.
# Correct adjustments for identifying total effects
Model is correctly specified.
- Outcome: y
- Exposure: x
No adjustment needed to estimate the total effect of x on y.

---

Code
print(dag)
Output
# Correct adjustments for identifying direct effects
Model is correctly specified.
- Outcome: y
- Exposure: x
All minimal sufficient adjustments to estimate the direct effect were done.
# Correct adjustments for identifying total effects
Model is correctly specified.
- Outcome: y
- Exposure: x
All minimal sufficient adjustments to estimate the total effect were done.

---

Code
print(dag)
Output
# Correct adjustments for identifying direct effects
Incorrectly adjusted!
- Outcome: y
- Exposure: x
To estimate the direct effect, also adjust for: b.
Currently, the model does not adjust for any variables.
# Correct adjustments for identifying total effects
Incorrectly adjusted!
- Outcome: y
- Exposure: x
To estimate the total effect, also adjust for: b.
Currently, the model does not adjust for any variables.

---

Code
print(dag)
Output
# Correct adjustments for identifying direct effects
Incorrectly adjusted!
- Outcome: y
- Exposure: x
To estimate the direct effect, also adjust for: b and c.
Currently, the model currently only adjusts for c.
# Correct adjustments for identifying total effects
Incorrectly adjusted!
- Outcome: y
- Exposure: x
To estimate the total effect, also adjust for: b and c.
Currently, the model currently only adjusts for c.

34 changes: 34 additions & 0 deletions tests/testthat/test-check_dag.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
skip_on_cran()
skip_if_not_installed("ggdag")
skip_if_not_installed("dagitty")

test_that("check_dag", {
dag <- check_dag(
y ~ x + b,
outcome = "y",
exposure = "x"
)
expect_snapshot(print(dag))
dag <- check_dag(
y ~ x + b,
outcome = "y",
exposure = "x",
adjusted = "b"
)
expect_snapshot(print(dag))
dag <- check_dag(
y ~ x + b + c,
x ~ b,
outcome = "y",
exposure = "x"
)
expect_snapshot(print(dag))
dag <- check_dag(
y ~ x + b + c,
x ~ b,
outcome = "y",
exposure = "x",
adjusted = "c"
)
expect_snapshot(print(dag))
})

0 comments on commit 5396e4f

Please sign in to comment.