Skip to content

Commit

Permalink
Add tests (#37)
Browse files Browse the repository at this point in the history
* add tests

* update snapshots
  • Loading branch information
clarkliming authored Aug 19, 2024
1 parent 374a3f9 commit 7607621
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
34 changes: 34 additions & 0 deletions tests/testthat/_snaps/treatment_effect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# treatment_effect works for lm/glm object

Code
treatment_effect(fit_binom, treatment = treatment ~ s1, eff_measure = h_diff)
Output
Treatment Effect
-------------
Model : y_b ~ treatment * s1 + covar
Randomization: treatment ~ s1
Variance Type: variance
Estimate Std.Err Z Value Pr(>z)
trt1 - pbo 0.2246 0.0477 4.71 1.3e-06 ***
trt2 - pbo 0.2653 0.0475 5.58 1.2e-08 ***
trt2 - trt1 0.0407 0.0479 0.85 0.2
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

---

Code
treatment_effect(fit_lm, treatment = treatment ~ s1, eff_measure = h_diff)
Output
Treatment Effect
-------------
Model : NULL
Randomization: treatment ~ s1
Variance Type: variance
Estimate Std.Err Z Value Pr(>z)
trt1 - pbo 0.564 0.101 5.60 1.1e-08 ***
trt2 - pbo 0.771 0.101 7.61 1.4e-14 ***
trt2 - trt1 0.207 0.107 1.94 0.026 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

4 changes: 2 additions & 2 deletions tests/testthat/test-treatment_effect.R
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,6 @@ test_that("treatment_effect works as expected for custom contrast", {
})

test_that("treatment_effect works for lm/glm object", {
expect_silent(treatment_effect(fit_binom, treatment = treatment ~ s1, eff_measure = h_diff))
expect_silent(treatment_effect(fit_lm, treatment = treatment ~ s1, eff_measure = h_diff))
expect_snapshot(treatment_effect(fit_binom, treatment = treatment ~ s1, eff_measure = h_diff))
expect_snapshot(treatment_effect(fit_lm, treatment = treatment ~ s1, eff_measure = h_diff))
})

0 comments on commit 7607621

Please sign in to comment.