nice_lm_slopes {rempsyc} | R Documentation |
Nice formatting of simple slopes for lm models
Description
Extracts simple slopes from lm()
model
object and format for a publication-ready format.
Usage
nice_lm_slopes(
model,
predictor,
moderator,
b.label = "b",
standardize = FALSE,
mod.id = TRUE,
ci.alternative = "two.sided",
...
)
Arguments
model |
The model to be formatted. |
predictor |
The independent variable. |
moderator |
The moderating variable. |
b.label |
What to rename the default "b" column (e.g.,
to capital B if using standardized data for it to be converted
to the Greek beta symbol in the |
standardize |
Logical, whether to standardize the
data before refitting the model. If |
mod.id |
Logical. Whether to display the model number, when there is more than one model. |
ci.alternative |
Alternative for the confidence interval of the sr2. It can be either "two.sided (the default in this package), "greater", or "less". |
... |
Further arguments to be passed to the |
Details
The effect size, sr2 (semi-partial correlation squared, also
known as delta R2), is computed through effectsize::r2_semipartial.
Please read the documentation for that function, especially regarding
the interpretation of the confidence interval. In rempsyc
, instead
of using the default one-sided alternative ("greater"), we use the
two-sided alternative.
To interpret the sr2, use effectsize::interpret_r2_semipartial()
.
For the easystats equivalent, use report::report()
on the lm()
model object.
Value
A formatted dataframe of the simple slopes of the specified lm model, with DV, levels of IV, degrees of freedom, regression coefficient, t-value, p-value, and the effect size, the semi-partial correlation squared, and its confidence interval.
See Also
Checking for moderation before checking simple slopes:
nice_lm
, nice_mod
,
nice_slopes
. Tutorial:
https://rempsyc.remi-theriault.com/articles/moderation
Examples
# Make and format model
model <- lm(mpg ~ gear * wt, mtcars)
nice_lm_slopes(model, predictor = "gear", moderator = "wt")
# Make and format multiple models
model2 <- lm(qsec ~ gear * wt, mtcars)
my.models <- list(model, model2)
x <- nice_lm_slopes(my.models, predictor = "gear", moderator = "wt")
x
# Get interpretations
cbind(x, Interpretation = effectsize::interpret_r2_semipartial(x$sr2))