Description Usage Arguments Details Value Author(s) Examples
Compute suitable contrast matrix for pairwise comparisons of treatment levels over grids of covariates given a fitted model object of class 'lm' or 'glm' Restricted to ONE factor variable and pairwise comparisons of treatments ("Dunnett", "Tukey", or user defined subsets of Tukey-type comparisons). More than one covariate, quadratic terms etc. are possible
1 |
modelfit |
a fitted model of class |
treatment |
a single character string, identifying the factor variable in the model |
treatcon |
either a matrix with integer entries, or a single character string. If a matrix: number of columns must be = number of treatment levels in the factor variable rows specifies contrasts between treatments: only coefficients 1,0,-1 are allowed, all contrasts must define pairwise treatment differences: if a character string: "Dunnett" or "Tukey", will be passed to the |
covset |
a named list with numeric vectors: names of list elements must be the names of the covariates in the model, vector in each element is supposed to contain the covariate values at which contrasts sould be computed |
... |
further arguments to be passed to internal functions, currently only:
|
Based on the call and data set in the model object, matrices are contructed that allow to compute predictions over the grid of covariate values specified in covset
and the factor variable specified in treatment
. These matrices are then combined to define pairwise differences between the levels in treatment, over the grid of covariate values. The pairwise differences can be defined in the argument treatcon
.
A list with items
linfct |
a matrix of linear combinations of the model parameters, for plugging into the |
datadiff |
a data set with names for the differences between treatment levels, the treatment levels contributing as minuend and subtrahend of the differences, and the covariate(s); rows of the data set are ordered as are the rows in the matrix |
Xpos |
model matrix for those predictions used as minuend to compute |
Xneg |
model matrix for those predictions used as subtrahend to compute |
datapos |
|
dataneg |
Frank Schaarschmidt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | # Data set simulated acc. to Milliken and Johnson (2002), see ?pc for details
data(pc)
# A model including treatment interaction with the quadratic term
fitpc<-lm(yield ~ x + I(x^2) + additive + additive:I(x^2), data=pc)
cmpc <- cmiacov(fitpc, treatment="additive",
covset=list("x" = seq(from=1, to=9, by=1)), treatcon="Dunnett")
str(cmpc)
# treatment interaction with the linear term
fitpclin<-lm(yield ~ x + I(x^2) + additive + additive:x, data=pc)
cmpclin <- cmiacov(fitpc, treatment="additive",
covset=list("x" = seq(from=1, to=9, by=1)), treatcon="Dunnett")
str(cmpclin)
# daphnids data from package drc
# no: counted no. of immobile daphnids
# mob: corresponding no. mobile daphnids
if(require("drc")){
data(daphnids, package="drc")
daphnids$mob <- daphnids$total - daphnids$no
daphnids$l10dose <- log10(daphnids$dose)
ggplot(daphnids, aes(y=no/total, x=l10dose)) + geom_point(aes(color=time))
fitda <- glm(cbind(no, mob) ~ time * l10dose, data=daphnids, family=quasibinomial())
anova(fitda, test="F")
cmda <- cmiacov(fitda, treatment="time",
covset=list("l10dose" = seq(from=2, to=4, by=0.5)), treatcon="Dunnett")
str(cmda, max.level=1)
cmda$linfct
confint(glht(fitda, linfct=cmda$linfct))
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.