找回密码
 注册
查看: 3125|回复: 0

R语言:contrast()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-2-16 21:01:46 | 显示全部楼层 |阅读模式
contrast(stats)
contrast()所属R语言包:stats

                                        (Possibly Sparse) Contrast Matrices
                                         (可能是稀疏的)对比矩阵

                                         译者:生物统计家园网 机器人LoveR

描述----------Description----------

Return a matrix of contrasts.
返回一个矩阵的对比。


用法----------Usage----------


contr.helmert(n, contrasts = TRUE, sparse = FALSE)
contr.poly(n, scores = 1:n, contrasts = TRUE, sparse = FALSE)
contr.sum(n, contrasts = TRUE, sparse = FALSE)
contr.treatment(n, base = 1, contrasts = TRUE, sparse = FALSE)
contr.SAS(n, contrasts = TRUE, sparse = FALSE)



参数----------Arguments----------

参数:n
a vector of levels for a factor, or the number of levels.
的一个因素,或层次水平的向量。


参数:contrasts
a logical indicating whether contrasts should be computed.
逻辑说明是否应计算对比。


参数:sparse
logical indicating if the result should be sparse (of class dgCMatrix), using package Matrix.
逻辑表示,如果结果应该是稀疏的(类dgCMatrix),使用包Matrix。


参数:scores
the set of values over which orthogonal polynomials are to be computed.
值超过正交多项式计算。


参数:base
an integer specifying which group is considered the baseline group. Ignored if contrasts is FALSE.
一个整数,指定这组被认为是基准组。如果contrasts是FALSE忽略。


Details

详情----------Details----------

These functions are used for creating contrast matrices for use in fitting analysis of variance and regression models.  The columns of the resulting matrices contain contrasts which can be used for coding a factor with n levels.  The returned value contains the computed contrasts.  If the argument contrasts is FALSE a square indicator matrix (the dummy coding) is returned except for contr.poly (which includes the 0-degree, i.e. constant, polynomial when contrasts = FALSE).
这些函数用于创建利用方差分析和回归模型的拟合分析对比矩阵。所产生的矩阵列包含编码n水平的一个因素,它可以用于对比。返回值包含计算的对比。如果参数contrasts是FALSE除了返回一个方形的指标矩阵(假人编码)contr.poly(其中包括0度,即常数,多项式contrasts = FALSE )。

contr.helmert returns Helmert contrasts, which contrast the second level with the first, the third with the average of the first two, and so on.  contr.poly returns contrasts based on orthogonal polynomials. contr.sum uses "sum to zero contrasts".
contr.helmert返回Helmert对比,对比第二级第一,第三,与前两个平均等。 contr.poly回报对比基于正交多项式。 contr.sum用途“的总和为零对比”。

contr.treatment contrasts each level with the baseline level (specified by base): the baseline level is omitted.  Note that this does not produce "contrasts" as defined in the standard theory for linear models as they are not orthogonal to the intercept.
contr.treatment对比每个级别与基准值(指定base):基线水平被省略。请注意,这不会产生“对比”定义为线性模型,在标准的理论,因为它们不是正交拦截。

contr.SAS is a wrapper for contr.treatment that sets the base level to be the last level of the factor.  The coefficients produced when using these contrasts should be equivalent to those produced by many (but not all) SAS procedures.
contr.SAScontr.treatment设置的基本水平,是最后一个级别的因素是包装。使用这些对比时产生的系数应该是相当于很多(但不是全部)的SAS程序产生的。

For consistency, sparse is an argument to all these contrast functions, however sparse = TRUE for contr.poly is typically pointless and is rarely useful for contr.helmert.
一致性,sparse是所有这些对比功能的参数,但是sparse = TRUEcontr.poly通常是毫无意义的,是很少有用contr.helmert。


值----------Value----------

A matrix with n rows and k columns, with k=n-1 if contrasts is TRUE and k=n if contrasts is FALSE.
一个矩阵n行k列k=n-1如果contrasts是TRUE和k=n如果contrasts是FALSE。


参考文献----------References----------

Statistical models. Chapter 2 of Statistical Models in S eds J. M. Chambers and T. J. Hastie, Wadsworth & Brooks/Cole.

参见----------See Also----------

contrasts, C, and aov, glm, lm.
contrasts,C,aov,glm,lm。


举例----------Examples----------


(cH <- contr.helmert(4))
apply(cH, 2,sum) # column sums are 0[列金额是0]
crossprod(cH) # diagonal -- columns are orthogonal[对角线 - 列是正交]
contr.helmert(4, contrasts = FALSE) # just the 4 x 4 identity matrix[只是4×4单位矩阵]

(cT <- contr.treatment(5))
all(crossprod(cT) == diag(4)) # TRUE: even orthonormal[TRUE:即使正交]

(cT. <- contr.SAS(5))
all(crossprod(cT.) == diag(4)) # TRUE[真]

zapsmall(cP &lt;- contr.poly(3)) # Linear and Quadratic[线性和二次]
zapsmall(crossprod(cP), digits=15) # orthonormal up to fuzz[正交上升到模糊]

转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。


注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2025-2-3 04:46 , Processed in 0.023511 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表