- Opción 1:
> datos2 = matrix (data = c(740,260,350,650), ncol=2, nrow=2) > datos2 [,1] [,2] [1,] 740 350 [2,] 260 650
- Opción 2
> prueba = c(340,100,400,160) > prueba2 = matrix(prueba, byrow=T,ncol=2) > prueba2 [,1] [,2] [1,] 340 100 [2,] 400 160
Lo siguiente sería renombrar las filas y columnas.
> colnames(datos2) = c ('cases','controls') > rownames(datos2) = c ('exposed','noexposed')
Para calcular rápidamente los estadísticos Chi-cuadrado, P-value y hacer el contraste de hipótesis correspondiente solo necesitamos la siguiente función:
> prop.test(datos2) 2-sample test for equality of proportions with continuity correction data: datos2 X-squared = 305.1134, df = 1, p-value < 2.2e-16 alternative hypothesis: two.sided 95 percent confidence interval: 0.3518061 0.4345635 sample estimates: prop 1 prop 2 0.6788991 0.2857143
> epi.2by2(datos2, method="cohort.count") Disease + Disease - Total Inc risk * Odds Exposed + 740 350 1090 67.9 2.11 Exposed - 260 650 910 28.6 0.40 Total 1000 1000 2000 50.0 1.00 Point estimates and 95 % CIs: --------------------------------------------------------- Inc risk ratio 2.38 (2.13, 2.65) Odds ratio 5.28 (4.34, 6.44) Attrib risk * 39.32 (35.28, 43.36) Attrib risk in population * 21.43 (17.77, 25.09) Attrib fraction in exposed (%) 57.92 (53, 62.32) Attrib fraction in population (%) 42.86 (37.88, 47.44) --------------------------------------------------------- * Cases per 100 population units