Skip to content

Commit

Permalink
multcomp works with raw models
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentarelbundock committed Dec 11, 2024
1 parent cca37b3 commit 8a2b01e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
6 changes: 3 additions & 3 deletions R/hypotheses.R
Original file line number Diff line number Diff line change
Expand Up @@ -443,9 +443,6 @@ hypotheses <- function(

out <- sort_columns(out)

out <- multcomp_test(out, multcomp = multcomp, conf_level = conf_level)


class(out) <- c("hypotheses", "deltamethod", class(out))
attr(out, "posterior_draws") <- draws
attr(out, "model") <- model
Expand All @@ -456,6 +453,9 @@ hypotheses <- function(
attr(out, "vcov.type") <- vcov.type
attr(out, "conf_level") <- conf_level

# must be after attributes for vcov
out <- multcomp_test(out, multcomp = multcomp, conf_level = conf_level)

# Issue #1102: hypotheses() should not be called twice on the same object
attr(out, "hypotheses_call") <- TRUE

Expand Down
9 changes: 8 additions & 1 deletion inst/tinytest/test-multcomp.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,11 @@ mod <- lm(y ~ x * z)
pre1 <- avg_predictions(mod, by = "z")
pre2 <- hypotheses(pre1, multcomp = "single-step")
expect_true(any(pre1$p.value < pre2$p.value))
expect_true(all(pre1$p.value <= pre2$p.value))
expect_true(all(pre1$p.value <= pre2$p.value))

mod <- lm(y ~ x * z)
pkgload::load_all()
hyp1 <- hypotheses(mod)
hyp2 <- hypotheses(mod, multcomp = "single-step")
expect_true(any(hyp1$p.value < hyp2$p.value))
expect_true(all(hyp1$p.value <= hyp2$p.value))

0 comments on commit 8a2b01e

Please sign in to comment.