Alexandre Santos Aguiar
2005-Dec-06 18:48 UTC
[R] Coefficient of association for 2x2 contingency tables
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 - consultoria para pesquisa em sa??de - R Botucatu, 591 cj 81 tel 11-9320-2046 fax 11-5549-8760 www.spsconsultoria.com
Søren Højsgaard
2005-Dec-06 20:08 UTC
[R] Coefficient of association for 2x2 contingency tables
The CoCo bundle might contain various measures of association... S??ren ________________________________ Fra: r-help-bounces at stat.math.ethz.ch p?? vegne af Alexandre Santos Aguiar Sendt: ti 06-12-2005 19:48 Til: r-help Emne: [R] Coefficient of association for 2x2 contingency tables 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 - consultoria para pesquisa em sa??de - R Botucatu, 591 cj 81 tel 11-9320-2046 fax 11-5549-8760 www.spsconsultoria.com ______________________________________________ R-help at 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
Marc Schwartz (via MN)
2005-Dec-06 20:16 UTC
[R] Coefficient of association for 2x2 contingency tables
On Tue, 2005-12-06 at 16:48 -0200, 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, See the assocstats() function in the 'vcd' package on CRAN. HTH, Marc Schwartz
Bernardo Rangel tura
2005-Dec-07 07:46 UTC
[R] Coefficient of association for 2x2 contingency tables
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 AguiarIN 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