[R] oddsratio epitool and chi-square
David martin
vilanew at gmail.com
Fri May 4 12:03:27 CEST 2012
Here is a working snippet.
library(epitools)
mat <- matrix(c(10,15,60,25,98, 12,10,70,28,14, 9,11,68,10,12
,8,13,20,11,58) ,ncol=2)
colnames(mat) <- c("treatmentA","treatmentB")
row.names(mat) <- paste("Cond",rep(1:10,1))
dimnames(mat) <- list("Condition" = row.names(mat), "instrument" =
colnames(mat))
> mat
instrument
Condition treatmentA treatmentB
Cond 1 10 9
Cond 2 15 11
Cond 3 60 68
Cond 4 25 10
Cond 5 98 12
Cond 6 12 8
Cond 7 10 13
Cond 8 70 20
Cond 9 28 11
Cond 10 14 13
# I'm not sure how to use the rev option of the oddsration works here.
I'm trying to see if any of the treatments has an effect on each
condition, so for example if treatment A has an effect on cond1 compared
to treatmentB. And so on for each condition.
I also don't understand why i get an NA value on cond10 ???
> oddsratio(mat,rev="r") . Shoudl this be rev="r" or rev="c"
$data
instrument
Condition treatmentA treatmentB Total
Cond 10 14 58 72
Cond 9 28 11 39
Cond 8 70 20 90
Cond 7 10 13 23
Cond 6 12 8 20
Cond 5 98 12 110
Cond 4 25 10 35
Cond 3 60 68 128
Cond 2 15 11 26
Cond 1 10 9 19
Total 342 220 562
$measure
odds ratio with 95% C.I.
Condition estimate lower upper
Cond 10 1.00000000 NA NA
Cond 9 0.09829116 0.03774410 0.23797549
Cond 8 0.07099961 0.03179722 0.14918984
Cond 7 0.31836593 0.11348206 0.89217010
Cond 6 0.16616586 0.05412347 0.48011838
Cond 5 0.03081892 0.01269306 0.06870094
Cond 4 0.10021240 0.03728880 0.24932078
Cond 3 0.27705710 0.13577945 0.53625865
Cond 2 0.18189409 0.06613614 0.47770002
Cond 1 0.22261481 0.07313306 0.65711936
$p.value
two-sided
Condition midp.exact fisher.exact chi.square
Cond 10 NA NA NA
Cond 9 8.154112e-08 1.049524e-07 5.662609e-08
Cond 8 5.306866e-14 6.524468e-14 1.539341e-13
Cond 7 2.978326e-02 2.860464e-02 2.092707e-02
Cond 6 8.811686e-04 1.259777e-03 3.660559e-04
Cond 5 0.000000e+00 3.867056e-22 3.600564e-21
Cond 4 2.707171e-07 3.071608e-07 1.590623e-07
Cond 3 9.355292e-05 1.212804e-04 1.149120e-04
Cond 2 5.085059e-04 7.732183e-04 2.499965e-04
Cond 1 6.702975e-03 6.992229e-03 3.499738e-03
$correction
[1] FALSE
attr(,"method")
[1] "median-unbiased estimate & mid-p exact CI"
>
More information about the R-help
mailing list