Learn R Programming

lmerTest (version 3.1-3)

step.lmerModLmerTest: Backward Elimination for Linear Mixed Models

Description

Backward elimination of random-effect terms followed by backward elimination of fixed-effect terms in linear mixed models.

Usage

# S3 method for lmerModLmerTest
step(
  object,
  ddf = c("Satterthwaite", "Kenward-Roger"),
  alpha.random = 0.1,
  alpha.fixed = 0.05,
  reduce.fixed = TRUE,
  reduce.random = TRUE,
  keep,
  ...
)

# S3 method for step_list get_model(x, ...)

Arguments

object

a fitted model object. For the lmerModLmerTest method an lmer model fit (of class "lmerModLmerTest".)

ddf

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.random

alpha for random effects elimination

alpha.fixed

alpha for fixed effects elimination

reduce.fixed

reduce fixed effect structure? TRUE by default.

reduce.random

reduce random effect structure? TRUE by default.

keep

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.

x

a step object.

Value

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>).

Details

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.

See Also

drop1 for tests of marginal fixed-effect terms and ranova for a drop1-like table of reduction of random-effect terms.

Examples

Run this code
# NOT RUN {
# 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))
final <- get_model(step_res)
anova(final)

# }
# NOT RUN {
# 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)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab