Learn R Programming

lmerTest (version 2.0-6)

step: Performs backward elimination of non-significant effects of linear mixed effects model:

Description

performs automatic backward elimination of all effects of linear mixed effect model. First backward elimination of the random part is performed following by backward elimination of the fixed part. Finally LSMEANS (population means) and differences of LSMEANS for the fixed part of the model are calculated and the final model is provided. The p-values for the fixed effects are calculated from F test based on Sattethwaite's or Kenward-Roger approximation), p-values for the random effects are based on likelihood ratio test. All analysis may be performed on lmer object of lme4 package.

Usage

step(model, ddf="Satterthwaite", type=3, alpha.random = 0.1, alpha.fixed = 0.05, 
reduce.fixed = TRUE, reduce.random = TRUE, lsmeans.calc=TRUE,
difflsmeans.calc=TRUE, test.effs=NULL, method.grad="simple",  ...)

Arguments

model
linear mixed effects model (lmer object).
ddf
approximation for denominator degrees of freedom. By default Satterthwaite's approximation. ddf="Kenward-Roger"" calculates Kenward-Roger approximation
type
type of hypothesis to be tested (SAS notation). Either type=1 or type=3.
alpha.random
significance level for elimination of the random part (for LRT test)
alpha.fixed
significance level for elimination of the fixed part (for F test and t-test for least squares means)
reduce.fixed
logical for whether the reduction of the fixed part is required
reduce.random
logical for whether the reduction of the random part is required
lsmeans.calc
logical for whether the calculation of LSMEANS(population means) is required
difflsmeans.calc
logical for whether the calculation of differences of LSMEANS is required
test.effs
charachter vector specifying the names of terms to be tested in LSMEANS. If NULL all the terms are tested. If lsmeans.calc==FALSE then LSMEANS are not calculated.
method.grad
approximation method for the grad function, which is used in calculation of denominator degrees of freedom. Could be "simple" or "Richardson". "simple" is the default one.
...
other potential arguments.

Value

  • rand.tabledata frame with value of Chi square statistics, p-values for the likelihood ratio test for random effects
  • anova.tabledata frame with tests for whether the model fixed terms are significant (Analysis of Variance)
  • lsmeans.tableLeast Squares Means data frame with p-values and Confidence intervals
  • diffs.lsmeans.tableDifferences of Least Squares Means data frame with p-values and Confidence intervals
  • modelFinal model - object of merLmerTest(contains mer class) or gls (after all the required reduction has been performed)

Details

Elimination of all effects is done one at a time. Elimination of the fixed part is done by the principle of marginality that is: the highest order interactions are tested first: if they are significant, the lower order effects are not tested for significance.

See Also

rand, lsmeans, difflsmeans

Examples

Run this code
#import lme4 package and lmerTest package
library(lmerTest)

m <- lmer(Informed.liking ~ Product*Information*Gender+ 
(1|Consumer) + (1|Product:Consumer), data=ham)


#elimination of non-significant effects
s <- step(m)

#plot of post-hoc analysis of the final model
plot(s)

Run the code above in your browser using DataLab