How can I get the value of the non-centrality parameter that gives a probability of exactly 0.9 for different critical values and degrees of freedom?
For example, with the significance level = 0.05 and 1 degree of freedom (critical value = 3.84), the ncp must be equal to 10.50742 in order to get a probability of 0.9:
1 - pchisq(3.841459, 1, 10.50742)
[1] 0.9
Rearrange terms in: 1 - pchisq(3.841459, 1, 10.50742) = 0.9 and wrap abs around the result to construct a minimization function:
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
To do a sensitivity analysis, you can serially alter the values of the other parameters:
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With