Skip to content

Commit 2a60377

Browse files
committed
Update contributor attributions in NEWS.md for issues #728 and #730
1 parent 5db014a commit 2a60377

File tree

4 files changed

+55
-131
lines changed

4 files changed

+55
-131
lines changed

NEWS.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,13 @@
2323
that provides stabler results for small samples and zero within-imputation
2424
variance. Contributed: @frederikfabriciusbjerre (#726)
2525

26+
2627
### Minor changes
2728

28-
* Explicitly load `toenail` data from the `mice` package to avoid `lme4` conflict. Thanks: Ben Bolker (#730)
29+
* Adds fallback for `lmer` objects in `pool()` without requiring `broom.mixed`.
30+
Contributed: @anya-decarlo (#728)
31+
32+
* Explicitly load `toenail` data from the `mice` package to avoid `lme4` conflict. Contributed: @bbolker (#730)
2933

3034
# mice 3.18.0
3135

R/summary.R

Lines changed: 50 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -16,36 +16,47 @@
1616
#' @seealso \code{\link{mira}}
1717
#' @method summary mira
1818
#' @export
19-
summary.mira <- function(object,
20-
type = c("tidy", "glance", "summary"),
21-
dfcom = NULL,
22-
...) {
19+
summary.mira <- function(
20+
object,
21+
type = c("tidy", "glance", "summary"),
22+
dfcom = NULL,
23+
...
24+
) {
2325
type <- match.arg(type)
2426
fitlist <- getfit(object)
2527
if (type == "tidy") {
2628
# Try standard tidy() first, with fallback for lmer objects
27-
v <- tryCatch({
28-
lapply(fitlist, tidy, effects = "fixed", parametric = TRUE, ...) %>% bind_rows()
29-
}, error = function(e) {
30-
# Check if this is an lmerMod object without broom.mixed
31-
if (inherits(fitlist[[1]], "lmerMod") &&
32-
grepl("No.*tidy.*method", e$message, ignore.case = TRUE)) {
33-
# Manual extraction for lmer objects using built-in methods
34-
lapply(fitlist, function(fit) {
35-
coefs <- lme4::fixef(fit)
36-
se <- sqrt(diag(as.matrix(stats::vcov(fit))))
37-
data.frame(
38-
term = names(coefs),
39-
estimate = as.numeric(coefs),
40-
std.error = as.numeric(se),
41-
stringsAsFactors = FALSE
42-
)
43-
}) %>% bind_rows()
44-
} else {
45-
# Re-throw the error if it's not an lmer issue
46-
stop(e)
29+
v <- tryCatch(
30+
{
31+
lapply(fitlist, tidy, effects = "fixed", parametric = TRUE, ...) %>%
32+
bind_rows()
33+
},
34+
error = function(e) {
35+
# Check if this is an lmerMod object without broom.mixed
36+
if (
37+
inherits(fitlist[[1]], "lmerMod") &&
38+
grepl("No.*tidy.*method", e$message, ignore.case = TRUE)
39+
) {
40+
# Ensure lme4 is available (CRAN-compliant check)
41+
install.on.demand("lme4", ...)
42+
# Manual extraction for lmer objects using built-in methods
43+
lapply(fitlist, function(fit) {
44+
coefs <- lme4::fixef(fit)
45+
se <- sqrt(diag(as.matrix(stats::vcov(fit))))
46+
data.frame(
47+
term = names(coefs),
48+
estimate = as.numeric(coefs),
49+
std.error = as.numeric(se),
50+
stringsAsFactors = FALSE
51+
)
52+
}) %>%
53+
bind_rows()
54+
} else {
55+
# Re-throw the error if it's not an lmer issue
56+
stop(e)
57+
}
4758
}
48-
})
59+
)
4960
}
5061
if (type == "glance") {
5162
v <- lapply(fitlist, glance, ...) %>% bind_rows()
@@ -54,8 +65,9 @@ summary.mira <- function(object,
5465
# not supplied by broom <= 0.5.6
5566
model <- getfit(object, 1L)
5667
if (!"nobs" %in% colnames(v)) {
57-
v$nobs <- tryCatch(length(stats::residuals(model)),
58-
error = function(e) {NULL})
68+
v$nobs <- tryCatch(length(stats::residuals(model)), error = function(e) {
69+
NULL
70+
})
5971
}
6072

6173
# get df.residuals
@@ -87,10 +99,12 @@ summary.mice.anova <- function(object, ...) {
8799

88100
# handle objects from D1, D2 and D3
89101
if (is.null(out)) {
90-
out <- list(`1 ~~ 2` = list(
91-
result = object$result,
92-
dfcom = object$dfcom
93-
))
102+
out <- list(
103+
`1 ~~ 2` = list(
104+
result = object$result,
105+
dfcom = object$dfcom
106+
)
107+
)
94108
}
95109

96110
test <- names(out)
@@ -115,8 +129,11 @@ summary.mice.anova <- function(object, ...) {
115129

116130
structure(
117131
list(
118-
models = ff, comparisons = rf,
119-
m = object$m, method = object$method, use = object$use
132+
models = ff,
133+
comparisons = rf,
134+
m = object$m,
135+
method = object$method,
136+
use = object$use
120137
),
121138
class = c("mice.anova.summary", class(object))
122139
)

test_lmer_fix.R

Lines changed: 0 additions & 35 deletions
This file was deleted.

test_verify_accuracy.R

Lines changed: 0 additions & 62 deletions
This file was deleted.

0 commit comments

Comments
 (0)