View source: R/contrastmeans.R
| contrastmeans | R Documentation |
t tests (or permutation t tests) of given contrasts among the predicted means of a model term, for the
models of predictmeans (aov, lm, glm, gls, lme, lmer,
glmer, glmmTMB, gam).
contrastmeans(model, modelterm, ctrmatrix, ctrnames=NULL, adj="none", permlist,
vcov_adjust=TRUE,
weights=c("equal", "proportional", "outer", "cells", "flat"),
df_method=c("auto", "Kenward-Roger", "Satterthwaite", "containment",
"between-within", "KR-expected", "KR-average", "inner-outer", "residual"),
joint=FALSE, conf_level=0.95, vcov=NULL, equivalence=NULL, ...)
model |
A fitted model, as for |
modelterm |
Name (in "quotes") for indicating which factor term's contrast to be calculated.
The |
ctrmatrix |
A specified contrast matrix. If it is missing, an edit window asks for it (interactive sessions only). The columns can be named by level (e.g. from |
ctrnames |
Names of the specified contrasts, e.g. c("A vs D", "C vs B", ...) |
adj |
Name (in "quote") for indicating a method for adjusting p-values of pairwise comparisons.
The choices are "none", "holm", "hochberg", "hommel", "bonferroni", "BH", "BY", "fdr", "sidak", "scheffe",
"mvt" and "westfall", in any letter case. "sidak", "scheffe" (rank of |
permlist |
A list from |
vcov_adjust |
For models fitted by REML ( |
weights |
Passed to |
df_method |
Denominator df, by method or as one number (a fixed df, |
joint |
Logical: also test all the contrasts together (all of them zero), as |
conf_level |
Confidence level of the limits of the contrasts ( |
vcov |
Optional covariance of the coefficients to use instead of the model's. For |
equivalence |
Optional equivalence margins for equivalence tests (two one-sided t tests, TOST) of the
contrasts: a positive number |
... |
Not used: arguments removed in 2.0 ( |
An object of class "contrastmeans", a list. print() shows the contrasts, tidy() and
as.data.frame() return the table contrasts (what = "joint": the joint test). Its first
components are those of 1.x:
The t tests of the specified contrasts |
A table (rounded to 4 decimals) of the t tests of the contrasts,
with the adjusted p-value in |
K |
A contrast matrix. |
Joint F test of the contrasts |
With |
and then the tables in the layout of predictmeans, unrounded:
contrasts |
One row per contrast: |
joint |
With |
settings |
|
Dongwen Luo, Siva Ganesh and John Koolaard
Torsten Hothorn, Frank Bretz and Peter Westfall (2008), Simultaneous Inference in General Parametric Models. Biometrical, Journal 50(3), 346–363.
specify_contrast, contrast_family, pm_joint, predictmeans, tidy.predictmeans, advice
library(predictmeans)
Oats$nitro <- factor(Oats$nitro)
fm <- lme(yield ~ nitro*Variety, random=~1|Block/Variety, data=Oats)
# 1. Enter a contrast matrix in an edit window (interactive sessions only)
if (interactive()) contrastmeans(fm, "nitro:Variety")
# 2. Give the contrast matrix: Victory - Golden Rain at nitro 0, Victory at 0 - Marvellous at 0.4
cm <- rbind(c(-1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0),
c(0, 0, 1, 0, 0, 0, 0, -1, 0, 0, 0, 0))
contrastmeans(fm, "nitro:Variety", ctrmatrix=cm)
# 3. ... and both contrasts tested together (an F test with 2 numerator df)
ct <- contrastmeans(fm, "nitro:Variety", ctrmatrix=cm, joint=TRUE)
ct
as.data.frame(ct)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.