gpt4 book ai didi

r - 非中心卡方概率和非中心参数

转载 作者:行者123 更新时间:2023-12-01 13:12:21 25 4
gpt4 key购买 nike

对于不同的临界值和自由度,我怎样才能得到给出恰好 0.9 概率的非中心参数值?

例如,显着性水平 = 0.05 且自由度为 1(临界值 = 3.84),ncp 必须等于 10.50742 才能获得 0.9 的概率:

1 - pchisq(3.841459, 1, 10.50742)
[1] 0.9

最佳答案

重新排列以下项:1 - pchisq(3.841459, 1, 10.50742) = 0.9 并将 abs 包裹在结果周围以构建最小化函数:

 optim( 1, function(x) abs(pchisq(3.841459, 1, x)  - 0.1) )
#-------
$par
[1] 10.50742

$value
[1] 1.740301e-08

$counts
function gradient
56 NA

$convergence
[1] 0

$message
NULL

要进行敏感性分析,您可以连续更改其他参数的值:

for( crit.val in seq(2.5, 3.5, by=0.1)) {
print( optim( 1,
function(x) abs(pchisq(crit.val, 1, x) - 0.1),
method="Brent" , lower=0, upper=20)$par)}
[1] 8.194852
[1] 8.375145
[1] 8.553901
[1] 8.731204
[1] 8.907135
[1] 9.081764
[1] 9.255156
[1] 9.427372
[1] 9.598467
[1] 9.768491
[1] 9.937492

关于r - 非中心卡方概率和非中心参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18421296/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com