-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for vcov = "satterthwaite" | "kenward-roger"
w/ aggragation
#1302
Comments
That's interesting. To be honest, I know none of the relevant theory, here. I'm definitely open to doing it that way, but before implementing I'd ideally like to see a reference to an academic text to justify this. Does such a thing exist? |
I'm not familiar with such a reference. @rvlenth, can you point us in the right direction? |
Maybe I'm missing something, but isn't your aggregation a linear process? If so, the right thing to do is aggregate the linear functions (of the fixed-effect coefficients) involved, thus obtaining one linear function for each aggregated estimate; then apply The only place (at least that I can remember) where emmeans uses the minimum d.f. is in |
As far as I understand, the various df-producing weights require a vector/matrix of weights in terms of the model's fixed effects. But there are never produced by This also seems to be the case in library(lmerTest)
library(emmeans)
sleepstudy$Reaction[c(1:3, 11:14)] <- NA
fm1 <- lmer(Reaction ~ Days + (Days | Subject), data = sleepstudy)
em <- emmeans(fm1, ~ Days, cov.reduce = FALSE)
em@dffun
#> function (k, dfargs)
#> pbkrtest::Lb_ddf(k, dfargs$unadjV, dfargs$adjV)
#> <environment: base>
#> attr(,"mesg")
#> [1] "kenward-roger"
em2 <- regrid(em)
em2@dffun
#> function (k, dfargs)
#> {
#> idx = which(zapsmall(k) != 0)
#> ifelse(length(idx) == 0, NA, min(dfargs$df[idx], na.rm = TRUE))
#> }
#> <bytecode: 0x000001ec6fb8a278>
#> <environment: 0x000001ec6fb8e278>
#> attr(,"mesg")
#> [1] "inherited from kenward-roger when re-gridding" Created on 2024-12-15 with reprex v2.1.1 |
But I don't see why |
Currently, when aggregation is done, an error is thrown regarding the Satterthwaite / Kenward-Roger degrees of freedom.
It is my understanding that this is because these d.f. are obtained via
insight::get_df(model, data = newdata, type = vcov, df_per_observation = TRUE)
, returning one d.f. per-row ofnewdata
.The way
{emmeans}
deals with cases were the d.f.s aren't directly estimatable vialmerTest::calcSatterth()
orpbkrtest::Lb_ddf()
(such as when non-linear transformations are applied) is to take the smallest d.f. for the aggregated group:https://github.com/rvlenth/emmeans/blob/495ed3ac04bb494e41dba053dbdf299e8e093605/R/emmGrid-methods.R#L971-L972
Would this possibly be applicable here as well?
The text was updated successfully, but these errors were encountered: