| pm_slopes | R Documentation |
The slope (rate of change) of the fitted response in a numeric covariate within each level of a model term, with
standard errors, degrees of freedom, confidence limits and tests, and pairwise comparisons of the slopes, as
emmeans::emtrends() and SAS ESTIMATE statements on slope terms.
pm_slopes(model, covariate, modelterm, at = NULL, conf_level = 0.95, adj = "none",
df_method = c("auto", "Kenward-Roger", "Satterthwaite", "containment",
"between-within", "KR-expected", "KR-average", "inner-outer", "residual"),
vcov_adjust = TRUE,
weights = c("equal", "proportional", "outer", "cells", "flat"),
vcov = NULL, ...)
model |
A fitted model, as for |
covariate |
Name (in "quotes") of the numeric covariate. |
modelterm |
Name (in "quotes") of the factor term whose levels get a slope each, e.g. |
at |
The value of the covariate where the slopes are taken (matters only when the covariate enters the model non-linearly); the default is its mean. |
conf_level |
Confidence level of the limits, the default is 0.95 ( |
adj |
Adjustment of the p-values of the pairwise comparisons of slopes, as in |
df_method, vcov_adjust, weights, vcov |
As in |
... |
Not used: |
The slopes are on the scale of the linear predictor. They come from the reference grid of Kmatrix:
the change in the K matrix between at - h and at + h, divided by 2h with h = 0.0001 times
the standard deviation of the covariate. This is exact when the covariate enters the model linearly (also through
interactions) and a central difference for poly(), splines and smooths, whose slope depends on at.
Standard errors and degrees of freedom follow predictmeans: for models fitted by REML (lmer,
lme, gls) Kenward-Roger (with the adjusted covariance when vcov_adjust = TRUE); with one df per
term (containment, between-within, nlme's df) the smallest df of the terms with the covariate; otherwise the
residual df.
An object of class "pm_slopes", a list in the layout of predictmeans (tidy() and
as.data.frame() return its tables, what = "slopes" or "pairs"):
slopes |
one row per level of |
pairs |
one row per pair of levels: |
settings |
|
Dongwen Luo, Siva Ganesh and John Koolaard
covariatemeans, predictmeans, advice
library(predictmeans)
Oats <- as.data.frame(nlme::Oats)
fm <- lmer(yield ~ nitro*Variety + (1|Block/Variety), data = Oats)
sl <- pm_slopes(fm, "nitro", "Variety", adj = "tukey")
sl
as.data.frame(sl, what = "pairs")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.