Hello, R users! I am struggling with the following problem: I need to compute a P-value for a mixture of two chi-squared distributions. My P-value is given by: P = 0.5*prob(sqrt(chi2(1)) <= x) + 0.5*prob(sqrt(chi2(2)) <= x) In words, I need to compute the p-value for 50?50 mixture of the square root of a chi-squared random variable with 1 degree of freedom and the square root of a chi-squared with two degrees of freedom. Although I can quickly simulate data, the P-values I am looking for are at the tail of the distribution, that is, alpha levels below 10^-7. Hence, simulation is not efficient. Are you aware of smart approach? All the best, Tiago
How to compute a P-value for a complex mixture of chi-squared distributions in R
5 messages · Peter Dalgaard, Tiago V. Pereira, Rui Barradas
On Jun 1, 2013, at 06:32 , Tiago V. Pereira wrote:
Hello, R users! I am struggling with the following problem: I need to compute a P-value for a mixture of two chi-squared distributions. My P-value is given by: P = 0.5*prob(sqrt(chi2(1)) <= x) + 0.5*prob(sqrt(chi2(2)) <= x) In words, I need to compute the p-value for 50?50 mixture of the square root of a chi-squared random variable with 1 degree of freedom and the square root of a chi-squared with two degrees of freedom. Although I can quickly simulate data, the P-values I am looking for are at the tail of the distribution, that is, alpha levels below 10^-7. Hence, simulation is not efficient. Are you aware of smart approach?
Er,... Anything wrong with 0.5 * pchisq(x^2, 1) + 0.5 * pchisq(x^2, 2) ??? -pd
All the best, Tiago
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com
Hello, No, nothing wrong. (I feel silly for not having noticed it.) In fact not only it's much simpler but it's also more accurate than the use of accurate with the default rel.tol. It should be better, however, to use lower.tail = FALSE, since the op wants p-values. 0.5 * pchisq(x^2, 1, lower.tail = FALSE) + 0.5 * pchisq(x^2, 2, lower.tail = FALSE) Rui Barradas Em 01-06-2013 14:57, peter dalgaard escreveu:
On Jun 1, 2013, at 06:32 , Tiago V. Pereira wrote:
Hello, R users! I am struggling with the following problem: I need to compute a P-value for a mixture of two chi-squared distributions. My P-value is given by: P = 0.5*prob(sqrt(chi2(1)) <= x) + 0.5*prob(sqrt(chi2(2)) <= x) In words, I need to compute the p-value for 50?50 mixture of the square root of a chi-squared random variable with 1 degree of freedom and the square root of a chi-squared with two degrees of freedom. Although I can quickly simulate data, the P-values I am looking for are at the tail of the distribution, that is, alpha levels below 10^-7. Hence, simulation is not efficient. Are you aware of smart approach?
Er,... Anything wrong with 0.5 * pchisq(x^2, 1) + 0.5 * pchisq(x^2, 2) ??? -pd
All the best, Tiago
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Thank you very much, Rui and Peter, for you detailed and helpful tips! It worked like a charm! I would spend more two weeks (or more) to figure out that by myself. Cheers! Tiago
Hello, No, nothing wrong. (I feel silly for not having noticed it.) In fact not only it's much simpler but it's also more accurate than the use of accurate with the default rel.tol. It should be better, however, to use lower.tail = FALSE, since the op wants p-values. 0.5 * pchisq(x^2, 1, lower.tail = FALSE) + 0.5 * pchisq(x^2, 2, lower.tail = FALSE) Rui Barradas Em 01-06-2013 14:57, peter dalgaard escreveu:
On Jun 1, 2013, at 06:32 , Tiago V. Pereira wrote:
Hello, R users! I am struggling with the following problem: I need to compute a P-value for a mixture of two chi-squared distributions. My P-value is given by: P = 0.5*prob(sqrt(chi2(1)) <= x) + 0.5*prob(sqrt(chi2(2)) <= x) In words, I need to compute the p-value for 50?50 mixture of the square root of a chi-squared random variable with 1 degree of freedom and the square root of a chi-squared with two degrees of freedom. Although I can quickly simulate data, the P-values I am looking for are at the tail of the distribution, that is, alpha levels below 10^-7. Hence, simulation is not efficient. Are you aware of smart approach?
Er,... Anything wrong with 0.5 * pchisq(x^2, 1) + 0.5 * pchisq(x^2, 2) ??? -pd
All the best, Tiago
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Inline. Em 01-06-2013 19:41, Rui Barradas escreveu:
Hello, No, nothing wrong. (I feel silly for not having noticed it.) In fact not only it's much simpler but it's also more accurate than the use of accurate with the default rel.tol.
Correction: "...than the use of _integrate()_ with the default rel.tol." Rui Barradas
It should be better, however, to use lower.tail = FALSE, since the op wants p-values. 0.5 * pchisq(x^2, 1, lower.tail = FALSE) + 0.5 * pchisq(x^2, 2, lower.tail = FALSE) Rui Barradas Em 01-06-2013 14:57, peter dalgaard escreveu:
On Jun 1, 2013, at 06:32 , Tiago V. Pereira wrote:
Hello, R users! I am struggling with the following problem: I need to compute a P-value for a mixture of two chi-squared distributions. My P-value is given by: P = 0.5*prob(sqrt(chi2(1)) <= x) + 0.5*prob(sqrt(chi2(2)) <= x) In words, I need to compute the p-value for 50?50 mixture of the square root of a chi-squared random variable with 1 degree of freedom and the square root of a chi-squared with two degrees of freedom. Although I can quickly simulate data, the P-values I am looking for are at the tail of the distribution, that is, alpha levels below 10^-7. Hence, simulation is not efficient. Are you aware of smart approach?
Er,... Anything wrong with 0.5 * pchisq(x^2, 1) + 0.5 * pchisq(x^2, 2) ??? -pd
All the best, Tiago
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.