Skip to content

Commit

Permalink
Resp transf detection improvement (#504)
Browse files Browse the repository at this point in the history
  • Loading branch information
rvlenth committed Jul 19, 2024
1 parent 909821d commit 22889dc
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: emmeans
Type: Package
Title: Estimated Margin2l Means, aka Least-Squares Means
Version: 1.10.3-090004
Date: 2024-07-18
Version: 1.10.3-090005
Date: 2024-07-19
Authors@R: c(person("Russell V.", "Lenth", role = c("aut", "cre", "cph"),
email = "russell-lenth@uiowa.edu"),
person("Ben", "Bolker", role = "ctb"),
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ title: "NEWS for the emmeans package"
(defaults to `TRUE`) just in case we broke anything that used to work.
* Better default contrasts in `qdrg()` (#501)
* Bug fix for nuisance factors when we have a multivariate response (#503)
* Improved auto-detection of response transformation (#504)


## emmeans 1.10.3
Expand Down
2 changes: 1 addition & 1 deletion R/ref-grid.R
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ ref_grid <- function(object, at, cov.reduce = mean, cov.keep = get_emm_option("c
# next stmt assumes that model formula is 1st argument (2nd element) in call.
# if not, we probably get an error or something that isn't a formula
# and it is silently ignored
frm = try(formula(eval(attr(data, "call")[[2]])), silent = TRUE)
frm = try(formula(eval(attr(data, "call")[[2]], environment(trms))), silent = TRUE)
if (inherits(frm, "formula")) { # response may be transformed
lhs = if(length(frm) == 2) NULL
else frm[-3]
Expand Down
7 changes: 6 additions & 1 deletion tests/testthat/test-ref_grid.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,9 @@ test_that("Fuzzy matching of numerical mult.levels works", {
expect_equal(MOats.nrg@levels$nitro, c(0, .4), 0.001)
})


### Nuisance factors
MOats.rgn = ref_grid(MOats.lm, nuisance = "Block")
MOats.emm = emmeans(MOats.lm, ~ Variety * rep.meas)
test_that("We get same predictions with and without nuisance specs", {
expect_equal(predict(MOats.rgn), predict(MOats.emm), 0.001)
})

0 comments on commit 22889dc

Please sign in to comment.