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

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

  [复制链接]
发表于 2012-10-2 07:43:40 | 显示全部楼层 |阅读模式
setx(Zelig)
setx()所属R语言包:Zelig

                                        Setting Explanatory Variable Values
                                         设置说明变量值

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

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

The setx command uses the variables identified in the formula generated by zelig and sets the values of the explanatory variables to the selected values.  Use setx after zelig and before sim to simulate quantities of
setx命令使用的变量中确定的formula所产生的zelig和解释变量的值设置到选定的值。使用setx后zelig前sim模拟量的


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


setx(object, ...)

## Default S3 method:[默认方法]
setx(object,
             fn = list(numeric = mean, ordered = median, other = mode),
             data = NULL,
             cond = FALSE, counter = NULL,
             ...
             )



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

参数:object
the saved output from zelig.  
已保存的输出从zelig。


参数:fn
a list of functions to apply to three types of variables:   
适用于三种类型的变量的函数的列表:

numericnumeric variables are set to their mean by default, but you may select any mathematical function to apply to numeric variables.  
默认情况下,他们的平均数字numeric变量的设置,但你可以选择任何适用于数值型变量的数学函数。

orderedordered factors are set to their meidan by default, and most mathematical operations will work on them.  If you select ordered = mean, however, setx will default to median with a warning.  
默认情况下,自己的美丹下令ordered的因素,对他们的工作和大部分的数学运算。如果您选择ordered = mean,但是,setx将默认的中位数警告。

othervariables may consist of unordered factors, character strings, or logical variables.  The other variables may only be set to their mode.  If you wish to set one of the other variables to a specific value, you may do so using ... below.   
othervariables可能由无序因素的影响,字符串或逻辑变量。 other变量只能被设置为他们的模式。如果你想其他变量设置为特定的值,你可以这样做...下面。

In the special case fn = NULL, setx will return all of the observations without applying any function to the data.   
在特殊情况下fn = NULL,setx将返回所有的意见,没有任何功能的数据。


参数:data
a new data frame used to set the values of explanatory variables. If data = NULL (the default), the data frame called in zelig is used.  
一个新的数据框,用于设置的值的解释变量。如果data = NULL(默认值),数据框称为zelig使用。


参数:cond
a logical value indicating whether unconditional (default) or conditional (choose cond = TRUE) prediction should be performed.  If you choose cond = TRUE, setx will coerce fn = NULL and ignore the additional arguments in  ....  If cond = TRUE and data = NULL, setx will prompt you for a data frame.     
一逻辑值,指示是否无条件的(默认)或有条件的(选择cond = TRUE)的预测应进行。如果你选择cond = TRUE,setx会强制fn = NULL和...忽略额外的参数。如果cond = TRUE和data = NULL,setx会提示你一个数据框。


参数:counter
a deprecated parameter
一个弃用的参数


参数:...
user-defined values of specific variables overwriting the default values set by the function fn.  For example, adding var1 = mean(data\$var1) or x1 = 12 explicitly sets the value of x1 to 12.  In addition, you may specify one explanatory variable as a range of values, creating one observation for every unique value in the range of values.  
用户定义的特定变量的值,覆盖默认值的功能fn。例如,添加var1 = mean(data\$var1)或x1 = 12明确的x1的值设置为12。此外,您可以指定一个解释变量的值的范围,创建一个观察值的范围在每一个独特的价值。


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

For unconditional prediction, x.out is a model matrix based on the specified values for the explanatory variables.  For multiple analyses (i.e., when choosing the by option in zelig, setx returns the selected values calculated over the entire data frame.  If you wish to calculate values over just one subset of the data frame, the 5th subset for example, you may use:   x.out <- setx(z.out[[5]])
对于无条件的预测,x.out是一个指定的值的基础上解释变量的模型矩阵。对于多个分析(即by选项时,选择zelig,setx返回选定的计算值在整个数据框。如果你想在仅有的一个子集的计算值数据框,第5子集,例如,你可以使用:x.out <- setx(z.out[[5]])

For conditional prediction, x.out includes the model matrix and the dependent variables.  For multiple analyses (when choosing the by option in zelig), setx returns the observed explanatory variables in each subset.
对于有条件的预测,x.out包括模型的矩阵变量和因变量。对于多个分析(by选项时,选择zelig),setx返回所观察到的解释变量在每个子集。


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



Kosuke Imai &lt;<a href="mailto:kimai@princeton.edu">kimai@princeton.edu</a>&gt;; Gary King
&lt;<a href="mailto:king@harvard.edu">king@harvard.edu</a>&gt;; Olivia Lau &lt;<a href="mailtolau@fas.harvard.edu">olau@fas.harvard.edu</a>&gt;




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

The full Zelig manual may be accessed online at
全策利希手册可在网上查询


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


# Unconditional prediction:[无条件的预测:]
data(turnout)
z.out <- zelig(vote ~ race + educate, model = "logit", data = turnout)
x.out <- setx(z.out)
s.out <- sim(z.out, x = x.out)

# Unconditional prediction with all observations:[所有观测无条件预测:]
x.out <- setx(z.out, fn = NULL)
s.out <- sim(z.out, x = x.out)

# Unconditional prediction with out of sample data:[无条件预测出来的样本数据:]
z.out <- zelig(vote ~ race + educate, model = "logit",
               data = turnout[1:1000,])
x.out <- setx(z.out, data = turnout[1001:2000,])
s.out <- sim(z.out, x = x.out)

# Using a user-defined function in fn:[使用用户定义的函数中fn:]
## Not run: [#不运行:]
quants <- function(x)
  quantile(x, 0.25)
x.out <- setx(z.out, fn = list(numeric = quants))

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

# Conditional prediction:  [有条件的预测:]
## Not run: library(MatchIt)[#运行库(MatchIt)]
data(lalonde)
match.out <- matchit(treat ~ age + educ + black + hispan + married +
                     nodegree + re74 + re75, data = lalonde)
z.out <- zelig(re78 ~ distance, data = match.data(match.out, "control"),
               model = "ls")
x.out <- setx(z.out, fn = NULL, data = match.data(match.out, "treat"),
              cond = TRUE)
s.out <- sim(z.out, x = x.out)

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

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


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

使用道具 举报

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

本版积分规则

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

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

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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