| tidy.predictmeans | R Documentation |
Return the means or pairs table of a predictmeans result (glance(): one row describing it). The tables have fixed column
names (see the Value section of predictmeans) and unrounded values, which makes them easy to use in
further analysis, reports, Shiny apps or AI tools. tidy() is the generic from package generics (also
used by broom); as.data.frame() needs no other package.
coef() and vcov() return the means (on the model scale, as in the estimate column) and
their covariance matrix (Kenward-Roger adjusted when the means are), named by the mean labels. With them,
multcomp::glht() or marginaleffects::hypotheses() can test any contrast of the means, e.g.
hypotheses(pm, hypothesis = "n2 - n0 = 0") (normal-based). Recent versions of marginaleffects need
the class listed first: options(marginaleffects_model_classes = "predictmeans").
## S3 method for class 'predictmeans'
tidy(x, what = c("means", "pairs"), ...)
## S3 method for class 'predictmeans'
glance(x, ...)
## S3 method for class 'predictmeans'
as.data.frame(x, row.names = NULL, optional = FALSE,
what = c("means", "pairs"), ...)
## S3 method for class 'predictmeans'
coef(object, ...)
## S3 method for class 'predictmeans'
vcov(object, ...)
x |
A result of |
object |
A result of |
what |
Which table: |
row.names |
Optional row names for the result. |
optional |
Not used. |
... |
Not used. |
A data frame; for coef() a named vector and for vcov() a matrix. glance() gives one row:
modelterm, n.means, n.pairs, nobs (observations in the cells), df.method,
adjust, level, vcov, vcov.adjust, sed.min, sed.mean, sed.max
(standard errors of the differences), lsd.mean, nperm and model.class.
Dongwen Luo, Siva Ganesh and John Koolaard
predictmeans, autoplot.predictmeans, advice
library(predictmeans)
Oats <- as.data.frame(nlme::Oats)
Oats$nitro <- factor(Oats$nitro)
fm <- lmer(yield ~ nitro*Variety + (1|Block/Variety), data = Oats)
pm <- predictmeans(fm, "nitro:Variety", atvar = "Variety", adj = "tukey")
as.data.frame(pm)
head(as.data.frame(pm, what = "pairs"))
if (requireNamespace("generics", quietly = TRUE)) generics::glance(pm)
# Any contrast of the means from coef() and vcov(): Victory - Golden Rain at nitro 0.6
b <- coef(pm)
L <- (names(b) == "0.6:Victory") - (names(b) == "0.6:Golden Rain")
c(estimate = sum(L*b), SE = sqrt(drop(L %*% vcov(pm) %*% L)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.