eugen pircalabelu
2008-Jan-10 17:47 UTC
[R] question regarding hypothesis testing in contingency tables
Hi R-users!
I have the following example:
a<-data.frame(cat=c(5,10,15), dog=c(5,10, 15), mouse=c(10,10,20))
b<-data.frame(cat=c(15,10,5), dog=c(15, 10, 5), mouse=c(20,10,10))
rownames(b)<-c("scared", "happy", "sad")
rownames(a)<-c("scared", "happy", "sad")
Let's say that a and b are 2 contingency tables and 5,10, 15, 20 are
proportions of the whole sample (eg there are 5% animals that are both dogs and
scared in sample a). a and b are two different samples. Now, what i want is to
test the hypothesis that these two sample structures are similar. I know that
the chi square test, only handles one 2-dimensional contingency table, or a
3-dimensional one (mantelhaen. test), but I haven't seen a test that handles
2 separate 2-dimensional tables. Is there such a test?
Another thing that i want to see , is which cells differ one from another? Eg is
the 5 percent of scared dogs from sample a, different from 15% of scared dogs
form sample b? I would like something like the "adjusted standardized
reziduals" test from SPSS?
If i would compute by hand a z-statistic that tested the hypothesis that the 2
proportions are equal, would that be correct, since I have a multinomial
proportion and not a binomial one ?
Could I construct a confidence interval for my multinomial proportions in R
simultaneously ? If i would do it for each proportion by using the binomial
distribution would that affect the power of the test?
Thank you and have a great day!
---------------------------------
[[alternative HTML version deleted]]
Bernardo Rangel Tura
2008-Jan-13 12:42 UTC
[R] question regarding hypothesis testing in contingency tables
On Thu, 2008-01-10 at 09:47 -0800, eugen pircalabelu wrote:> Hi R-users! > > I have the following example: > a<-data.frame(cat=c(5,10,15), dog=c(5,10, 15), mouse=c(10,10,20)) > b<-data.frame(cat=c(15,10,5), dog=c(15, 10, 5), mouse=c(20,10,10)) > rownames(b)<-c("scared", "happy", "sad") > rownames(a)<-c("scared", "happy", "sad") >(...)> Another thing that i want to see , is which cells differ one from another? Eg is the 5 percent of scared dogs from sample a, > different from 15% of scared dogs form sample b? I would like something like the "adjusted standardized reziduals" test from SPSS?(...)> Thank you and have a great day!Hi Eugen! The adjusted standardized residuals is available in package gmodels require(gmodels) ?CrossTable -- Bernardo Rangel Tura, M.D,MPH,Ph.D National Institute of Cardiology Brazil