aggregate-methods(simFrame)
aggregate-methods()所属R语言包:simFrame
Method for aggregating simulation results
聚集模拟结果的方法
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Aggregate simulation results, i.e, split the data into subsets if applicable and compute summary statistics.
总的模拟结果,即,将数据拆分到,如果适用,并计算汇总统计数据的子集。
用法----------Usage----------
## S4 method for signature 'SimResults'
aggregate(x, select = NULL, FUN = mean, ...)
参数----------Arguments----------
参数:x
the simulation results to be aggregated, i.e., an object of class "SimResults".
仿真结果进行汇总,,对象类"SimResults"。
参数:select
a character vector specifying the columns to be aggregated. It must be a subset of the colnames slot of x, which is the default.
字符向量指定的列进行汇总。它必须是一个colnames插槽x,这是默认的子集。
参数:FUN
a scalar function to compute the summary statistics (defaults to mean).
一个标量函数来计算的汇总统计数据(默认到mean)。
参数:...
additional arguments to be passed down to aggregate or apply.
其他参数传递给aggregate或apply。
值----------Value----------
If contamination or missing values have been inserted or the simulations have been split into different domains, a data.frame is returned, otherwise a vector.
如果污染或丢失已插入或模拟已经被分成不同的域值,一个data.frame返回,否则一个向量。
Details
详细信息----------Details----------
If contamination or missing values have been inserted or the simulations have been split into different domains, aggregate is called to compute the summary statistics for the respective subsets.
如果污染或丢失已插入或模拟已经被分成不同的域值,aggregate被称为计算的各个子集的摘要统计信息。
Otherwise, apply is called to compute the summary statistics for each column specified by select.
否则,apply被称为计算的汇总统计数据为每列指定的select。
方法----------Methods----------
x = "SimResults" aggregate simulation results.
x = "SimResults"总仿真结果。
(作者)----------Author(s)----------
Andreas Alfons
参考文献----------References----------
Statistical Simulation: The R Package <code>simFrame</code>. Journal of Statistical Software, 37(3), 1–36. URL http://www.jstatsoft.org/v37/i03/.
参见----------See Also----------
aggregate, apply, "SimResults"
aggregate,apply,"SimResults"
实例----------Examples----------
#### design-based simulation[###设计为基础的模拟]
set.seed(12345) # for reproducibility[可重复性]
data(eusilcP) # load data[加载数据]
## control objects for sampling and contamination[#控制对象的采样和污染]
sc <- SampleControl(size = 500, k = 50)
cc <- DARContControl(target = "eqIncome", epsilon = 0.02,
fun = function(x) x * 25)
## function for simulation runs[功能模拟运行]
sim <- function(x) {
c(mean = mean(x$eqIncome), trimmed = mean(x$eqIncome, 0.02))
}
## run simulation[#运行仿真]
results <- runSimulation(eusilcP,
sc, contControl = cc, fun = sim)
## aggregate[#总]
aggregate(results) # means of results[结果]
aggregate(results, FUN = sd) # standard deviations of results[标准偏差的结果]
#### model-based simulation[###基于模型的仿真]
set.seed(12345) # for reproducibility[可重复性]
## function for generating data[#,用于产生数据的功能]
rgnorm <- function(n, means) {
group <- sample(1:2, n, replace=TRUE)
data.frame(group=group, value=rnorm(n) + means[group])
}
## control objects for data generation and contamination[#控制对象的数据生成和污染]
means <- c(0, 0.25)
dc <- DataControl(size = 500, distribution = rgnorm,
dots = list(means = means))
cc <- DCARContControl(target = "value",
epsilon = 0.02, dots = list(mean = 15))
## function for simulation runs[功能模拟运行]
sim <- function(x) {
c(mean = mean(x$value),
trimmed = mean(x$value, trim = 0.02),
median = median(x$value))
}
## run simulation[#运行仿真]
results <- runSimulation(dc, nrep = 50,
contControl = cc, design = "group", fun = sim)
## aggregate[#总]
aggregate(results) # means of results[结果]
aggregate(results, FUN = sd) # standard deviations of results[标准偏差的结果]
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|