At 04:48 PM 12/6/2005, Alexandre Santos Aguiar wrote:
>Hi,
>
>Found no measure of association or correlation for 2x2 contingency tables in
>fullrefman.pdf or google. Can someone point to a package that implements such
>calculations?
>
>Thanx.
>
>--
>
>         Alexandre Santos Aguiar


IN vcd poackage have many measure.
If You Know formulae do do you create a function, example
epitable<-function(exposure, outcome,OR=F,RISK=F)
   {
   tab <- table(exposure, outcome,deparse.level = 2)
   a <- tab[1,1]; b <- tab[1,2]; c <- tab[2,1]; d <- tab[2,2]
   m1<-a+b; m2<-c+d; p1<-a/m1; p2<-c/m2
   if(RISK){
         rr <- (a / (a + b)) / (c / (c + d))
         se.log.rr <- sqrt((b / a) / (a + b) + (d / c) / (c + d))
         lci.rr <- exp(log(rr) - 1.96 * se.log.rr)
         uci.rr <- exp(log(rr) + 1.96 * se.log.rr)
         rd<-p1-p2
         se.rd.mle<-((p1*(1-p1))/m1)-((p2*(1-p2))/m2)
         se.rd.ub<-((p1*(1-p1))/(m1-1))-((p2*(1-p2))/(m2-1))
         lci.rd.mle<- rd - 1.96*se.rd.mle
         uci.rd.mle<- rd + 1.96*se.rd.mle
         lci.rd.ub<- rd - 1.96*se.rd.ub
         uci.rd.ub<- rd + 1.96*se.rd.ub
         }
   if(OR){
         or <- (a / b) / (c / d)
         se.log.or <- sqrt(1 / a + 1 / b + 1 / c + 1 / d)
         lci.or <- exp(log(or) - 1.96 * se.log.or)
         uci.or <- exp(log(or) + 1.96 * se.log.or)
         }
   print(tab)
   chi<-chisq.test(tab,correct=F)
if (OR | RISK){
         cat("_________________________________________________")
         cat("\n           Estimate                  95% CI ")
         cat("\n_________________________________________________\n")
         }
if (RISK){
         cat("RR        ",round(rr,3),"            ", 
round(lci.rr,3), round(uci.rr,3), "\n")
         cat("RD        ",round(rd,3),"            ", 
round(lci.rd.mle,3), round(uci.rd.mle,3), " (MLE)\n")
         cat("                             ", round(lci.rd.ub,3), 
round(uci.rd.ub,3), " (UB)\n")}
if (OR){cat("OR        ", round(or,3), "          ", round(lci.or,3), 
round(uci.or,3), "\n")}
if (OR | RISK){cat("_________________________________________________\n")}
   print(chi)
   }

FA<-rbinom(250,1,.3)
obito<-rbinom(250,1,.1)
epitable(FA,obito,RISK=T)




Bernardo Rangel Tura, MD, MSc
National Institute of Cardiology Laranjeiras
Rio de Janeiro Brazil

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to