Learn R Programming

reghelper (version 0.3.3)

simple_slopes.lme: Simple slopes of interaction.

Description

simple_slopes.lme calculates all the simple effects of an interaction in a regression model.

Usage

# S3 method for lme
simple_slopes(model, levels = NULL, ...)

Arguments

model

A fitted linear model of type 'lme' with at least one interaction term.

levels

A list with element names corresponding to some or all of the variables in the model. Each list element should be a vector with the names of factor levels (for categorical variables) or numeric values (for continuous variables) at which to test that variable. Note: If you do not include 'sstest' as one of these levels, the function will not test the simple effects for that variable.

...

Not currently implemented; used to ensure consistency with S3 generic.

Value

A data frame with a row for each simple effect. The first few columns identify the level at which each variable in your model was set for that test. A 'sstest' value in a particular column indicates that this was the variable being tested. After columns for each variable, the data frame has columns for the slope of the test variable, the standard error, t-value, p-value, and degrees of freedom for the model.

Details

If the model includes interactions at different levels (e.g., three two-way interactions and one three-way interaction), the function will test the simple effects of the highest-order interaction. If there are multiple interactions in the highest order, it will test the first one in the model. If you wish to test simple effects for a different interaction, simply switch the order in the formula.

By default, this function will provide slopes at -1SD, the mean, and +1SD for continuous variables, and at each level of categorical variables. This can be overridden with the levels parameter.

If a categorical variable with more than two levels is being tested, you may see multiple rows for that test. One row will be shown for each contrast for that variable; the order is in the same order shown in contrasts().

See Also

simple_slopes.lm, simple_slopes.glm, simple_slopes.merMod

Examples

Run this code
# NOT RUN {
# iris data
if (require(nlme, quietly=TRUE)) {
    model <- lme(Sepal.Width ~ Sepal.Length * Petal.Length, random=~1|Species, data=iris)
    summary(model)  # significant interaction
    simple_slopes(model)
    simple_slopes(model,
        levels=list(Sepal.Length=c(4, 5, 6, 'sstest'),
        Petal.Length=c(2, 3, 'sstest')))  # test at specific levels
}
# }

Run the code above in your browser using DataLab