提问人:John hall 提问时间:9/11/2023 最后编辑:Rui BarradasJohn hall 更新时间:9/11/2023 访问量:31
绘制符号检验的幂函数
ploting power function of a sign test
问:
我正在尝试绘制符号测试的幂函数。我拥有的代码已经是这个:
library(BSDA) # for SIGN.test()
M_values <- seq(-1, 1, by = 0.1)
sign_rank_test_p<-vector("numeric",length=length(M_values))
sign_test_p<-vector("numeric", length=length(M_values))
n<-1000
lower_bounds <- matrix(nrow=n,ncol=length(M_values))
upper_bounds <- matrix(nrow=n,ncol=length(M_values))
center <- matrix(nrow=n,ncol=length(M_values))
for (i in seq_along(M_values)) {
for (j in 1:n){
M <- M_values[i]
value <- rnorm(1, mean = M, sd = 1)
lower_bounds[j,i] <- value-0.01
upper_bounds[j,i] <- value+0.01
center[j,i] <- (lower_bounds[j,i] + upper_bounds[j,i]) / 2
}
sign_test_p[i]<-SIGN.test(center[,i],md=0,alternative = "greater")$p.value
sign_rank_test_p[i]<-wilcox.test(center[,i], mu = 0, alternative = "greater")$p.value
}
# Create a data frame to store the results
results_df <- data.frame(M = M_values,
sign_test_p_value = sign_test_p,
signed_rank_test_p_value = sign_rank_test_p)
这将给出符号检验的 p 值。我们为 -1 和 1 之间的 M 值生成了 1000 个 p 值。
我现在想要的是绘制符号测试的幂函数并得出一些结论,但我不知道该怎么做。是使用 pwr.r.test 还是 power.sign.test?
答: 暂无答案
上一个:在 R 中绘制幂函数(假设检验)
下一个:根据 LFR 基准进行假设检验
评论
SIGN.test
不是基本 R 函数。使用非基本 R 函数的函数时,请调用脚本以加载所需的包。(已经完成了,我已经编辑了问题。library(pkgname)