Off-center chi-square probability and off-center parameter

How can I get the value of the off-center parameter, which gives a probability of exactly 0.9 for different critical values ​​and degrees of freedom?

For example, with a significance level = 0.05 and 1 degree of freedom (critical value = 3.84), ncp should be equal to 10.50742 to get a probability of 0.9:

1 - pchisq(3.841459, 1, 10.50742) [1] 0.9 
+4
source share
1 answer

Rearrange the terms in: 1 - pchisq (3.841459, 1, 10.50742) = 0.9 and wrap around the result to build 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 perform a sensitivity analysis, you can subsequently change the values ​​of 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 
+6
source

Source: https://habr.com/ru/post/1498524/


All Articles