se.contrast(stats)
se.contrast()所属R语言包:stats
Standard Errors for Contrasts in Model Terms
对比的标准错误示范条款
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Returns the standard errors for one or more contrasts in an aov object.
返回aov对象中的一个或多个对比的标准误差。
用法----------Usage----------
se.contrast(object, ...)
## S3 method for class 'aov'
se.contrast(object, contrast.obj,
coef = contr.helmert(ncol(contrast))[, 1],
data = NULL, ...)
参数----------Arguments----------
参数:object
A suitable fit, usually from aov.
一个合适的契合,通常是从aov。
参数:contrast.obj
The contrasts for which standard errors are requested. This can be specified via a list or via a matrix. A single contrast can be specified by a list of logical vectors giving the cells to be contrasted. Multiple contrasts should be specified by a matrix, each column of which is a numerical contrast vector (summing to zero).
的对比标准误差要求。这可以通过列表或矩阵通过指定。给单元进行对比的逻辑向量,可以指定一个单一的对比。多对比应指定一个矩阵,其中的每一列是一个数字的对比向量(求和为零)。
参数:coef
used when contrast.obj is a list; it should be a vector of the same length as the list with zero sum. The default value is the first Helmert contrast, which contrasts the first and second cell means specified by the list.
时使用contrast.obj是一个列表,它应该是一个零和列表的长度相同的向量。默认值是第一个的赫尔默特对比,对比第一和第二单元列表中指定的。
参数:data
The data frame used to evaluate contrast.obj.
数据框用于评估contrast.obj。
参数:...
further arguments passed to or from other methods.
通过进一步的论据或其他方法。
Details
详情----------Details----------
Contrasts are usually used to test if certain means are significantly different; it can be easier to use se.contrast than compute them directly from the coefficients.
通常用于对比测试,如果某些手段有显着不同,它可以更容易使用se.contrast比系数直接计算。
In multistratum models, the contrasts can appear in more than one stratum, in which case the standard errors are computed in the lowest stratum and adjusted for efficiencies and comparisons between strata. (See the comments in the note in the help for aov about using orthogonal contrasts.) Such standard errors are often conservative.
在多段模型,对比可以出现在多个阶层,在这种情况下,标准的错误是在最低层的计算和调整效率和阶层之间的比较。 (见aov使用正交对比的帮助说明中的意见。)这样的标准误差往往是保守的。
Suitable matrices for use with coef can be found by calling contrasts and indexing the columns by a factor.
可以找到合适的矩阵使用coef调用contrasts和索引列的一个因素。
值----------Value----------
A vector giving the standard errors for each contrast.
A向量,让每个对比的标准误差。
参见----------See Also----------
contrasts, model.tables
contrasts,model.tables
举例----------Examples----------
## From Venables and Ripley (2002) p.165.[#从维纳布尔斯和Ripley(2002)第165页。]
N <- c(0,1,0,1,1,1,0,0,0,1,1,0,1,1,0,0,1,0,1,0,1,1,0,0)
P <- c(1,1,0,0,0,1,0,1,1,1,0,0,0,1,0,1,1,0,0,1,0,1,1,0)
K <- c(1,0,0,1,0,1,1,0,0,1,0,1,0,1,1,0,0,0,1,1,1,0,1,0)
yield <- c(49.5,62.8,46.8,57.0,59.8,58.5,55.5,56.0,62.8,55.8,69.5,
55.0, 62.0,48.8,45.5,44.2,52.0,51.5,49.8,48.8,57.2,59.0,53.2,56.0)
npk <- data.frame(block = gl(6,4), N = factor(N), P = factor(P),
K = factor(K), yield = yield)
## Set suitable contrasts.[#设置适当的反差。]
options(contrasts=c("contr.helmert", "contr.poly"))
npk.aov1 <- aov(yield ~ block + N + K, data=npk)
se.contrast(npk.aov1, list(N == "0", N == "1"), data=npk)
# or via a matrix[或通过一个矩阵]
cont <- matrix(c(-1,1), 2, 1, dimnames=list(NULL, "N"))
se.contrast(npk.aov1, cont[N, , drop=FALSE]/12, data=npk)
## test a multi-stratum model[#测试一个多阶层模型]
npk.aov2 <- aov(yield ~ N + K + Error(block/(N + K)), data=npk)
se.contrast(npk.aov2, list(N == "0", N == "1"))
## an example looking at an interaction contrast[#一个例子,在一个交互对比]
## Dataset from R.E. Kirk (1995)[#数据集从R.E.柯克(1995)]
## 'Experimental Design: procedures for the behavioral sciences'[#“实验设计:行为科学的程序”]
score <- c(12, 8,10, 6, 8, 4,10,12, 8, 6,10,14, 9, 7, 9, 5,11,12,
7,13, 9, 9, 5,11, 8, 7, 3, 8,12,10,13,14,19, 9,16,14)
A <- gl(2, 18, labels=c("a1", "a2"))
B <- rep(gl(3, 6, labels=c("b1", "b2", "b3")), 2)
fit <- aov(score ~ A*B)
cont <- c(1, -1)[A] * c(1, -1, 0)[B]
sum(cont) # 0[0]
sum(cont*score) # value of the contrast[值的对比]
se.contrast(fit, as.matrix(cont))
(t.stat <- sum(cont*score)/se.contrast(fit, as.matrix(cont)))
summary(fit, split=list(B=1:2), expand.split = TRUE)
## t.stat^2 is the F value on the A:B: C1 line (with Helmert contrasts)[#t.stat ^ 2是对A的F值:A:C1线(Helmert对比)]
## Now look at all three interaction contrasts[#现在看在所有三个互动对比]
cont <- c(1, -1)[A] * cbind(c(1, -1, 0), c(1, 0, -1), c(0, 1, -1))[B,]
se.contrast(fit, cont) # same, due to balance.[同样,由于平衡。]
rm(A,B,score)
## multi-stratum example where efficiencies play a role[#多阶层效率发挥作用的例子]
utils::example(eff.aovlist)
fit <- aov(Yield ~ A + B * C + Error(Block), data = aovdat)
cont1 <- c(-1, 1)[A]/32 # Helmert contrasts[Helmert对比]
cont2 <- c(-1, 1)[B] * c(-1, 1)[C]/32
cont <- cbind(A=cont1, BC=cont2)
colSums(cont*Yield) # values of the contrasts[值对比]
se.contrast(fit, as.matrix(cont))
## Not run: # comparison with lme[#无法运行:#与LME比较]
library(nlme)
fit2 <- lme(Yield ~ A + B*C, random = ~1 | Block, data = aovdat)
summary(fit2)$tTable # same estimates, similar (but smaller) se's.[估计相同,相似,但规模较小SE的。]
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|