提问人:Nate 提问时间:11/14/2023 最后编辑:Nate 更新时间:11/17/2023 访问量:115
pwrss::p ower.t.test 警告 - “alternative = 'less' but non-centrality parameter is positive”
pwrss::power.t.test warning - "alternative = 'less' but non-centrality parameter is positive"
问:
我正在尝试计算检测平均密度(log(x+1) 变换)的假设变化(增加 30%,然后也减少 30%)所需的功效。使用这篇文章中的公式,我的非中心性参数 (ncp) 值为正(在这两种情况下)。当 alternative=“less” 时,它会产生以下警告。
# 30% hypothetical increase
power.t.test(ncp = (0.4940*sqrt(47)), # ncp = ((ln_up = 0.4940)*sqrt(n=47)) = 3.386693
df = 46, # df = n-1 = 46
alpha = 0.05,
alternative = "less",
plot = TRUE)
power ncp.alt ncp.null alpha df t.crit
0.9546192 3.387 0 0.05 46 1.67866
Warning message:
alternative = 'less' but non-centrality parameter is positive
我的主要问题是如何解决警告问题(我认为这些功率计算是错误的)?根据我的数据,计算负值和正值的正确 ncp 公式是什么?
数据:
structure(list(Season = "DRY", assem = "Far", n = 47L, mean_log_den = 0.38,
ln_up = 0.494, ln_down = 0.266), class = c("grouped_df",
"tbl_df", "tbl", "data.frame"), row.names = c(NA, -1L), groups = structure(list(
Season = "DRY", .rows = structure(list(1L), ptype = integer(0), class = c("vctrs_list_of",
"vctrs_vctr", "list"))), class = c("tbl_df", "tbl", "data.frame"
), row.names = c(NA, -1L), .drop = TRUE))
- mean_log_den = 密度的平均对数(x+1)变换(数据右偏,有许多零)
- ln_up = 0.4940 = 假设 30% 的mean_log_den
- ln_down = 假设mean_log_den减少 30%
答:
1赞
Nate
11/16/2023
#1
mu_0 = 0.3799 # Null hypothesis (no change in mean)
mu = 0.2659 # Alternative (30% decline in mean)
n = 47 # Sample size per group
d = -0.114 # Direction of change
sd = 0.4352 # Sample sd
cor = 0.5 # R assumed correlation between repeated measures
# 3 options...
ncp_1 = (mu - mu_0) * sqrt(n)/sd
ncp_2 = d / (sd / sqrt(n))
ncp_3 = d * sqrt(n) / sqrt(2*sd^2 * (1 - cor))
pwrss::power.t.test(ncp = c(ncp_1, ncp_2, ncp_3),
df = n-1,
alpha = 0.05,
alternative = "less",
plot = FALSE)
power ncp.alt ncp.null alpha df t.crit
0.5495299 -1.796 0 0.05 46 1.67866
0.5495299 -1.796 0 0.05 46 1.67866
0.5495299 -1.796 0 0.05 46 1.67866
评论
0.38*sqrt(47))