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

R语言 rms包 anova.rms()函数中文帮助文档(中英文对照)

  [复制链接]
发表于 2012-9-27 19:08:50 | 显示全部楼层 |阅读模式
anova.rms(rms)
anova.rms()所属R语言包:rms

                                        Analysis of Variance (Wald and F Statistics)
                                         方差分析(Wald和F统计量)

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

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

The anova function automatically tests most meaningful hypotheses in a design. For example, suppose that age and cholesterol are predictors, and that a general interaction is modeled using a restricted spline surface. anova prints Wald statistics (F statistics for an ols fit) for testing linearity of age, linearity of cholesterol, age effect (age + age by cholesterol interaction), cholesterol effect (cholesterol + age by cholesterol interaction), linearity of the age by cholesterol interaction (i.e., adequacy of the simple age * cholesterol 1 d.f. product), linearity of the interaction in age alone, and linearity of the interaction in cholesterol alone. Joint tests of all interaction terms in the model and all nonlinear terms in the model are also performed.  For any multiple d.f. effects for continuous variables that were not modeled through rcs, pol, lsp, etc., tests of linearity will be omitted.  This applies to matrix predictors produced by e.g. poly or ns.  print.anova.rms is the printing method.  plot.anova.rms draws dot charts depicting the importance of variables in the model, as measured by Wald chi-square, chi-square minus d.f., AIC, P-values, partial R^2, R^2 for the whole model after deleting the effects in question, or proportion of overall model R^2 that is due to each predictor.  latex.anova.rms is the latex method.  It substitutes Greek/math symbols in column headings, uses boldface for TOTAL lines, and constructs a caption.  Then it passes the result to latex.default for conversion to LaTeX.
anova功能,自动测试在设计中最有意义的假设。例如,假设,年龄和胆固醇是预测因子,和一般的相互作用使用受限制的样条曲面建模。 anova打印Wald统计量(F统计ols适合的)测试线性的年龄,胆固醇,年龄的影响(年龄+胆固醇互动的年龄),胆固醇的作用(胆固醇的线性度+由胆固醇相互作用年龄),线性的年龄相互作用胆固醇(即,是否足够简单的年龄*胆固醇1 df的产品),线性度的单独的年龄的相互作用,和单独的相互作用中的胆固醇的线性。也进行联合测试,测试模型中的非线性模型中的所有互动。对于任何多重D.F.的连续变量,没有仿照透过rcs,pol,lsp,等,线性度的测试将被省略,效果。这也适用于矩阵的预测,例如由poly或ns。 print.anova.rms是印刷方法。 plot.anova.rms点绘制统计图,展示在模型中的变量的重要性,作为衡量沃尔德chi-square,chi-square减去DF,AIC,P值,部分R^2 ,R^2删除后的效果问题,或整个模型的整体模型的比例R^2这是由于每一个预测。 latex.anova.rms是latex方法。它替代希腊/数学符号在列标题中,使用粗体TOTAL线,并构建了一个标题。然后将结果传递到latex.defaultLaTeX的转换。


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


## S3 method for class 'rms'
anova(object, ..., main.effect=FALSE, tol=1e-9,
      test=c('F','Chisq'), india=TRUE, indnl=TRUE, ss=TRUE)

## S3 method for class 'anova.rms'
print(x, which=c('none','subscripts','names','dots'), ...)

## S3 method for class 'anova.rms'
plot(x,
     what=c("chisqminusdf","chisq","aic","P","partial R2","remaining R2",
            "proportion R2"),
     xlab=NULL, pch=16,
     rm.totals=TRUE, rm.ia=FALSE, rm.other=NULL, newnames,
     sort=c("descending","ascending","none"), pl=TRUE, ...)

## S3 method for class 'anova.rms'
latex(object, title, psmall=TRUE, dec.chisq=2,
      dec.F=2, dec.ss=NA, dec.ms=NA, dec.P=4, table.env=TRUE,
      caption=NULL, ...)



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

参数:object
a rms fit object.  object must allow vcov to return the variance-covariance matrix.  For latex is the result of anova.  
rms合适的对象。 object必须允许vcov返回的方差 - 协方差矩阵。 latex的结果anova。


参数:...
If omitted, all variables are tested, yielding tests for individual factors and for pooled effects. Specify a subset of the variables to obtain tests for only those factors, with a pooled Wald tests for the combined effects of all factors listed. Names may be abbreviated.  For example, specify anova(fit,age,cholesterol) to get a Wald statistic for testing the joint importance of age, cholesterol, and any factor interacting with them.  Can be optional graphical parameters to send to  dotchart2, or other parameters to send to latex.default. Ignored for print.  
如果省略,则所有的变量进行了测试,得到测试个人因素和汇集的影响。指定的一个子集的变量,得到测试为只有那些因素,具有汇集沃尔德列出的所有因素的综合影响,测试。可能是缩写名称。例如,指定anova(fit,age,cholesterol)得到Wald统计量的联合测试的年龄,胆固醇和任何与他们互动的因素的重要性。可以是可选的图形参数发送到dotchart2,或其他参数要发送到latex.default。为print忽略。


参数:main.effect
Set to TRUE to print the (usually meaningless) main effect tests even when the factor is involved in an interaction. The default is FALSE, to print only the effect of the main effect combined with all interactions involving that factor.  
设置为TRUE打印(通常是没有意义的)的主要作用,即使因子参与的互动测试。默认值是FALSE,只打印效果的主要影响与所有涉及该因素的相互作用相结合。


参数:tol
singularity criterion for use in matrix inversion  
中使用的矩阵求逆的奇异性标准


参数:test
For an ols fit, set test="Chisq" to use Wald χ^2 tests rather than F-tests.  
对于ols适合,test="Chisq"使用沃尔德χ^2测试,而不是F-检验。


参数:india
set to FALSE to exclude individual tests of interaction from the table
从表中排除个别测试的互动设置为FALSE


参数:indnl
set to FALSE to exclude individual tests of nonlinearity from the table
从表中排除个别测试的非线性设置为FALSE


参数:ss
For an ols fit, set ss=FALSE to suppress printing partial sums of squares, mean squares, and the Error SS and MS.  
对于ols适合,ss=FALSE抑制印刷部分和的平方,平均广场,SS和MS的错误。


参数:x
for print,plot,text is the result of anova.  
print,plot,text的结果anova。


参数:which
If which is not "none" (the default), print.anova.rms will add to the rightmost column of the output the list of parameters being tested by the hypothesis being tested in the current row.  Specifying which="subscripts" causes the subscripts of the regression coefficients being tested to be printed (with a subscript of one for the first non-intercept term).  which="names" prints the names of the terms being tested, and which="dots" prints dots for terms being tested and blanks for those just being adjusted for.  
如果which不"none"(默认值),print.anova.rms添加到最右边的列的输出参数测试,被测试的假设在当前行的列表。指定which="subscripts"导致回归系数被测试以进行打印(用下标为第一非截距项之一)的下标。 which="names"打印的条款被测试的名称,which="dots"条款进行测试和空白,对于那些只是被调整打印点。


参数:what
what type of statistic to plot.  The default is the Wald chi-square  statistic for each factor (adding in the effect of higher-ordered factors containing that factor) minus its degrees of freedom.  The last three choice for what only apply to ols models.  
什么类型的统计图。默认的Wald chi-square统计每个因素的加入更有序的因素,这个因素的影响,减去其自由度。最后三个选择what只适用于ols模型。


参数:xlab
x-axis label, default is constructed according to what. plotmath symbols are used for R, by default.  
X轴标签,默认是根据what。 plotmath符号用于R,默认情况下。


参数:pch
character for plotting dots in dot charts.  Default is 16 (solid dot).  
点图的绘制点的字符。默认值是16(实心圆点)。


参数:rm.totals
set to FALSE to keep total chi-squares (overall, nonlinear, interaction totals) in the chart.  
设置为FALSE保持总chi-square(整体的,非线性的,互动总计)在图表中。


参数:rm.ia
set to TRUE to omit any effect that has "*" in its name  
设置为TRUE"*"在其名称中省略任何影响,


参数:rm.other
a list of other predictor names to omit from the chart  
从图中省略列表中的其他预测的名称


参数:newnames
a list of substitute predictor names to use, after omitting any.  
使用替代预测的名称,省略任何一个列表。


参数:sort
default is to sort bars in descending order of the summary statistic  
默认情况下是条形的汇总统计量的递减顺序进行排序


参数:pl
set to FALSE to suppress plotting.  This is useful when you only wish to analyze the vector of statistics returned.  
设置为FALSE抑制绘制。这是非常有用的,当你只是想返回矢量的统计分析。


参数:title
title to pass to latex, default is name of fit object passed to anova prefixed with "anova.".  For Windows, the default is "ano" followed by the first 5 letters of the name of the fit object.   
标题传递给latex,默认情况下是合适的对象传递给anova前缀"anova."的名称。在Windows中,默认情况下是"ano"其次是合适的对象的第一个5个字母的名字。


参数:psmall
The default is psmall=TRUE, which causes P<0.00005 to print as <0.0001. Set to FALSE to print as 0.0000.  
默认值是psmall=TRUE,这会导致P<0.00005打印为<0.0001,。设置为FALSE,打印为0.0000。


参数:dec.chisq
number of places to the right of the decimal place for typesetting chi-square values (default is 2).  Use zero for integer, NA for floating point.  
一些地方的小数位的权利排版chi-square值(默认是2)。使用零为整,NA浮点。


参数:dec.F
digits to the right for F statistics (default is 2)  
右侧数字为F统计(默认是2)


参数:dec.ss
digits to the right for sums of squares (default is NA, indicating floating point)  
右侧数字的平方的款项(默认是NA,表示浮点)


参数:dec.ms
digits to the right for mean squares (default is NA)  
右侧数字为均方值(默认是NA)


参数:dec.P
digits to the right for P-values
右侧数字为P值


参数:table.env
see latex
看到latex


参数:caption
caption for table if table.env is TRUE. Default is constructed from the response variable.
标题表,如果table.env是TRUE。默认构造响应变量。


Details

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

If the statistics being plotted with plot.anova.rms are few in number and one of them is negative or zero, plot.anova.rms will quit because of an error in dotchart2.
如果统计数据所绘制plot.anova.rms是人数不多,其中之一为负数或零,plot.anova.rms将退出,因为一个错误的dotchart2。


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

anova.rms returns a matrix of class anova.rms containing factors  as rows and chi-square, d.f., and P-values as columns (or d.f., partial SS, MS, F, P). plot.anova.rms invisibly returns the vector of quantities plotted.  This vector has a names attribute describing the terms for which the statistics in the vector are calculated.
anova.rms返回一个矩阵行和anova.rms,df和chi-square值的列(或DF类P包含的因素,部分SS, MS, F, P)。 plot.anova.rms看不见的返回绘制向量的数量。这个向量有一个名称属性描述的统计数据中的矢量计算。


副作用----------Side Effects----------

print prints, latex creates a file with a name of the form "title.tex" (see the title argument above).
print打印,latex创建一个文件的名称形如"title.tex"(title的上述论点)。


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



Frank Harrell<br>
Department of Biostatistics, Vanderbilt University<br>
f.harrell@vanderbilt.edu




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

rms, rmsMisc, lrtest, rms.trans, summary.rms, solvet, locator, dotchart2, latex,   xYplot, anova.lm, contrast.rms, pantext
rms,rmsMisc,lrtest,rms.trans,summary.rms,solvet,locator,dotchart2,<所述>,latex,xYplot,anova.lm,contrast.rms


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


n &lt;- 1000    # define sample size[确定样本量]
set.seed(17) # so can reproduce the results[所以可以重现的结果]
treat <- factor(sample(c('a','b','c'), n,TRUE))
num.diseases <- sample(0:4, n,TRUE)
age <- rnorm(n, 50, 10)
cholesterol <- rnorm(n, 200, 25)
weight <- rnorm(n, 150, 20)
sex <- factor(sample(c('female','male'), n,TRUE))
label(age) &lt;- 'Age'      # label is in Hmisc[标签是在Hmisc]
label(num.diseases) <- 'Number of Comorbid Diseases'
label(cholesterol) <- 'Total Cholesterol'
label(weight) <- 'Weight, lbs.'
label(sex) <- 'Sex'
units(cholesterol) &lt;- 'mg/dl'   # uses units.default in Hmisc[使用units.default在Hmisc]


# Specify population model for log odds that Y=1[指定的log几率的人口模型Y = 1]
L <- .1*(num.diseases-2) + .045*(age-50) +
     (log(cholesterol - 10)-5.2)*(-2*(treat=='a') +
     3.5*(treat=='b')+2*(treat=='c'))
# Simulate binary y to have Prob(y=1) = 1/[1+exp(-L)][模拟二进制y以有PROB(y = 1时)= 1 / [1 +(-L)]]
y <- ifelse(runif(n) < plogis(L), 1, 0)


fit <- lrm(y ~ treat + scored(num.diseases) + rcs(age) +
               log(cholesterol+10) + treat:log(cholesterol+10))
anova(fit)                       # Test all factors[测试的所有因素]
anova(fit, treat, cholesterol)   # Test these 2 by themselves[这2个测试自己]
                                 # to get their pooled effects[得到他们的汇集效应]
g <- lrm(y ~ treat*rcs(age))
dd <- datadist(treat, num.diseases, age, cholesterol)
options(datadist='dd')
p <- Predict(g, age, treat="b")
s <- anova(g)
# Usually omit fontfamily to default to 'Courier'[通常省略fontFamily中默认为“信使”]
# It's specified here to make R pass its package-building checks[它的指定使R通过包检查]
plot(p, addpanel=pantext(s, 28, 1.9,  fontfamily='Helvetica'))

plot(s)                          # new plot - dot chart of chisq-d.f.[新的图 - 点图的chisq d.f。]
# latex(s)                       # nice printout - creates anova.g.tex[乳胶(S)#不错的打印输出 - 创建anova.g.tex]
options(datadist=NULL)


# Simulate data with from a given model, and display exactly which[从一个给定的模型模拟数据,并显示哪些]
# hypotheses are being tested[假设正在测试中]


set.seed(123)
age <- rnorm(500, 50, 15)
treat <- factor(sample(c('a','b','c'), 500, TRUE))
bp  <- rnorm(500, 120, 10)
y   <- ifelse(treat=='a', (age-50)*.05, abs(age-50)*.08) + 3*(treat=='c') +
       pmax(bp, 100)*.09 + rnorm(500)
f   <- ols(y ~ treat*lsp(age,50) + rcs(bp,4))
print(names(coef(f)), quote=FALSE)
specs(f)
anova(f)
an <- anova(f)
options(digits=3)
print(an, 'subscripts')
print(an, 'dots')


an <- anova(f, test='Chisq', ss=FALSE)
plot(0:1)                        # make some plot[一些图]
tab <- pantext(an, 1.2, .6, lattice=FALSE, fontfamily='Helvetica')
# create function to write table; usually omit fontfamily[创建函数写表,通常省略fontFamily中]
tab()                            # execute it; could do tab(cex=.65)[执行它;能做到“选项卡”(CEX = 0.65)]
plot(an)                         # new plot - dot chart of chisq-d.f.[新的图 - 点图的chisq d.f。]
# latex(an)                      # nice printout - creates anova.f.tex[乳胶()#不错的打印输出 - 创建anova.f.tex]


## Example to save partial R^2 for all predictors, along with overall[#示例保存部分的R ^ 2的所有预测,随着整体]
## R^2, from two separate fits, and to combine them with a lattice plot[#R ^ 2,从两个单独的配合,并把它们结合起来,其晶格图]

require(lattice)
set.seed(1)
n <- 100
x1 <- runif(n)
x2 <- runif(n)
y  <- (x1-.5)^2 + x2 + runif(n)
group <- c(rep('a', n/2), rep('b', n/2))
A <- NULL
for(g in c('a','b'))
  {
    f <- ols(y ~ pol(x1,2) + pol(x2,2) + pol(x1,2) %ia% pol(x2,2),
             subset=group==g)
    a <- plot(anova(f),
              what='partial R2', pl=FALSE, rm.totals=FALSE, sort='none')
    a <- a[-grep('NONLINEAR', names(a))]
    d <- data.frame(group=g, Variable=factor(names(a), names(a)),
                    partialR2=unname(a))
    A <- rbind(A, d)
  }
dotplot(Variable ~ partialR2 | group, data=A,
        xlab=ex <- expression(partial~R^2))
dotplot(group ~ partialR2 | Variable, data=A, xlab=ex)
dotplot(Variable ~ partialR2, groups=group, data=A, xlab=ex,
        auto.key=list(corner=c(.5,.5)))

# Suppose that a researcher wants to make a big deal about a variable [假设一个变量,研究人员希望,使一个大问题]
# because it has the highest adjusted chi-square.  We use the[因为它具有最高的调整卡方。我们使用]
# bootstrap to derive 0.95 confidence intervals for the ranks of all[引导中获得0.95的置信区间的行列]
# the effects in the model.  We use the plot method for anova, with[在模型中的效果。我们用图法方差分析,]
# pl=FALSE to suppress actual plotting of chi-square - d.f. for each[PL = FALSE抑制实际绘图卡方 -  DF为每个]
# bootstrap repetition.  We rank the negative of the adjusted[引导重复。排名负的调整]
# chi-squares so that a rank of 1 is assigned to the highest.[卡广场,使被分配到最高的秩为1。]
# It is important to tell plot.anova.rms not to sort the results,[这是很重要,告诉plot.anova.rms对结果进行排序,]
# or every bootstrap replication would have ranks of 1,2,3 for the stats.[或每一个引导复制1,2,3的统计队伍。]


mydata <- data.frame(x1=runif(200), x2=runif(200),
                     sex=factor(sample(c('female','male'),200,TRUE)))
set.seed(9)  # so can reproduce example[这样可以重现的例子]
mydata$y <- ifelse(runif(200)<=plogis(mydata$x1-.5 + .5*(mydata$x2-.5) +
                   .5*(mydata$sex=='male')),1,0)


if(require(boot))
   {
      b <- boot(mydata, function(data, i, ...) rank(-plot(anova(
                lrm(y ~ rcs(x1,4)+pol(x2,2)+sex,data,subset=i)),
                sort='none', pl=FALSE)),
                R=25)  # should really do R=500 but will take a while[要真正做R = 500,但还需要一段时间]
      Rank <- b$t0
      lim <- t(apply(b$t, 2, quantile, probs=c(.025,.975)))


# Use the Hmisc Dotplot function to display ranks and their confidence[中使用Hmisc Dotplot函数显示行列的信心]
# intervals.  Sort the categories by descending adj. chi-square, for ranks[的时间间隔。的类别进行排序,按降序ADJ。卡方行列]
      original.chisq <- plot(anova(lrm(y ~ rcs(x1,4)+pol(x2,2)+sex,
                       data=mydata)),
                       sort='none', pl=FALSE)
      predictor <- as.factor(names(original.chisq))
      predictor <- reorder(predictor, -original.chisq)

      Dotplot(predictor ~ Cbind(Rank, lim), pch=3, xlab='Rank',
              main=if(.R.) expression(paste(
      'Ranks and 0.95 Confidence Limits for ',chi^2,' - d.f.')) else
      'Ranks and 0.95 Confidence Limits for Chi-square - d.f.')
}

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


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

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-11-23 13:47 , Processed in 0.023925 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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