Wednesday, January 26, 2011

Comparing Risks

To evaluate whether an exposure is at all contributing to risk of disease, the simplest form of comparison is as follows:
x1 ~ Binomial(n1, pi1)
x2 ~ Binomial(n2, pi2)



Then, a variety of comparison can be performed with these two parameters pi1 and pi2: here is a list



Calculation of these measures can be done easily in R. The following example table can be used to illustrate:

 cross-sectional data

outcome



Diseased
Not diseased
Marginal total
exposure
Exposed
a = 23
b = 87
n1
Unexposed
c = 8
d = 92
n2
Marginal total

m1
m2
N


Here are the relevant codes:

 > # Data
> a = 23
> b = 87
> c = 8
> d = 92
> n1 = a + b
> n2 = c + d
> m1 = a + c
> m2 = b + d
> p1 = a/n1
> p2 = c/n2
> N = n1 + n2
> # Use of package
> require(epiR)
> epi.2by2(a,b,c,d, method = "cross.sectional", conf.level = 0.95, verbose = T)
$RR
       est      se    lower   upper
1 2.613636 1.47183 1.225322 5.57494

$OR
      est       se    lower    upper
1 3.04023 1.547831 1.291383 7.157442

$AR
       est      se  weight   lower    upper
1 12.90909 4.73221 446.552 3.63413 22.18405

$ARp
       est       se      lower    upper
1 6.761905 3.654011 -0.3998244 13.92363

$AFe
        est     lower     upper
1 0.6173913 0.1838878 0.8206259

$AFp
        est      lower     upper
1 0.4580645 0.04635869 0.6920288

$chisq
  test.statistic df     p.value
1        6.93727  1 0.008441788

> epi.2by2(a,b,c,d, method = "cross.sectional", conf.level = 0.95, verbose = F)
             Disease +    Disease -      Total        Prevalence *        Odds
Exposed +           23           87        110                20.9       0.264
Exposed -            8           92        100                 8.0       0.087
Total               31          179        210                14.8       0.173

Point estimates and 95 % CIs:
---------------------------------------------------------
Prevalence ratio                             2.61 (1.23, 5.57)
Odds ratio                                   3.04 (1.29, 7.16)
Attrib prevalence *                          12.91 (3.63, 22.18)
Attrib prevalence in population *            6.76 (-0.4, 13.92)
Attrib fraction in exposed (%)               61.74 (18.39, 82.06)
Attrib fraction in population (%)            45.81 (4.64, 69.2)
---------------------------------------------------------
 * Cases per 100 population units 
> # with out any external package
> RD = p1 - p2
> RD
[1] 0.1290909
> v.RD = p1*(1-p1)/n1 + p2*(1-p2)/n2
> c(RD - qnorm(.975)*sqrt(v.RD), RD + qnorm(.975)*sqrt(v.RD))
[1] 0.0363413 0.2218405
> RR = p1/p2
> RR
[1] 2.613636
> LRR = log(RR)
> LRR
[1] 0.9607425
> v.LRR = (1-p1)/(p1*n1) + (1-p2)/(p2*n2)
> c(LRR - qnorm(.975)*sqrt(v.LRR), LRR + qnorm(.975)*sqrt(v.LRR))
[1] 0.2032035 1.7182815
> OR  = (p1/(1-p1)) / (p2/(1-p2))
> OR
[1] 3.04023
> LOR  = log(OR)
> LOR
[1] 1.111933
> v.LOR = (1/(n1*p1*(1-p1))) + (1/(n2*p2*(1-p2)))
> c(LOR - qnorm(.975)*sqrt(v.LOR), LOR + qnorm(.975)*sqrt(v.LOR))
[1] 0.2557135 1.9681527

Asymmetric 95% confidence limits


 > c(exp(LRR - qnorm(.975)*sqrt(v.LRR)), exp(LRR + qnorm(.975)*sqrt(v.LRR)))
[1] 1.225322 5.574940
> c(exp(LOR - qnorm(.975)*sqrt(v.LOR)), exp(LOR + qnorm(.975)*sqrt(v.LOR)))
[1] 1.291383 7.157442


Reversing the groups, the theta2:1 estimates can be calculated:


 > RR21 = p2/p1
> RR21
[1] 0.3826087
> LRR21 = log(RR21)
> LRR21
[1] -0.9607425
> v.LRR21 = (1-p1)/(p1*n1) + (1-p2)/(p2*n2)
> c(LRR21 - qnorm(.975)*sqrt(v.LRR21),
+   LRR21 + qnorm(.975)*sqrt(v.LRR21))
[1] -1.7182815 -0.2032035
> OR21  = (p2/(1-p2)) / (p1/(1-p1))
> OR21
[1] 0.3289225
> LOR21  = log(OR21)
> LOR21
[1] -1.111933
> v.LOR21 = (1/(n1*p1*(1-p1))) + (1/(n2*p2*(1-p2)))
> c(LOR21 - qnorm(.975)*sqrt(v.LOR21),
+   LOR21 + qnorm(.975)*sqrt(v.LOR21))
[1] -1.9681527 -0.2557135

No comments:

Post a Comment