user151310
user151310

Reputation: 1

lsmeans package - Kenward-Roger df adjusment for F-tests

I have looked into the lsmeans package in R. The package description states than if the pbkrtest package is installed, then for lme4 objects the degrees of freedom for F-tests are adjusted according to Kenward and Roger. However, with the pbkrtest package installed and loaded, the degrees of freedom are still the default ones (asymptotic):

Example:

require(lsmeans)
require(nlme)
require(pbkrtest)

Oats.lme <- lme(yield ~ factor(nitro) + Variety, random = ~1 | Block/Variety,
    subset = -c(1,2,3,5,8,13,21,34,55), data = Oats)
lsmeans(Oats.lme, list(poly ~ nitro, pairwise ~ Variety))

Output:

$`lsmeans of nitro`
 nitro    lsmean       SE df asymp.LCL asymp.UCL
   0.0  78.89205 7.280578 NA  64.62065  93.16344
   0.2  97.03422 7.128674 NA  83.06058 111.00785
   0.4 114.19813 7.128853 NA 100.22415 128.17212
   0.6 124.06857 7.067271 NA 110.21529 137.92184

...

P values are asymptotic

...

I am using R version 3.02 and the packages are freshly installed.

packageVersion("lsmeans")
[1] '2.0.4'

Upvotes: 0

Views: 2272

Answers (1)

Ben Bolker
Ben Bolker

Reputation: 226097

?lsmeans states (emphasis added)

For models fitted using the ‘lme4’ package, degrees of freedom are obtained using the Kenward-Roger (1997) method as implemented in the package ‘pbkrtest’, if it is installed. If ‘pbkrtest’ is not installed, the degrees of freedom are set to ‘NA’ and asymptotic results are displayed.

That means you have to use lme4::lmer, not nlme::lme, to fit your model.

require(lsmeans)
require(lme4)
require(pbkrtest)

Oats.lmer <- lmer(yield ~ factor(nitro) + Variety+
            (1 | Block/Variety),
     subset = -c(1,2,3,5,8,13,21,34,55), data = Oats)
lsmeans(Oats.lmer, list(poly ~ nitro, pairwise ~ Variety))

The results do have adjusted df:

## $`lsmeans of nitro`
##  nitro    lsmean       SE   df  lower.CL  upper.CL
##    0.0  78.89207 7.294379 7.78  61.98930  95.79484
##    0.2  97.03425 7.136271 7.19  80.25029 113.81822
##    0.4 114.19816 7.136186 7.19  97.41454 130.98179
##    0.6 124.06857 7.070235 6.95 107.32795 140.80919

Upvotes: 4

Related Questions