1
$\begingroup$

I am interested in calculating the degrees of freedom for predictor variables in mixed effects (or multi-level) models using the Kenward-Roger approximation (described in this paper here).

Using a function (get_Lb_ddf()) to "Get adjusted denomintor degress freedom for testing Lb=0 in a linear mixed model where L is a restriction matrix," I obtain one value.

My question is, Do these Kenward-Roger approximation degrees of freedom apply to all of the predictor variables in the model?

I ask, because, naïvely, it seems odd to me for a data-level and a group-level predictor, for example, to have the same degrees of freedom.

$\endgroup$
0
$\begingroup$

Based on how this is implemented in the lmerTest package (link https://cran.r-project.org/web/packages/lmerTest/index.html), each coefficient is associated with its own degrees of freedom. Here is a chunk of code to estimate them using the Kenward-Rogers approximation:

library(purrr)
library(lme4)
library(pbkrtest)

fm1 <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy)

get_kr_df <- function(model_object) {
    L <- diag(rep(1, length(fixef(model_object))))
    L <- as.data.frame(L)
    out <- purrr::map_dbl(L, pbkrtest::get_Lb_ddf, object = model_object)
    names(out) <- names(fixef(model_object))
    out
}

get_kr_df(m1)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.