R: Performs backward elimination of non-significant effects of...

step {lmerTest} | R Documentation

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

### 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

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

### Note

For the random coefficient models: in the random part if correlation is present between slope and intercept, then the simplified model will contain just an intercept. That is if the random part of the initial model is `(1+c|f)`, then this model is compared to `(1|f)` by using LRT. If there are multiple slopes, then the the slope with the highest `p`-value (and higher then alpha level) is eliminated. That is if the random part of the initial model has the following form `(1+c1+c2|f)`, then two simplified models are constracted and compared to the initial one: the first one has `(1+c1|f)` in the random part and the second one has: `(1+c2|f)`.

### Author(s)

Alexandra Kuznetsova, Per Bruun Brockhoff, Rune Haubo Bojesen Christensen

### See Also

`rand`, `lsmeans`, `difflsmeans`

### Examples

    #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")

    ## End(Not run)

[Package lmerTest version 2.0-33 Index]