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

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

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

                                        Simulate Responses
                                         模拟响应

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

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

Simulate one or more responses from the distribution corresponding to a fitted model object.
模拟一个或多个相应的拟合模型对象分布的答复。


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


simulate(object, nsim = 1, seed = NULL, ...)



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

参数:object
an object representing a fitted model.
代表拟合模型对象。


参数:nsim
number of response vectors to simulate.  Defaults to 1.
响应向量的数量来模拟。 1默认。


参数:seed
an object specifying if and how the random number generator should be initialized ("seeded").<br> For the &quot;lm&quot; method, either NULL or an integer that will be used in a call to set.seed before simulating the response vectors.  If set, the value is saved as the "seed" attribute of the returned value.  The default, NULL will not change the random generator state, and return .Random.seed as the "seed" attribute, see "Value".  
一个对象,指定是否以及如何初始化随机数发生器应(种子)。参考“LM”的方法,无论是NULL或一个整数,将被用于在调用set.seed之前模拟的响应向量。如果设置,"seed"返回值的属性值将被保存。默认情况下,NULL不会改变的随机生成器的状态,并返回.Random.seed"seed"属性,看到“价值”。


参数:...
additional optional arguments.
额外的可选参数。


Details

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

This is a generic function.  Consult the individual modeling functions for details on how to use this function.
这是一个通用的功能。咨询有关如何使用此功能的详细信息,个别的建模功能。

Package stats has a method for "lm" objects which is used for lm and glm fits.  There is a method for fits from glm.nb in package MASS, and hence the case of negative binomial families is not covered by the "lm" method.
包stats有"lm"lm和glm适合使用的对象的方法。有一个方法适合glm.nb套件MASS,因此,负二项式家庭的情况下不"lm"方法覆盖。

The methods for linear models fitted by lm or glm(family   = "gaussian") assume that any weights which have been supplied are inversely proportional to the error variance.  For other GLMs the (optional) simulate component of the family object is used&mdash;there is no appropriate simulation method for "quasi" models as they are specified only up to two moments.
安装lm或glm(family   = "gaussian")认为任何已提供的重量是成反比的误差方差的线性模型的方法。 (可选)为其他GLMs的simulate组件family对象,也没有适当的模拟方法准的模式,因为他们被指定最多只有两个时刻。

For binomial and Poisson GLMs the dispersion is fixed at one.  Integer prior weights w_i can be interpreted as meaning that observation i is an average of w_i observations, which is natural for binomials specified as proportions but less so for a Poisson, for which prior weights are ignored with a warning.
为二项式和泊松GLMs的分散固定在一个。整数前重量w_i可以解释为,这意味着观察i是w_i意见,这是很自然的比例为指定的二项式,但泊松,其中前重量的平均警告被忽略。

For a gamma GLM the shape parameter is estimated by maximum likelihood (using function gamma.shape in package MASS).  The interpretation of weights is as multipliers to a basic shape parameter, since dispersion is inversely proportional to shape.
为伽马的GLM的形状参数的最大似然估计(使用功能gamma.shape在包MASS)。权的解释是,作为一个基本的形状参数的乘数,由于分散是成反比的塑造。

For an inverse gaussian GLM the model assumed is IG(&mu;_i, &lambda; w_i) (see http://en.wikipedia.org/wiki/Inverse_Gaussian_distribution) where &lambda; is estimated by the inverse of the dispersion estimate for the fit.  The variance is &mu;_i^3/(&lambda; w_i) and hence inversely proportional to the prior weights.  The simulation is done by function rinvGauss from the SuppDists package, which must be installed.
对于逆高斯的GLM模型假设是IG(&mu;_i, &lambda; w_i)(见http://en.wikipedia.org/wiki/Inverse_Gaussian_distribution)&lambda;适合分散估计逆估计。方差是&mu;_i^3/(&lambda; w_i)“,因此前的重量成反比。模拟功能做rinvGaussSuppDists包,必须安装的。


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

Typically, a list of length nsim of simulated responses.  Where appropriate the result can be a data frame (which is a special type of list).  
通常情况下,列表的长度nsim模拟反应。在适当的情况下,结果可能是一个数据框(这是一个特殊类型的列表)。

For the "lm" method, the result is a data frame with an attribute "seed".  If argument seed is NULL, the attribute is the value of .Random.seed before the simulation was started; otherwise it is the value of the argument with a "kind" attribute with value as.list(RNGkind()).
为"lm"方法,其结果是一个数据框的属性"seed"。如果参数seed是NULL属性.Random.seed模拟开始前的价值,否则它是一个"kind"属性的参数值与值 as.list(RNGkind())。


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

RNG about random number generation in R, fitted.values and residuals for related methods; glm, lm for model fitting.
RNGR中的随机数生成,fitted.values和residuals相关的方法,“glm,lm模型拟合。

There are further examples in the "simulate.R" tests file in the sources for package stats.
包simulate.R来源“stats测试文件有更多的例子。


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


x <- 1:5
mod1 <- lm(c(1:3, 7, 6) ~ x)
S1 <- simulate(mod1, nsim = 4)
## repeat the simulation:[#重复的模拟:]
.Random.seed <- attr(S1, "seed")
identical(S1, simulate(mod1, nsim = 4))

S2 <- simulate(mod1, nsim = 200, seed = 101)
rowMeans(S2) # should be about the same as[应该大致相同]
fitted(mod1)

## repeat identically:[#重复相同的:]
(sseed &lt;- attr(S2, "seed")) # seed; RNGkind as attribute[种子;作为属性RNGkind]
stopifnot(identical(S2, simulate(mod1, nsim = 200, seed = sseed)))

## To be sure about the proper RNGkind, e.g., after[#有关适当RNGkind,如要确定后,]
RNGversion("2.7.0")
## first set the RNG kind, then simulate[#首先设置RNG的那种,然后模拟]
do.call(RNGkind, attr(sseed, "kind"))
identical(S2, simulate(mod1, nsim = 200, seed = sseed))

## Binomial GLM examples[#二项式的GLM的例子]
yb1 <- matrix(c(4, 4, 5, 7, 8, 6, 6, 5, 3, 2), ncol = 2)
modb1 <- glm(yb1 ~ x, family = binomial)
S3 <- simulate(modb1, nsim = 4)
# each column of S3 is a two-column matrix.[S3的每一列是一个两列的矩阵。]

x2 <- sort(runif(100))
yb2 <- rbinom(100, prob = plogis(2*(x2-1)), size = 1)
yb2 <- factor(1 + yb2, labels = c("failure", "success"))
modb2 <- glm(yb2 ~ x2, family = binomial)
S4 <- simulate(modb2, nsim = 4)
# each column of S4 is a factor[S4的每一列是一个因素]

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


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

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-1-24 15:32 , Processed in 0.033746 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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