Description Usage Arguments Details Value Author(s) Examples
For a linear model with one factor variable, one covariate, and a factor-covariate interaction, simultaneous confidence intervals for user-defined treatment contrasts are computed for a set of pre-specified covariate values. scitreatcov
compares treatments in terms of differences, codesciratiotreatcov compares treatments in terms of ratios.
1 2 3 4 5 6 7 | scitreatcov(response, treatment, covariate, data,
covset = NULL, nocov = 10, treatcon = "Dunnett",
conf.level = 0.95, alternative = "two.sided", ...)
sciratiotreatcov(response, treatment, covariate, data,
covset = NULL, nocov = 10, treatcon = "Dunnett",
conf.level = 0.95, alternative = "two.sided", ...)
|
response |
a single character string, naming the variable in the data set, containg the numeric response |
treatment |
a single character string, naming the variable in the data set, containg the factor variable |
covariate |
a single character string, naming the variable in the data set, containg the numeric covariate |
data |
the data set (a |
covset |
a numeric vector, containing the values of the covariate for which treatment comparisons should be performed |
nocov |
a single integer, defines the number of covariate values starting from |
treatcon |
either a matrix with numeric entries, or a single character string; if a matrix: number of columns must be = number of treatment levels in the factor variable, rows should specify contrasts between treatments. If a character string: the character string is passed to the |
conf.level |
a single numeric value ]0;1[, the simultaneous confidence level |
alternative |
one of "two.sided", "less" (upper limits only), "greater" (lower limits only) |
... |
arguments to be passed to other functions. Currently, in both functions:
|
The functions fit a linear model (using lm
) of the form response ~ 0 + treatment + treatment:covariate
. It constructs a suitable contrast matrix to compute simultaneous confidence intervals (sci) for multiple treatment comparisons (as defined in treatcon
) for the covariate vales defined by covset
or nocov
. scitreatcov
computes sci for differences using function glht
and confint.glht
, package multcomp
. sciratiotreatcov
computes sci for differences using function gsci.ratio
in package mratios
.
a list with elements:
sci |
a |
model.fit |
the linear model fit |
glht |
the object returned by |
treatmentcontrasts |
the matrix defining the contrasts between treatments |
covset |
numeric vector with the covariate values used |
alternative |
as input |
conf.level |
as input |
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 | if(require("MASS")){
data(anorexia, package="MASS")
anova(lm(Postwt ~ Treat*Prewt, data=anorexia))
dscian <- scitreatcov(response="Postwt", treatment="Treat",
covariate="Prewt", data=anorexia, covset=seq(from=75, to=95, by=5),
treatcon="Tukey", conf.level=0.95)
str(dscian)
ggplot(dscian$sci, aes(x=covariate, y=Estimate, ymin=lwr, ymax=upr)) +
geom_errorbar(width=1) + geom_line() + geom_point(shape=15) +
facet_grid(.~comparison) + xlab("Preweight") +
ylab("Difference in expected postweight") + geom_hline(yintercept=0)
}
# for ratios, :
if(require("MASS")){
data(anorexia, package="MASS")
dscianr <- sciratiotreatcov(response="Postwt", treatment="Treat",
covariate="Prewt", data=anorexia, covset=seq(from=75, to=95, by=5),
treatcon="Tukey", conf.level=0.95)
str(dscianr, max.level=1)
str(dscianr$sci)
ggplot(dscianr$sci, aes(x=covariate, y=estimate, ymin=lower, ymax=upper)) +
geom_errorbar(width=1) + geom_line() + geom_point(shape=15) +
facet_grid(.~comparison) + xlab("Preweight") +
ylab("Difference in expected postweight") + geom_hline(yintercept=1)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.