sat-modcomp.Rd
An approximate F-test based on the Satterthwaite approach.
An lmerMod
model.
An lmerMod
model, a restriction matrix or
a model formula. See example section.
If larger than 0 some timing details are printed.
A small number.
Notice: It cannot be guaranteed that the results agree with other implementations of the Satterthwaite approach!
Ulrich Halekoh, Søren Højsgaard (2014)., A Kenward-Roger Approximation and Parametric Bootstrap Methods for Tests in Linear Mixed Models - The R Package pbkrtest., Journal of Statistical Software, 58(10), 1-30., https://www.jstatsoft.org/v59/i09/
(fm1 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy))
#> Linear mixed model fit by REML ['lmerMod']
#> Formula: Reaction ~ Days + (Days | Subject)
#> Data: sleepstudy
#> REML criterion at convergence: 1743.628
#> Random effects:
#> Groups Name Std.Dev. Corr
#> Subject (Intercept) 24.741
#> Days 5.922 0.07
#> Residual 25.592
#> Number of obs: 180, groups: Subject, 18
#> Fixed Effects:
#> (Intercept) Days
#> 251.41 10.47
L1 <- cbind(0,1)
SATmodcomp(fm1, L1)
#> large : Reaction ~ Days + (Days | Subject)
#> <environment: 0x7fd3a2df0dd8>
#> small (restriction matrix) :
#>
#> 0 1
#> statistic ndf ddf p.value
#> [1,] 45.853 1.000 17 3.264e-06 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(fm2 <- lmer(Reaction ~ Days + I(Days^2) + (Days|Subject), sleepstudy))
#> Linear mixed model fit by REML ['lmerMod']
#> Formula: Reaction ~ Days + I(Days^2) + (Days | Subject)
#> Data: sleepstudy
#> REML criterion at convergence: 1742.816
#> Random effects:
#> Groups Name Std.Dev. Corr
#> Subject (Intercept) 24.761
#> Days 5.925 0.06
#> Residual 25.534
#> Number of obs: 180, groups: Subject, 18
#> Fixed Effects:
#> (Intercept) Days I(Days^2)
#> 255.449 7.434 0.337
## Test for no effect of Days. There are three ways of using the function:
## 1) Define 2-df contrast - since L has 2 (linearly independent) rows
## the F-test is on 2 (numerator) df:
L2 <- rbind(c(0, 1, 0), c(0, 0, 1))
SATmodcomp(fm2, L2)
#> large : Reaction ~ Days + I(Days^2) + (Days | Subject)
#> <environment: 0x7fd3a2df0dd8>
#> small (restriction matrix) :
#>
#> 0 1 0
#> 0 0 1
#> statistic ndf ddf p.value
#> [1,] 23.754 2.000 51.563 4.876e-08 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
## 2) Use two model objects
fm3 <- update(fm2, ~. - Days - I(Days^2))
SATmodcomp(fm2, fm3)
#> large : Reaction ~ Days + I(Days^2) + (Days | Subject)
#> <environment: 0x7fd3a2df0dd8>
#> small (restriction matrix) :
#>
#> 0 0.1104315 0.9938837
#> 0 -0.9938837 0.1104315
#> statistic ndf ddf p.value
#> [1,] 23.754 2.000 51.563 4.876e-08 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
## 3) Specify restriction as formula
SATmodcomp(fm2, ~. - Days - I(Days^2))
#> large : Reaction ~ Days + I(Days^2) + (Days | Subject)
#> <environment: 0x7fd3a2df0dd8>
#> small (restriction matrix) :
#>
#> 0 0.1104315 0.9938837
#> 0 -0.9938837 0.1104315
#> statistic ndf ddf p.value
#> [1,] 23.754 2.000 51.563 4.876e-08 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1