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

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

  [复制链接]
发表于 2012-9-17 08:48:10 | 显示全部楼层 |阅读模式
effect(effects)
effect()所属R语言包:effects

                                        Functions For Constructing Effect Plots
                                         对于建设作用图的功能

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

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

effect constructs an "eff" object for a term (usually a high-order term)  in a linear (fit by lm or gls) or generalized linear model (fit by glm), or an "effpoly" object for a term in a multinomial or proportional-odds logit model (fit respectively by multinom or polr),  absorbing the lower-order terms marginal to the term in question, and averaging over other terms in the model.  The function can also be used with mixed-effects models fit with lmer from the lme4 package, or fit with lme from the nlme package.  In mixed effects models the analysis is for the fixed effects only, not for random effects.
effect构造一个"eff"对象的期限(通常是一个高阶项)的线性(适合lm或gls)或广义线性模型(适合用 glm),或"effpoly"对象为多项式或比例赔率Logit模型中的一个术语(的分别multinom或polr),吸收低阶项的边际术语的问题,平均比其他模型中的。该功能也可用于混合效应模型配合lmerlme4包,或适合lmenlme包。在混合效应模型的分析是固定的,而不是随机效应的影响。

allEffects identifies all of the high-order terms in a model and returns a list of "eff" or "effpoly" objects (i.e., an object of type "efflist").
allEffects确定在模型中的高次项,并返回一个列表,"eff"或"effpoly"对象(例如,一个类型的对象"efflist"“)。


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


effect(term, mod, ...)

## S3 method for class 'lm'
effect(term, mod, xlevels=list(), default.levels=10, given.values,
        se=TRUE, confidence.level=.95,
    transformation=list(link=family(mod)$linkfun, inverse=family(mod)$linkinv),
    typical=mean, ...)
   
## S3 method for class 'gls'
effect(term, mod, xlevels=list(), default.levels=10, given.values,
        se=TRUE, confidence.level=.95, transformation=NULL, typical=mean, ...)
   
## S3 method for class 'multinom'
effect(term, mod, confidence.level=.95, xlevels=list(), default.levels=10,
        given.values, se=TRUE, typical=mean, ...)
               
## S3 method for class 'polr'
effect(term, mod, confidence.level=.95, xlevels=list(), default.levels=10,
        given.values, se=TRUE, typical=mean, latent=FALSE, ...)
       
## S3 method for class 'mer'
effect(term, mod, ...)

## S3 method for class 'lme'
effect(term, mod, ...)
   
allEffects(mod, ...)

## S3 method for class 'mer'
allEffects(mod, ...)

## S3 method for class 'lme'
allEffects(mod, ...)

## S3 method for class 'eff'
as.data.frame(x, row.names=NULL, optional=TRUE, ...)

## S3 method for class 'effpoly'
as.data.frame(x, row.names=NULL, optional=TRUE, ...)

## S3 method for class 'efflatent'
as.data.frame(x, row.names=NULL, optional=TRUE, ...)

## S3 method for class 'eff'
vcov(object, ...)



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

参数:term
the quoted name of a term, usually, but not necessarily, a high-order  term in the model. The term must be given exactly as it appears in the printed model, although either colons ( or asterisks (*) may be used for interactions.
所报的名称的一个术语,通常,但不是必须的,在模型中的高阶的术语。该术语必须给予正是因为它出现在印刷的模型,虽然可以冒号(:)或星号(*)可用于相互作用。


参数:mod
an object of class "lm", "gls", "glm",  "multinom", "polr" "mer" or "lme".  
类的一个对象"lm","gls","glm","multinom","polr""mer"或"lme"。


参数:xlevels
an optional list of values at which to set covariates, with components of the form covariate.name = vector.of.values.
可选列表的值设置的协变量,组件的形式covariate.name = vector.of.values。


参数:default.levels
number of values for covariates that are not specified explicitly via xlevels; covariate values set by default are evenly spaced between the minimum and maximum values in the data.
通过xlevels;协设置的默认值是均匀分布的数据中的最小值和最大值之间,没有明确指定的协变量的值的数目。


参数:given.values
a numeric vector of named elements, setting particular columns of the model matrix to specific values for terms not appearing in an effect; if specified, this argument takes precedence over the application of the function given in the typical argument (below). Care must be taken in specifying these values — e.g., for a factor, the values of all contrasts should be given and these should be consistent with each other.
一个数值向量命名的元素,设置特定的模型矩阵的列到特定的值没有出现影响;如果指定的话,这种说法typical参数中给出的函数的应用的优先级高于(低于) 。必须小心,在指定这些值 - 例如,一个因素,所有的对比的值应给出这些都应该是相互一致的。


参数:se
if TRUE, the default, calculate standard errors and confidence limits for the effects.
如果TRUE,默认情况下,计算标准误差和置信限的影响。


参数:confidence.level
level at which to compute confidence limits based on the standard-normal distribution; the default is 0.95.
在哪一级的标准正态分布的基础上计算的置信区间,默认为0.95。


参数:transformation
a two-element list with elements link and inverse. For a generalized linear model, these are by default the link function and inverse-link (mean) function. For a linear model, these default to NULL. If NULL, the identify function, I, is used; this effect can also be achieved by setting the argument to NULL. The inverse-link may be used to transform effects when they are printed or plotted; the link may be used in positioning axis labels (see below). If the link is not given, an attempt will be made to approximate it from the inverse-link.
一个两个元素的列表元素link和inverse。对于广义线性模型,这些都是默认情况下,链接功能和反向链路()函数。对于线性模型,这些默认NULL。如果NULL,识别功能,I,使用效果也可以达到设定的参数NULL。逆链路可用于转换效果,当它们被印刷或绘制;链接可以用在定位轴标签(见下文)。如果没有给出链接,试图将近似它的反向链接。


参数:typical
a function to be applied to the columns of the model matrix over which the effect is "averaged"; the default is mean.
一个函数被施加到超过该效果是“平均”的模型矩阵的列,缺省值是mean。


参数:latent
if TRUE, effects in a proportional-odds logit model are computed on the scale of the latent response; if FALSE  (the default) effects are computed as individual-level probabilities and logits.
如果TRUE,影响规模的潜在反应的比例赔率Logit模型计算,如果FALSE(默认值)效应计算个人层面的概率和logits的。


参数:x
an object of class "eff" or "effpoly".
对象的类"eff"或"effpoly"。


参数:row.names, optional
not used.
不被使用。


参数:object
an object of class "eff" for which the covariance matrix of the effects is desired.
一个的类"eff"的对象的协方差矩阵的效果是理想的。


参数:...
arguments to be passed down.
参数传递下来。


Details

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

Normally, the functions to be used directly are allEffects, to return a list of high-order effects, and the generic plot function to plot the effects. (see plot.efflist, plot.eff, and plot.effpoly). Plots are drawn using the xyplot (or in some cases,  the densityplot) function in the  lattice package. Effects may also be printed (implicitly or explicitly via print) or summarized (using summary) (see print.efflist, summary.efflist, print.eff, summary.eff, print.effpoly, and summary.effpoly).
通常情况下,直接使用的功能是allEffects,返回一个列表中的高阶效应,和一般的plot功能,图的影响。 (见plot.efflist,plot.eff和plot.effpoly)。图绘制xyplot(或在某些情况下,densityplot)函数lattice包。效果也可以打印(或明或暗地通过print)或总结(使用summary)(见print.efflist,summary.efflist,print.eff,summary.eff, ,print.effpoly和summary.effpoly)。

If asked, the effect function will compute effects for terms that have  higher-order relatives in the model, averaging over those terms (which rarely makes sense), or for terms that do not appear in the model but are higher-order relatives of terms that do.  For example, for the model Y ~ A*B + A*C + B*C, one could compute the effect corresponding to the absent term A:B:C, which absorbs the constant, the A, B, and C main effects, and the three two-way interactions. In either of these cases, a warning is printed.
如果问,effect功能将高阶模型中的亲属的条款计算的影响,平均对这些条款(而很少是有道理的),或不会出现在模型中的条款,但高条款的订单亲属。例如,对于模型Y ~ A*B + A*C + B*C,人们可以计算缺席术语A:B:C,吸收常数,A,B相对应的效果,和<X >主效应,三个双向互动。在这两种情况下,一个警告被打印出来。

In calculating effects, the strategy for "safe" prediction described in Hastie (1992: Sec. 7.3.3) is employed.
在计算效果,该策略描述为“安全”的预测哈斯蒂(1992年:7.3.3节)。


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

For lm, glm, mer and lme, effect returns  an "eff" object, and for multinom and polr, an "effpoly" object, with the following components:
lm,glm,mer和lme,effect返回一个"eff"对象,并multinom和<X >,polr对象,具有以下组件:


参数:term
the term to which the effect pertains.
术语影响有关。


参数:formula
the complete model formula.
完整的模型公式。


参数:response
a character string giving the name of the response variable.
给予响应变量的名称的字符串。


参数:y.levels
(for "effpoly" objects) levels of the polytomous response variable.
("effpoly"对象)的水平的多分反应变量。


参数:variables
a list with information about each predictor, including its name, whether it is a factor, and its levels or values.
与每个预测变量,包括它的名称,它是否是一个因子,其水平或值有关下列内容的信息的列表。


参数:fit
(for "eff" objects) a one-column matrix of fitted values, representing the effect on the scale of the linear predictor; this is a ravelled table, representing all combinations of predictor values.
一个("eff"对象)列矩阵的拟合值,占规模的线性预测的影响,这是一个弄明白表,表示预测值的所有组合。


参数:prob
(for "effpoly" objects) a matrix giving fitted probabilities for the effect for the various levels of the the response (columns) and combinations of the focal predictors (rows).
("effpoly"对象)给予嵌合概率的响应(列)的焦点的预测因子(行)和组合的各种水平的影响的矩阵。


参数:logit
(for "effpoly" objects) a matrix giving fitted logits for the effect for the various levels of the the response (columns) and combinations of the focal predictors (rows).
("effpoly"对象)的响应(列)的焦点的预测因子(行)和组合的各种水平的效果给予嵌合logits的矩阵。


参数:x
a data frame, the columns of which are the predictors in the effect, and the rows of which give all combinations of values of these predictors.
的数据框,其中的列中的预测出效果,其中的行,让所有这些预测变量的值的组合。


参数:model.matrix
the model matrix from which the effect was calculated.
从效果计算的模型矩阵。


参数:data
a data frame with the data on which the fitted model was based.
拟合模型是基于其上的数据的数据框。


参数:discrepancy
the percentage discrepancy for the "safe" predictions of the original fit; should be very close to 0.
安全的预测原始拟合的百分比差异;应该是非常接近0。


参数:model
(for "effpoly" objects) "multinom" or "polr", as appropriate.
(用于"effpoly"对象)"multinom"或"polr",适当。


参数:vcov
(for "eff" objects) a covariance matrix for the effect, on the scale of the linear predictor.
("eff"的对象)的协方差矩阵的效果,上规模的线性预测器。


参数:se
(for "eff" objects) a vector of standard errors for the effect, on the scale of the linear predictor.
("eff"对象)的向量的效果的标准误差,刻度上的线性预测器。


参数:se.prob, se.logit
(for "effpoly" objects) matrices of standard errors for the effect, on the probability and logit scales.
("effpoly"对象)矩阵的标准误差的影响,概率和logit尺度上。


参数:lower, upper
(for "eff" objects) one-column matrices of confidence limits, on the scale of the linear predictor.
("eff"对象)的一列矩阵的置信区间,上规模的线性预测。


参数:lower.prob, upper.prob, lower.logit, upper.logit
(for "effpoly" objects) matrices of confidence limits for the fitted logits and probabilities; the latter are computed by transforming the former.
("effpoly"对象)的矩阵信心的的装logits和概率限制,后者由改造前的计算。


参数:confidence.level
for the confidence limits.
为自信的限制。


参数:transformation
(for "eff" objects) a two-element list, with element link giving the link function, and element inverse giving the inverse-link (mean) function.
("eff"对象)两个元素的列表,与元素link的纽带作用,和元素inverse的反向链接(平均)功能。

effectList returns a list of "eff" or "effpoly" objects corresponding to the high-order terms of the model.
effectList"eff"或"effpoly"相应的高次项的模型对象返回一个列表。


警告和限制----------Warnings and Limitations----------

The effect function handles factors and covariates differently, and becomes confused if one is changed to the other in a model formula. Consequently, formulas that include calls to as.factor, factor, or numeric (as, e.g., in as.factor(income)) will cause errors. Instead, create the modified variables outside of the model formula (e.g., fincome <- as.factor(income)) and use these in the model formula.
effect函数处理不同的因子和协,成为困惑,如果一个模型中的公式更改为其他。因此,公式,包括调用as.factor,factor或numeric(如,例如,as.factor(income))会导致错误。相反,创建修改后的变量之外的模型公式(例如,fincome <- as.factor(income)),并使用这些中的模型公式。

Factors cannot have colons in level names (e.g., "level:A"); the effect function will confuse the colons with interactions; rename levels to remove or replace the colons (e.g., "level.A").
因素不能有冒号级别名称(例如,"level:A"); effect函数会混淆冒号与互动,重命名,删除或替换冒号(例如,"level.A")的水平。

Binomial generalized linear models cannot have a matrix of successes and failures on the left-hand side of the model formula; instead specify the proportion of successes (i.e., successes/(successes + failures)) as the response, and give the number of binomial trials (i.e., successes + failures) in the weights argument to glm.
二项式广义线性模型可以不具有的成功和失败的左手侧的模型公式的矩阵,而不是指定的比例成功(即成功/(成功+失败的))的响应,并给数二项式试验(即成功+失败)中的权重参数,glm。


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


John Fox <a href="mailto:jfox@mcmaster.ca">jfox@mcmaster.ca</a> and Jangman Hong.  Extension to
<code>mer</code> and <code>lme</code> objects by Sanford Weisberg <a href="mailto:sandy@umn.edu">sandy@umn.edu</a>.



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

Effect displays for generalized linear models. Sociological Methodology 17, 347&ndash;361.
Effect displays in R for generalised linear models. Journal of Statistical Software 8:15, 1&ndash;27, &lt;http://www.jstatsoft.org/v08/i15/&gt;.
Effect displays for multinomial and proportional-odds logit models. Sociological Methodology  36, 225&ndash;255.
Effect displays in R for multinomial and proportional-odds logit models:  Extensions to the effects package. Journal of Statistical Software 32:1, 1&ndash;24, &lt;http://www.jstatsoft.org/v32/i01/&gt;.
Generalized additive models. In Chambers, J. M., and Hastie, T. J. (eds.) Statistical Models in S, Wadsworth.

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

print.eff, summary.eff, plot.eff,  print.summary.eff,  print.effpoly, summary.effpoly, plot.effpoly, print.efflist, summary.efflist, plot.efflist, xyplot,
print.eff,summary.eff,plot.eff,print.summary.eff,print.effpoly,summary.effpoly,plot.effpoly,print.efflist,summary.efflist,plot.efflist,xyplot,


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


mod.cowles <- glm(volunteer ~ sex + neuroticism*extraversion,
    data=Cowles, family=binomial)
eff.cowles <- allEffects(mod.cowles, xlevels=list(neuroticism=0:24,
    extraversion=seq(0, 24, 6)), given.values=c(sexmale=0.5))
eff.cowles

plot(eff.cowles, 'sex', ylab="rob(Volunteer)")

plot(eff.cowles, 'neuroticism:extraversion', ylab="rob(Volunteer)",
    ticks=list(at=c(.1,.25,.5,.75,.9)))

plot(eff.cowles, 'neuroticism:extraversion', multiline=TRUE,
    ylab="rob(Volunteer)")
   
plot(effect('sex:neuroticism:extraversion', mod.cowles,
    xlevels=list(neuroticism=0:24, extraversion=seq(0, 24, 6))), multiline=TRUE)

mod.beps <- multinom(vote ~ age + gender + economic.cond.national +
                                economic.cond.household + Blair + Hague + Kennedy +
                                Europe*political.knowledge, data=BEPS)
plot(effect("Europe*political.knowledge", mod.beps,
        xlevels=list(Europe=1:11, political.knowledge=0:3)))
       
plot(effect("Europe*political.knowledge", mod.beps,
                xlevels=list(Europe=1:11, political.knowledge=0:3),
                given.values=c(gendermale=0.5)),
        style="stacked", colors=c("blue", "red", "orange"), rug=FALSE)
       
mod.wvs <- polr(poverty ~ gender + religion + degree + country*poly(age,3),
        data=WVS)
plot(effect("country*poly(age, 3)", mod.wvs))

plot(effect("country*poly(age, 3)", mod.wvs), style="stacked")
       
plot(effect("country*poly(age, 3)", latent=TRUE, mod.wvs))

mod.pres <- lm(prestige ~ log(income, 10) + poly(education, 3) + poly(women, 2),
    data=Prestige)
eff.pres <- allEffects(mod.pres, default.levels=50)
plot(eff.pres, ask=FALSE)

## Not run: [#不运行:]
        library(nlme) # for gls()[GLS()]
        mod.hart <- gls(fconvict ~ mconvict + tfr + partic + degrees, data=Hartnagel,
            correlation=corARMA(p=2, q=0), method="ML")
        plot(allEffects(mod.hart), ask=FALSE)

        library(lme4)
        data(cake, package="lme4")
        fm1 <- lmer(angle ~ recipe * temperature + (1|recipe:replicate), cake,
                   REML = FALSE)
        plot(effect("recipe:temperature", fm1), grid=TRUE)

        detach(package:lme4) # if previously attached[如果以前连接]
        library(nlme)
        data(cake, package="lme4")
        cake$rep <- with(cake, paste( as.character(recipe), as.character(replicate), sep=""))
        fm2 <- lme(angle ~ recipe * temperature, data=cake,
               random = ~ 1 | rep, method="ML")
        plot(effect("recipe:temperature", fm2), grid=TRUE)

## End(Not run)[#(不执行)]

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


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

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-5-13 04:12 , Processed in 0.027845 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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