Learn R Programming

lmerTest (version 2.0-33)

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, fixed.calc = TRUE, lsmeans.calc = TRUE,
difflsmeans.calc = TRUE, test.effs = NULL,  keep.effs = NULL, ...)

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

fixed.calc

logical for whether the calculation of the table for fixed effects is needed. If FALSE then only the analysis of random effects is done

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.

keep.effs

charachter vector specifying the names of terms to be kept in the model even if being non-significant

other potential arguments.

Value

rand.table

data frame with value of Chi square statistics, p-values for the likelihood ratio test for random effects

anova.table

data frame with tests for whether the model fixed terms are significant (Analysis of Variance)

lsmeans.table

Least Squares Means data frame with p-values and Confidence intervals

diffs.lsmeans.table

Differences of Least Squares Means data frame with p-values and Confidence intervals

model

Final 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. The step function of lmerTest overrides the one from stats package for lm objects. So if the lmerTest is attached and one wants to call step fof lm object, then needs to use stats::step

See Also

rand, lsmeans, difflsmeans

Examples

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

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

m <- lmer(Coloursaturation ~ TVset*Picture+
(1|Assessor)+(1|Assessor:TVset), data=TVbo)

step(m, keep.effs = "Assessor")

# }
# NOT RUN {


# }
# NOT RUN {
<!-- % Add one or more standard keywords, see file 'KEYWORDS' in the -->
# }
# NOT RUN {
<!-- % R documentation directory. -->
# }
# NOT RUN {
<!-- %\keyword{ ~kwd1 } -->
# }
# NOT RUN {
<!-- %\keyword{ ~kwd2 }% __ONLY ONE__ keyword per line -->
# }

Run the code above in your browser using DataLab