View source: R/contrastmeans.R
contrastmeans | R Documentation |
Performs t-tests (or permuted t-tests) of specified contrasts for linear models
obtained from functions aov
, lm
, glm
, gls
, lme
,
or lmer
.
contrastmeans(model, modelterm, ctrmatrix, ctrnames=NULL, adj="none", Df, permlist)
model |
Model object returned by |
modelterm |
Name (in "quotes") for indicating which factor term's contrast to be calculated.
The |
ctrmatrix |
A specified contrast matrix. If |
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", "tukey", "holm", "hochberg", "hommel", "bonferroni", "BH", "BY" and "fdr". The default method is "none". |
Df |
A denominator degree of freedom for |
permlist |
A model parameter list containing |
There are two components in the output which are
Table |
A table showing t-test results for the specified linear contrasts. |
K |
A contrast matrix. |
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.
library(predictmeans)
# ftable(xtabs(yield ~ Block+Variety+nitro, data=Oats))
Oats$nitro <- factor(Oats$nitro)
fm <- lme(yield ~ nitro*Variety, random=~1|Block/Variety, data=Oats)
# library(lme4)
# fm <- lmer(yield ~ nitro*Variety+(1|Block/Variety), data=Oats)
## Not run:
## The contrast has a contrast matrix as follows:
# 0:Golden Rain 0:Marvellous 0:Victory
#[1,] -1 0 1
#[2,] 0 0 1
# 0.2:Golden Rain 0.2:Marvellous 0.2:Victory
#[1,] 0 0 0
#[2,] 0 0 0
# 0.4:Golden Rain 0.4:Marvellous 0.4:Victory
#[1,] 0 0 0
#[2,] 0 -1 0
# 0.6:Golden Rain 0.6:Marvellous 0.6:Victory
#[1,] 0 0 0
#[2,] 0 0 0
# 1. Enter above contrast matrix into a pop up window, then close the window
# contrastmeans(fm, "nitro:Variety")
# 2. Construct the contrast matrix directly
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.