[R-sig-ME] Use of pbkrtest to calculate Kenward-Roger approximated degrees of freedom

Joshua Rosenberg jmichaelrosenberg at gmail.com
Tue Dec 26 17:38:05 CET 2017


Hi all, in case any others find this useful, here's the approach I've
pursued, borrowing from the source code for the summary() method function
in lmerTest:

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)

On Thu, Dec 21, 2017 at 9:51 AM Joshua Rosenberg <
jmichaelrosenberg at gmail.com> wrote:

> Hi everyone,
>
> I'm trying to use the pbkrtest package to calculate Kenward-Roger
> approximation degrees of freedom for fixed effects coefficients estimated
> using the lmer() function from the lme4 package.
>
> I've been able to use, for example, the function pbkrtest::get_Lb_ddf().
> Here is how I am using it:
>
> library(lme4)
> library(pbkrtest)
> fm1 <- lmer(Reaction ~ Days + (Days| Subject), sleepstudy)
> get_Lb_ddf(fm1, lme4::fixef(fm1))
>
>
> My understanding is that this function returns the "denominator degrees of
> freedom," which, if I understand correctly, apply to the *overall model*,
> rather to specific coefficients, in part because get_Lb_ddf() returns a
> single value whether there are coefficients associated with zero, one, or
> more than one predictors. I
>
> 'm sorry if this is a novice question with respect to calculating degrees
> of freedom in general (and calculating them with this, Kenward-Roger,
> approach)! Thanks for any thoughts or suggestions for how to think about
> calculating degrees of freedom using this - or another, better - approach.
>
> Josh
>
>
> --
> Joshua Rosenberg, Ph.D. Candidate
> Educational Psychology
> &
>  Educational Technology
> Michigan State University
> http://jmichaelrosenberg.com
>
-- 
Joshua Rosenberg, Ph.D. Candidate
Educational Psychology ​&​ Educational Technology
Michigan State University
http://jmichaelrosenberg.com

	[[alternative HTML version deleted]]



More information about the R-sig-mixed-models mailing list