scitreatcov: Simultaneous treatment comparisons for a set of pre-specifed...

Description Usage Arguments Details Value Author(s) Examples

Description

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.

Usage

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", ...)

Arguments

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 data.frame contaning the three variables above)

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 min(covariate) ending at max(covariate); ignored, if covset is specified

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 type-argument in contrMat (package multcomp), see ?contrMat for detail, for sciratiotreatcov, see contrMatRatio

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: base:a single integer indicating the control level, if treatcon is a character stringf, passed to contrMat, digits:a single integer, defining the number of visible non-zero digits when rounding covariate values in contrast names. In sciratiotreatcov: adjusted: logical, to be passed to gsci.ratio.All other arguments are ignored.

Details

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.

Value

a list with elements:

sci

a data.frame with columns: comparison (name of between-treatment comparisons); covariate (covariate values); estimate (point estimate of the contrast); lwr, upr lower and upper confidence limits

model.fit

the linear model fit

glht

the object returned by glht, packagemultcomp

treatmentcontrasts

the matrix defining the contrasts between treatments

covset

numeric vector with the covariate values used

alternative

as input

conf.level

as input

Author(s)

Frank Schaarschmidt

Examples

 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)

}

schaarschmidt/statintcov documentation built on May 29, 2019, 3:26 p.m.