From 588b5037fc8f13de112cddfc9c274e1558053987 Mon Sep 17 00:00:00 2001 From: Kris Sankaran Date: Mon, 19 Aug 2024 11:24:56 -0500 Subject: [PATCH] test for new sensitivity functions --- tests/testthat/test-sensitivity.R | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 tests/testthat/test-sensitivity.R diff --git a/tests/testthat/test-sensitivity.R b/tests/testthat/test-sensitivity.R new file mode 100644 index 0000000..3926a28 --- /dev/null +++ b/tests/testthat/test-sensitivity.R @@ -0,0 +1,14 @@ + +xy_data <- demo_spline() +exper <- mediation_data(xy_data, starts_with("outcome"), "treatment", "mediator") +model <- multimedia(exper, outcome_estimator = rf_model(num.trees = 1e3)) |> + estimate(exper) + +sensitivity_curve <- sensitivity(model, exper, n_rho = 10) +test_that("Sensitivity curve has correct bounds.", { + expect_equal(nrow(sensitivity_curve), 10) +}) + +test_that("Sensitivity curve has correct column names.", { + expect_named(sensitivity_curve, c("rho", "indirect_overall")) +}) \ No newline at end of file