-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
glmnetUtils namespace, and add associated test
- Loading branch information
1 parent
6ccf5da
commit 112f80e
Showing
2 changed files
with
26 additions
and
1 deletion.
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,25 @@ | ||
|
||
library(multimedia) | ||
|
||
# Joy dataset example | ||
exper <- mediation_data(demo_joy(), "PHQ", "treatment", starts_with("ASV")) | ||
|
||
test_that("Estimation with RF works in a simple case.", { | ||
model <- multimedia(exper) |> | ||
estimate(exper) | ||
|
||
predictions <- predict(model) | ||
expect_equal(names(predictions), c("mediators", "outcomes")) | ||
expect_equal(colnames(predictions$mediators), mediators(model)) | ||
expect_equal(mediators(model), paste0("ASV", 1:5)) | ||
}) | ||
|
||
test_that("Estimation with glmnet works in a simple case", { | ||
model <- multimedia(exper, glmnet_model(lambda = .1)) |> | ||
estimate(exper) | ||
|
||
predictions <- predict(model) | ||
expect_equal(names(predictions), c("mediators", "outcomes")) | ||
expect_equal(colnames(predictions$mediators), mediators(model)) | ||
expect_equal(mediators(model), paste0("ASV", 1:5)) | ||
}) |