-
-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9b9bb45
commit 5396e4f
Showing
3 changed files
with
130 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | ||
}) |