Description Usage Arguments Value Author(s) References Examples
View source: R/simple_slopes.R
Computes simple slopes for objects fit with
the class "lm"
1 2 3 4 5 6 7 8 | simple_slopes(
fit,
variable1name,
variable1values = NULL,
variable2name,
variable2values = NULL,
plot_slopes = TRUE
)
|
fit |
|
variable1name |
Character.
Name of the first variable in interaction from |
variable1values |
Numeric.
Values to be used when first variable is the moderator.
If |
variable2name |
Character.
Name of the second variable in interaction from |
variable2values |
Numeric.
Values to be used when second variable is the moderator.
If |
plot_slopes |
Boolean.
Should simple slopes be plotted?
Defaults to |
Returns a list containing:
fit |
Returns |
results |
Data frame with variable, moderator, values of moderator betas of simple slopes, t values, p-values, and significance level |
parameters |
A list containing degrees of freedom ( |
plot_args |
Internal use only. Arguments for plots |
Alexander Christensen <alexpaulchristensen@gmail.com>
Preacher, K. J., Curran, P. J., & Bauer, D. J. (2006). Computational tools for probing interactions in multiple linear regression, multilevel modeling, and latent curve analysis. Journal of Educational and Behavioral Statistics, 31(4), 437-448.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | # Generate data
df <- data.frame(
y = rnorm(100),
x1 = rnorm(100),
x2 = rnorm(100)
)
# Estimate linear model
fit <- lm(y ~ x1 * x2, data = df)
# Estimate simple slopes
simple_slopes(
fit = fit,
variable1name = "x1", # must be name as it appears in 'fit' object
variable2name = "x2", # must be name as it appears in 'fit' object
plot = TRUE
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.