simctest(simctest)
simctest()所属R语言包:simctest
Sequential implementation of Monte Carlo
顺序执行的蒙地卡罗
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Wrapper function for convenient use of the sequential implementation of the Monte Carlo test.
包装功能的Monte Carlo试验的顺序执行,方便使用。
用法----------Usage----------
simctest(gensample, level=0.05, epsilon=1e-3, maxsteps=1e4)
参数----------Arguments----------
参数:gensample
function that performs one sampling step. Returns 0 (sampled test statistic does not exceed the observation) or 1 (sampled test static exceeds the observation).
函数,它执行一个采样步骤。返回0(采样的检验统计量的观察不超过)或1(采样测试静态超过观察)。
参数:level
level passed to getalgonthefly
水平传递给getalgonthefly
参数:epsilon
error bound epsilon passed to getalgonthefly
错误绑定小量传递getalgonthefly的
参数:maxsteps
maximal number of steps to take
要采取的步骤的最大数量
值----------Value----------
An object of class sampalgres.
对象的类sampalgres。
(作者)----------Author(s)----------
Axel Gandy
参考文献----------References----------
with Uniformly Bounded Resampling Risk. To appear in JASA.
实例----------Examples----------
#Example used in the above paper[实施例用于在上述纸张]
dat <- matrix(nrow=5,ncol=7,byrow=TRUE,
c(1,2,2,1,1,0,1, 2,0,0,2,3,0,0, 0,1,1,1,2,7,3, 1,1,2,0,0,0,1, 0,1,1,1,1,0,0))
loglikrat <- function(data){
cs <- colSums(data)
rs <- rowSums(data)
mu <- outer(rs,cs)/sum(rs)
2*sum(ifelse(data<=0.5, 0,data*log(data/mu)))
}
resample <- function(data){
cs <- colSums(data)
rs <- rowSums(data)
n <- sum(rs)
mu <- outer(rs,cs)/n/n
matrix(rmultinom(1,n,c(mu)),nrow=dim(data)[1],ncol=dim(data)[2])
}
t <- loglikrat(dat);
# function to generate samples[函数来生成样本]
gen <- function(){loglikrat(resample(dat))>=t}
#using simctest[使用simctest]
simctest(gen,maxsteps=10000)
#now trying simctest.cont[现在试图simctest.cont的]
res <- simctest(gen,maxsteps=500)
res
cont(res,20000)
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|