Backward elimination of random-effect terms followed by backward elimination of fixed-effect terms in linear mixed models.
a fitted model object. For the lmerModLmerTest method
an lmer model fit (of class "lmerModLmerTest".)
the method for computing the denominator degrees of freedom and
F-statistics. ddf="Satterthwaite" (default) uses Satterthwaite's method;
ddf="Kenward-Roger" uses Kenward-Roger's method.
alpha for random effects elimination
alpha for fixed effects elimination
reduce fixed effect structure? TRUE by default.
reduce random effect structure? TRUE by default.
an optional character vector of fixed effect terms which should
not be considered for eliminated. Valid terms are given by
attr(terms(object), "term.labels"). Terms that are marginal to terms
in keep will also not be considered for eliminations.
currently not used.
a step object.
step returns a list with elements "random" and
"fixed" each
containing anova-like elimination tables. The "fixed" table is
based on drop1 and the "random" table is
based on ranova (a drop1-like table for random effects). Both
tables have a column "Eliminated" indicating the order in which terms
are eliminated from the model with zero (0) indicating that the term
is not eliminated from the model.
The step object also contains the final model as an attribute which
is extractable with get_model(<step_object>).
Tests of random-effects are performed using ranova (using
reduce.terms = TRUE) and tests of fixed-effects are performed using
drop1.
The step method for lmer fits has a print method.
# Fit a model to the ham dataset:
fm <- lmer(Informed.liking ~ Product*Information+
(1|Consumer) + (1|Product:Consumer)
+ (1|Information:Consumer), data=ham)
# Backward elimination using terms with default alpha-levels:
(step_res <- step(fm))
#> boundary (singular) fit: see help('isSingular')
#> Backward reduced random-effect table:
#>
#> Eliminated npar logLik AIC LRT Df Pr(>Chisq)
#> <none> 12 -1352.0 2728.1
#> (1 | Information:Consumer) 1 11 -1352.8 2727.5 1.444 1 0.22952
#> (1 | Consumer) 0 10 -1354.4 2728.7 3.184 1 0.07437
#> (1 | Product:Consumer) 0 10 -1435.0 2890.0 164.443 1 < 2e-16
#>
#> <none>
#> (1 | Information:Consumer)
#> (1 | Consumer) .
#> (1 | Product:Consumer) ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Backward reduced fixed-effect table:
#> Degrees of freedom method: Satterthwaite
#>
#> Eliminated Sum Sq Mean Sq NumDF DenDF F value Pr(>F)
#> Product:Information 1 10.3873 3.4624 3 320 2.0765 0.10321
#> Product 0 19.3466 6.4489 3 240 3.8291 0.01048 *
#> Information 0 6.5201 6.5201 1 323 3.8714 0.04997 *
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Model found:
#> Informed.liking ~ Product + Information + (1 | Consumer) + (1 | Product:Consumer)
final <- get_model(step_res)
anova(final)
#> Type III Analysis of Variance Table with Satterthwaite's method
#> Sum Sq Mean Sq NumDF DenDF F value Pr(>F)
#> Product 19.3466 6.4489 3 240 3.8291 0.01048 *
#> Information 6.5201 6.5201 1 323 3.8714 0.04997 *
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
if (FALSE) { # \dontrun{
# Fit 'big' model:
fm <- lmer(Informed.liking ~ Product*Information*Gender*Age +
+ (1|Consumer) + (1|Consumer:Product) +
(1|Consumer:Information), data=ham)
step_fm <- step(fm)
step_fm # Display elimination results
final_fm <- get_model(step_fm)
} # }