[R] Confidence interval for relative risk
David Duffy
David.Duffy at qimr.edu.au
Tue Nov 14 01:44:55 CET 2006
Michael Dewey <info at aghmed.fsnet.co.uk> wrote
>>> Subject: [R] Confidence interval for relative risk
>>>
>>> The concrete problem is that I am refereeing
>>> a paper where a confidence interval is
>>> presented for the risk ratio and I do not find
>>> it credible. I show below my attempts to
>>> do this in R. The example is slightly changed
>>> from the authors'.
>>>
>>> I can obtain a confidence interval for
>>> the odds ratio from fisher.test of
>>> course
>>>
>>> === fisher.test example ===
>>>
>>> > outcome <- matrix(c(500, 0, 500, 8), ncol = 2, byrow = TRUE)
>>> > fisher.test(outcome)
>>>
>>> Fisher's Exact Test for Count Data
>>>
>>> data: outcome
>>> p-value = 0.00761
>>> alternative hypothesis: true odds ratio is not equal to 1
>>> 95 percent confidence interval:
>>> 1.694792 Inf
>>> sample estimates:
>>> odds ratio
>>> Inf
>>>
>>> === end example ===
>>>
Since
RR = p1 + 1 p1=a/(a+b), p2=c/(c+d)
--------------
p2 1
----- + ---
1-p2 OR
you can backsolve for the RR CI.
> x <- function(p1, p2, oddsr) p1 + 1/(p2/(1-p2) + 1/oddsr)
> 1/x(8/508, 0, 1/1.694792)
[1] 1.650734
Another approach is the Cornfield method -- which is a profile likelihood based CI
using the Gibbs Chi-square (LRTS), but IIRC originally used the Pearson chi-square.
I don't think there are R implementations.
David Duffy.
--
| David Duffy (MBBS PhD) ,-_|\
| email: davidD at qimr.edu.au ph: INT+61+7+3362-0217 fax: -0101 / *
| Epidemiology Unit, Queensland Institute of Medical Research \_,-._/
| 300 Herston Rd, Brisbane, Queensland 4029, Australia GPG 4D0B994A v
More information about the R-help
mailing list