Skip to content

How to compute the P-value for a mixture of chi^2 distributions

6 messages · Tiago Pereira, Thomas Lumley, (Ted Harding) +1 more

#
Hello,

The test I am working on has an asymptotic 0.5*chi2(1)+0.5*chi2(2)
distribution, where numbers inside parenthesis stand for the degrees of
freedom. Is is possible to compute quickly in R the cumulative distribution
of that distribution?

Thanks in advance.

Tiago

--
View this message in context: http://r.789695.n4.nabble.com/How-to-compute-the-P-value-for-a-mixture-of-chi-2-distributions-tp3591276p3591276.html
Sent from the R help mailing list archive at Nabble.com.
#
On Sun, Jun 12, 2011 at 12:44 PM, Tiago Pereira
<tiago.pereira at mbe.bio.br> wrote:

            
There appear to be pchibar() functions in both the ibdreg and ic.infer
packages that should do want you want.  Simulation is also fairly
efficient.

    -thomas
#
On 12-Jun-11 01:36:00, Thomas Lumley wrote:
Is there anything wrong with the following argument:

In Tiago's notation, let X have the mixed chi2 distribution:

  X ~ chi2(1) with probability p
  X ~ chi2(2) with probability q = (1-p)

Then the cumulative distribution of X is

  Prob(X <= x) = p*Prob(chi2(1) <= x) + q*prob(chi2(2) <= x)

so the CDF is p*pchisq(x,1) + (1-p)*pchisq(x,2)

Inverting this to find the value of x for a given value P
of Prob(X <= x) = P is another matter, but should be reliably
solvable by using R's uniroot() function, with lower and
upper endpoints taken from whichever of qchisq(P,1), qchisq(P,2)
is smallest, and whichever is largest.

Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <ted.harding at wlandres.net>
Fax-to-email: +44 (0)870 094 0861
Date: 12-Jun-11                                       Time: 09:37:46
------------------------------ XFMail ------------------------------
#
On Jun 12, 2011, at 03:36 , Thomas Lumley wrote:

            
Assuming that you mean a 50-50 mixture of the two, it should also work just to take the average of the two CDFs. The integral is a linear operator after all.
1 day later