contrast {datana} | R Documentation |
Computes statistics for inference in a given contrast
Description
The function computes the statistics for inference in a given contrast, subject to a given significance level. Those statistics are as follows: estimated contrast, standard error of the contrast, and confidence interval of the contrast.
Usage
contrast(
model = model,
coef.cont = coef.cont,
grp.m = grp.m,
grp.n = grp.n,
alpha = 0.05,
full = TRUE
)
Arguments
model |
object containing the fitted model |
coef.cont |
vector with the coefficients to establish the contrasts |
grp.m |
a vector having the sample mean per each group, or level of the factor under study. |
grp.n |
a vector having the sample size per each group, or level of the factor under study. |
alpha |
is the significance level for building the confidence intervals. Default value is 0.05, which is 95% confidence level. |
full |
FALSE if want short output, TRUE for longer (i.e. more details). Default is TRUE. |
Details
The contrast is established based upon an already fitted statistical model that describe the relationship among variables. The significance level (alpha) is defined by the user, although by default has been set to 0.05, that is to say, a 95 statistical confidence.
Value
This function returns the above described statistics for a given contrast.
Author(s)
Christian Salas-Eljatib
References
Stage AR. 1963. A mathematical approach to polymorphic site index curves for Grand fir. Forest Science 9(2):167–180.
Examples
data(fertiliza)
table(fertiliza$treat)
means.trt <- tapply(fertiliza$volume,fertiliza$treat,mean);means.trt
sds.trt <- tapply(fertiliza$volume,fertiliza$treat,sd);sds.trt
ns.trt <- tapply(fertiliza$volume,fertiliza$treat,length);ns.trt
m1 <- lm(volume ~ treat, data=fertiliza)
anova(m1)
## Coefficients to be used in the contrast
#c1: (tmoA1-A2) - (tmoA3-A4)
C1.coeff <- c(0,1,1,-1,-1)
contrast(model=m1,C1.coeff,grp.m=means.trt,grp.n=ns.trt,alpha=0.1,full=TRUE)
contrast(model=m1,C1.coeff,grp.m=means.trt,grp.n=ns.trt,alpha=0.1,full=FALSE)
contrast(m1,C1.coeff,grp.m=means.trt,grp.n=ns.trt,alpha=0.05,full=TRUE)
contrast(m1,C1.coeff,grp.m=means.trt,grp.n=ns.trt)