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

R语言 vcdExtra包 loddsratio()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-10-1 14:43:58 | 显示全部楼层 |阅读模式
loddsratio(vcdExtra)
loddsratio()所属R语言包:vcdExtra

                                         Calculate Log Odds Ratios for Frequency Tables
                                         计算log的比值比频率表

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

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

Computes (log) odds ratios and their asymptotic variance covariance matrix for (possibly) stratified data. Odds ratios are calculated for two array dimensions, separately for each level of all stratifying dimensions. This generalizes the oddsratio methods in the vcd package from 2 x 2 ( x strata) tables to R x C (x strata) tables.  In future versions, these functions may be renamed and or moved to the vcd package.
计算(对数)的比值比和其渐近方差协方差矩阵(可能)分层数据。比值比分别计算两个数组的尺寸,每个级别的所有分层的维度。推广了oddsratio在VCD包的方法从2×2(层)表R X C(X层)表。在未来的版本中,这些功能可能会被重命名或移动的VCD包。


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



loddsratio(x, ...)
## Default S3 method:[默认方法]
loddsratio(x, strata = NULL, log = TRUE,
  ref = NULL, correct = any(x == 0), ...)

## S3 method for class 'loddsratio'
coef(object, log = object$log, ...)
## S3 method for class 'loddsratio'
vcov(object, log = object$log, ...)
## S3 method for class 'loddsratio'
print(x, log = x$log, ...)

as.array(x, ...)
## S3 method for class 'loddsratio'
as.array(x, log=x$log, ...)



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

参数:x
An object. For the default method a k-way matrix/table/array of frequencies. The number of margins has to be at least 2.
一个对象。对于默认的方法的K-矩阵/频率表/数组。边距的数目是至少2。


参数:strata
Numeric or character indicating the margins of a k-way table x (with k greater than 2) that should be employed as strata. By default dimensions 3:length(dim(x)) are used.
数字或字符表示一个k-TABLEx(用k大于2),应作为阶层的边缘。默认情况下,尺寸3:length(dim(x))使用。


参数:ref
Numeric or character. Reference categories for the (non-stratum) row and column dimensions that should be employed for computing the odds ratios. By default, odds ratios for profile contrasts (or sequential contrasts, i.e., successive differences of adjacent categories) are used. See details below.
数字或字符。参考类别(非阶层)的行数和列数,应采用计算比值比。默认情况下,比值比,以便进行对比(或连续的对比,即连续相邻类别的差异)。详见下文。


参数:log
Logical. Should the results be displayed on a log scale or not? All internal computations are always on the log-scale but the results are transformed by default if log = TRUE.
逻辑。如果结果显示对数标度或不呢?所有的内部计算的log规模,但结果总是被转换默认情况下,如果log = TRUE。


参数:correct
Logical. Should a continuity correction be applied (by adding 0.5 to all table entries) before computing odds ratios? By default, this not employed unless there are any zero cells in the table, but this correction is often recommended to reduce bias when some frequencies  are small (Fleiss, 1981).
逻辑。如果连续性校正计算比值比(加入0.5到所有的表项)?默认情况下,这个没有工作,除非有任何零表中单元格,但这种调整往往是建议,以减少偏见,当某些频率小(弗莱斯,1981)。


参数:object
An object of class loddsratio as computed by loddsratio.
一个对象的类loddsratio的计算loddsratio。


参数:...
Arguments passed to methods.
传递参数的方法。


Details

详细信息----------Details----------

For an R x C table, (log) odds ratios are formed for the set of (R-1) x (C-1) 2 x 2 tables, corresponding to some set of contrasts among the row and column variables.  The ref argument allows these to be specified in a general way.
对于R X C表,(log)的比值比形成的组(R-1)×(C-1)2 x 2的表格,相应的一些组行和列变量之间的对比。 ref参数允许将这些在一般的方式指定。

ref = NULL (default) corresponds to “profile contrasts”  (or sequential contrasts or successive differences) for ordered categories, i.e., R1-R2, R2-R3, R3-R4, etc., and similarly for the column categories. These are sometimes called “local odds ratios”.
ref = NULL(默认值)对应于“档案中的对比”(或顺序的对比或连续差异)为排列的类别,即,R 1-R 2,R 2-R 3,R 3-R 4,等,类似地,对于列类别。这些有时也被称为“本地比值比”。

ref=1 gives contrasts with the first category; ref=dim(x) gives contrasts with the last category; ref = c(2, 4) or ref = list(2, 4) corresponds to the reference being the second category in rows and the fourth in columns.
ref=1给出对比与第一类;ref=dim(x)给出对比与最后一类;ref = c(2, 4)或ref = list(2, 4)对应的行中的第二类参考和第四列中的。

Combinations like ref = list(NULL, 3) are also possible, as are character vectors, e.g., ref = c("foo", "bar") also works ("foo" pertaining again to the row reference and "bar" to column reference).
像ref = list(NULL, 3)也有可能合并,作为特征向量,例如ref = c("foo", "bar")也可以(“foo”的有关再行引用和“bar”列参考)。

Note that all such parameterizations are equivalent, in that one can derive all other possible odds ratios from any non-redundant set.
请注意,所有这样的参数化是等效的,在那一个可以得到的所有其他可能的比值比从任何非冗余集。


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

An object of class loddsratio, with the following components:
对象的类loddsratio,以下组件:


参数:coefficients
A named vector, of length (R-1) x (C-1) x prod(dim(x)[strata]) containing the log odds ratios. Use the coef method to  extract these from the object, and the confint method for confidence intervals. For a two-way table, the names for the log odds ratios are constructed in the form Ri:Rj/Ci:Cj using the table names for rows and columns. For a stratified table, the names are constructed in the form Ri:Rj/Ci:Cj|Lk.  
命名的向量,长度为(R-1)×(C-1)×prod(dim(x)[strata])包含log的比值比。使用coef的方法来提取这些对象,和confint方法置信区间。对于双向表,名称为log比值比构造的形式日:的Rj /次:Cj的使用的行和列的表名称。对于分层表的名称构造的形式RI:RJ / CI:CJ路加福音。


参数:vcov
Variance covariance matrix of the log odds ratios.
方差协方差矩阵的log比值比。


参数:dimnames
Dimension names for the log odds ratios, considered as a table of size c(R-1, C-1, dim(x)[strata]. Use the dim and dimnames methods to extract these and manipulate the log odds ratios in relation to the original table.
尺寸名称的log胜算比,表的大小c(R-1, C-1, dim(x)[strata]审议。使用dim和dimnames方法来提取这些关系到原来的表操作log的比值比。


参数:dim
Corresponding dimension vector.
通讯维向量。


参数:contrasts
A matrix C, such that C %*% as.vector(log(x)) gives the log odds ratios. Each row corresponds to one log odds ratio, and is all zero, except for 4 elements of c(1, -1, -1, 1) for a given 2 x 2 subtable.
矩阵C,C %*% as.vector(log(x))给出了log的比值比。每一行对应于一个记录的比值比,是所有零,除了4c(1, -1, -1, 1)的元素为一个给定的2×2子表。


参数:log
A logical, indicating whether the value of log in the original call.
一个逻辑,指示该值是否log在原来的呼叫。


注意----------Note----------

The method of calculation is an example of the use of the delta method described by Agresti (1990), Section 12.1.7, giving estimates of log odds ratios and their asymptotic covariance matrix.
的计算方法是使用的delta阿格雷斯蒂(1990)所描述的,第12.1.7,给log比值比和其渐近的协方差矩阵的估计方法的一个例子。

The codecoef method returns the coefficients component as a vector of length (R-1) x (C-1) x prod(dim(x)[strata]). The dim and dimnames methods provide the proper attributes for treating the coefficients vector as an (R-1) x (C-1) x strata array. as.matrix and as.array methods are also provided for this purpose.
codecoef方法返回coefficients组件作为一个向量,长度为(R-1)×(C-1)×prod(dim(x)[strata])。 dim和dimnames方法用于治疗coefficients矢量为(R-1)×(C-1)x地层阵列提供适当的属性。 as.matrix和as.array的方法还提供了用于这一目的。

The confint method computes confidence intervals for the log odds ratios (or for odds ratios, with log=FALSE). The coeftest method prints the asympotic standard errors, z tests (standardized log odds ratios), and the corresponding p values.   
confint方法计算的log比值比(或比值比的置信区间,与log=FALSE)。 coeftest方法打印的渐近标准误差,z测试(标准的对数比值比),相应的P值。


(作者)----------Author(s)----------



Achim Zeileis and Michael Friendly




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


2nd Edition. New York: Wiley.


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

oddsratio, confint,
oddsratio,confint,

coeftest for z-tests of significance
coeftestZ-显着性检验


实例----------Examples----------


## artificial example[#人为的例子]
set.seed(1)
x <- matrix(rpois(5 * 3, 7), ncol = 5, nrow = 3)
dimnames(x) <- list(Row=head(letters, 3), Col=tail(letters, 5))

x_lor <- loddsratio(x)
coef(x_lor)
x_lor
confint(x_lor)
if(require("lmtest")) coeftest(x_lor)


## 2 x 2 x k cases[#2×2×K表情况下,]
#data(CoalMiners, package="vcd")[数据(矿工,包=“VCD”)]
lor.CM <- loddsratio(CoalMiners)
lor.CM
coef(lor.CM)
confint(lor.CM)
confint(lor.CM, log=FALSE)

# odds ratio plot[比值比图]
lor.CM.df <- as.data.frame(lor.CM)
lor.CM.df <- within(lor.CM.df,
        {lower<-LOR-ASE
         upper<-LOR+ASE}
        )
range <- c(min(lor.CM.df$lower), max(lor.CM.df$upper))
with(lor.CM.df, {
        plot(LOR ~ as.numeric(Age), type='b', pch=16, xaxt='n',
          ylim=range,
                xlab="Age", ylab="Log odds ratio: Wheeze x Breathlessness",
                main="CoalMiners data: Log odds ratio plot")
        axis(side=1, at=as.numeric(Age), labels=Age)
        segments(as.numeric(Age), lower, as.numeric(Age), upper)
        }
        )
# fit linear models using WLS[符合线性模型,采用WLS]
abline(lm(LOR ~ as.numeric(Age), weights=1/ASE^2, data=lor.CM.df), col="blue")
age <- seq(25, 60, by = 5)
qmod <- lm(LOR ~ poly(age,2), weights=1/ASE^2, data=lor.CM.df)
lines(fitted(qmod), col = "red", lwd=2)


## 2 x k x 2[#2值X k×2]
lor.Emp <-loddsratio(Employment)
lor.Emp
confint(lor.Emp)

# visualize the log odds ratios[可视化log的比值比]
lor.Emp.a <- as.array(lor.Emp)
matplot(lor.Emp.a, type='b', xaxt='n', pch=15:16, cex=1.5,
        ylab='log odds ratio: Employment Status x Length',
        xlab='Employment Length',
        xlim=c(0.2, 5),
        main="Employment status data")
abline(h=0, col='gray')
axis(side=1, at=1:5, labels=rownames(lor.Emp.a))
text(0.3, lor.Emp.a[1,], colnames(lor.Emp.a), pos=4, col=1:2)
text(0.5, max(lor.Emp.a[1,])+.1, "Layoff cause")


## R x C case[#R X C的情况下]
#data(Hauser79, package="vcdExtra")[数据(Hauser79,包=“vcdExtra”)]
hauser.tab <- xtabs(Freq ~ Father+Son, data=Hauser79)
(lor.hauser <- loddsratio(hauser.tab))
confint(lor.hauser)

# odds ratio plot[比值比图]
op <- par(xpd=TRUE)
matplot(as.matrix(lor.hauser), type='b', ylab='log odds ratio',
        xlab="Son's status comparisons", xaxt='n', xlim=c(1,4.5), ylim=c(-.5,3),
        main="Hauser79 data")
abline(h=0, col='gray')
axis(side=1, at=1:4, labels=colnames(lor.hauser))
text(4, as.matrix(lor.hauser)[4,], rownames(lor.hauser), pos=4, col=1:4)
text(4, 3, "Father's status")
par(op)


## 4 way tables [#4路表]
data(Punishment, package="vcd")
punish <- xtabs(Freq ~ memory + attitude + age + education, data = Punishment)
mosaic(~ age + education + memory + attitude, data = punish, keep = FALSE,
       gp = gpar(fill = grey.colors(2)), spacing = spacing_highlighting,
       rep = c(attitude = FALSE))

lor.pun <- loddsratio(punish)
lor.pun
confint(lor.pun)
if(require("lmtest")) coeftest(lor.pun)

# visualize the log odds ratios, by education[可视化log的比值比,受教育]
lor.pun.a <- as.array(lor.pun)
matplot(lor.pun.a, type='b', xaxt='n', pch=15:17, cex=1.5,
        ylab='log odds ratio: Attitude x Memory',
        xlab='Age', xlim=c(0.5, 3), ylim=c(-2, 1),
        main="Attitudes toward corporal punishment")
abline(h=0, col='gray')
axis(side=1, at=1:3, labels=rownames(lor.pun.a))
text(0.5, lor.pun.a[1,], colnames(lor.pun.a), pos=4, col=1:3)
text(0.6, max(lor.pun.a[1,])+.2, "Education")

# visualize the log odds ratios, by age[可视化的log胜算比,按年龄]
matplot(t(lor.pun.a), type='b', xaxt='n', pch=15:17, cex=1.5,
        ylab='log odds ratio: Attitude x Memory',
        xlab='Education', xlim=c(0.5, 3), ylim=c(-2, 1),
        main="Attitudes toward corporal punishment")
abline(h=0, col='gray')
axis(side=1, at=1:3, labels=colnames(lor.pun.a))
text(0.5, lor.pun.a[,1], rownames(lor.pun.a), pos=4, col=1:3)
text(0.6, max(lor.pun.a[,1])+.2, "Age")

# fit linear model using WLS[拟合线性模型,采用WLS]
lor.pun.df <- as.data.frame(lor.pun)
pun.mod1 <- lm(LOR ~ as.numeric(age) * as.numeric(education), data=lor.pun.df, weights=1/ASE^2)
anova(pun.mod1)


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


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

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-11-27 10:20 , Processed in 0.023449 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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