simSample(simFrame)
simSample()所属R语言包:simFrame
Set up multiple samples
设置多个样本
译者:生物统计家园网 机器人LoveR
描述----------Description----------
A convenience wrapper for setting up multiple samples using setup with control class SampleControl.
设立多个样本,使用setup控制类SampleControl,一个方便的包装。
用法----------Usage----------
simSample(x, design = character(), grouping = character(),
collect = FALSE, fun = srs, size = NULL,
prob = NULL, ..., k = 1)
参数----------Arguments----------
参数:x
the data.frame to sample from.
data.frame品尝。
参数:design
a character, logical or numeric vector specifying variables (columns) to be used for stratified sampling.
一个字符,逻辑或数值向量指定变量(列)被用于分层抽样。
参数:grouping
a character string, single integer or logical vector specifying a grouping variable (column) to be used for sampling whole groups rather than individual observations.
一个字符串,单整数或逻辑向量指定的一组变量(列)用于采样整个群体而非个人的意见的。
参数:collect
logical; if a grouping variable is specified and this is FALSE (which is the default value), groups are sampled directly. If grouping variable is specified and this is TRUE, individuals are sampled in a first step. In a second step, all individuals that belong to the same group as any of the sampled individuals are collected and added to the sample. If no grouping variable is specified, this is ignored.
逻辑,如果指定了一组变量,这是FALSE(这是默认值),组直接取样。如果分组变量指定这是TRUE,在第一步骤中进行采样,个人。在第二步骤中,所有的属于相同的组中的采样的任何个人的个人,被收集并添加到样品中。如果没有分组指定变量,这将被忽略。
参数:fun
a function to be used for sampling (defaults to srs). It should return a vector containing the indices of the sampled items (observations or groups).
一个函数来使用采样(默认到srs)。它应该返回一个向量,包含指数的样本项目(观察组)。
参数:size
an optional non-negative integer giving the number of items (observations or groups) to sample. For stratified sampling, a vector of non-negative integers, each giving the number of items to sample from the corresponding stratum.
一个可选的非负整数,给出样品中的项目的数目(观测或组)。对于分层抽样,一个向量的非负整数,每个样品给予的项目数从对应的阶层。
参数:prob
an optional numeric vector giving the probability weights, or a character string or logical vector specifying a variable (column) that contains the probability weights.
一个可选的数字向量给出概率权重,或指定的变量(列),其中包含的概率权重的一个字符串或逻辑向量。
参数:...
additional arguments to be passed to fun.
额外的参数传递给fun。
参数:k
a single positive integer giving the number of samples to be set up.
要设立一个单一的正整数,给出的样本数。
Details
详细信息----------Details----------
There are some restrictions on the argument names of the function supplied to fun. If it needs population data as input, the corresponding argument should be called x and should expect a data.frame. If the sampling method only needs the population size as input, the argument should be called N. Note that fun is not expected to have both x and N as arguments, and that the latter is much faster for stratified sampling or group sampling. Furthermore, if the function has arguments for sample size and probability weights, they should be called size and prob, respectively. Note that a function with prob as its only argument is perfectly valid (for probability proportional to size sampling). Further arguments of fun may be passed directly via the ... argument.
参数名称的功能提供给fun有一些限制。如果需要人口数据作为输入,相应的参数应该被称为x和预期data.frame。如果抽样的方法只需要输入的人口规模,参数应该被称为N。请注意,fun预计不会有两个x和N作为参数,而后者是更快的分层抽样或整群抽样的。此外,如果该函数有参数样本大小和概率权重,他们应该被称为size和prob“。需要注意的是同一个函数prob作为其唯一的参数是完全合法的概率成比例规模抽样。可能会通过直接通过进一步的论据fun ...的说法。
值----------Value----------
An object of class "SampleSetup".
对象的类"SampleSetup"。
(作者)----------Author(s)----------
Andreas Alfons
参见----------See Also----------
setup, "SampleControl", "SampleSetup"
setup,"SampleControl","SampleSetup"
实例----------Examples----------
data(eusilcP)
## simple random sampling[#简单随机抽样]
srss <- simSample(eusilcP, size = 20, k = 4)
summary(srss)
draw(eusilcP[, c("id", "eqIncome")], srss, i = 1)
## group sampling[#整群抽样]
gss <- simSample(eusilcP, grouping = "hid", size = 10, k = 4)
summary(gss)
draw(eusilcP[, c("hid", "id", "eqIncome")], gss, i = 2)
## stratified simple random sampling[#分层简单随机抽样]
ssrss <- simSample(eusilcP, design = "region",
size = c(2, 5, 5, 3, 4, 5, 3, 5, 2), k = 4)
summary(ssrss)
draw(eusilcP[, c("id", "region", "eqIncome")], ssrss, i = 3)
## stratified group sampling[#分层整群抽样]
sgss <- simSample(eusilcP, design = "region",
grouping = "hid", size = c(2, 5, 5, 3, 4, 5, 3, 5, 2), k = 4)
summary(sgss)
draw(eusilcP[, c("hid", "id", "region", "eqIncome")], sgss, i = 4)
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|