Skip to content

Commit

Permalink
Issue #856 Calculating inferences for cross-contrasts #856
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentarelbundock committed Aug 9, 2023
1 parent 1599a4c commit b1309c1
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: marginaleffects
Title: Predictions, Comparisons, Slopes, Marginal Means, and Hypothesis Tests
Version: 0.13.0.9012
Version: 0.13.0.9013
Authors@R:
c(person(given = "Vincent",
family = "Arel-Bundock",
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ New:

Bug fixes:

* `inferences()` supports the `cross` argument for `comparisons()` objects. Thanks to Kirill Solovev for report #856.
* `splines::bs()` in formulas could produce incorrect results due to weirdness in `stats::model.matrix()`. Thanks to @chiungming for report #831.
* `mgcv` with `ocat` are now supported. Thanks to Lorenzo Fabbri for Issue #844.
* `quantreg` problem with `rowid` merge did not affect estimates but did not return the full original data. Issue #829.
Expand Down
2 changes: 2 additions & 0 deletions R/comparisons.R
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ comparisons <- function(model,
FUN = comparisons,
model = model, newdata = newdata, vcov = vcov, variables = variables, type = type, by = by,
conf_level = conf_level,
cross = cross,
comparison = comparison, transform = transform, wts = wts, hypothesis = hypothesis, eps = eps, ...)
if (!is.null(out)) {
return(out)
Expand Down Expand Up @@ -658,6 +659,7 @@ avg_comparisons <- function(model,
out <- inferences_dispatch(
FUN = avg_comparisons,
model = model, newdata = newdata, vcov = vcov, variables = variables, type = type, by = by,
cross = cross,
conf_level = conf_level,
comparison = comparison, transform = transform, wts = wts, hypothesis = hypothesis, eps = eps, ...)
if (!is.null(out)) {
Expand Down
11 changes: 11 additions & 0 deletions inst/tinytest/test-inferences.R
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,15 @@ mod <- lm(Petal.Length ~ Sepal.Length * Sepal.Width * Species, data = iris)
expect_error(inferences(marginal_means(mod), method = "fwb"), pattern = "not supported")


# Issue #856
tmp <- lm(Petal.Length ~ Sepal.Length * Species, data = iris)
cmp <- avg_comparisons(tmp,
variables = list(Sepal.Length = 1, Species = "reference"),
cross = TRUE) |>
inferences(method = "boot", R = 5) |>
suppressWarnings()
expect_inherits(cmp, "comparisons")
expect_equal(nrow(cmp), 2)


rm(list = ls())

0 comments on commit b1309c1

Please sign in to comment.