View source: R/specify_contrast.R
| specify_contrast | R Documentation |
Build a contrast matrix for contrastmeans by writing each contrast as an expression in the level names
of a model term, so there is no need to count columns, even when some treatment combinations are missing.
Each level name (in backticks when it is not a syntactic name, e.g. `Wet:Bio`) stands for that mean.
specify_contrast(.x, ..., .zero_sum = TRUE)
.x |
A result of |
... |
Named expressions, one per contrast, e.g. |
.zero_sum |
If |
The arguments start with a dot so that contrasts can be given any name, including x.
A matrix with one row per contrast (named as given) and one column per level. Columns of levels that are not mentioned are zero. Means that cannot be estimated (e.g. missing cells) cannot be used.
Dongwen Luo, Siva Ganesh and John Koolaard
contrastmeans, contrast_family, pm_joint
library(predictmeans)
Oats <- as.data.frame(nlme::Oats)
Oats$nitro <- factor(Oats$nitro)
fm <- lmer(yield ~ nitro*Variety + (1|Block/Variety), data = Oats)
cm <- specify_contrast(Kmatrix(fm, "nitro:Variety"),
N_effect_Victory = `0.6:Victory` - `0:Victory`,
N_effect_vs_others = (`0.6:Victory` - `0:Victory`) -
((`0.6:Golden Rain` - `0:Golden Rain`) +
(`0.6:Marvellous` - `0:Marvellous`))/2)
contrastmeans(fm, "nitro:Variety", ctrmatrix = cm)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.