[R] testing independence of categorical variables
Bernardo Rangel Tura
tura at centroin.com.br
Mon Nov 26 09:28:39 CET 2007
On Thu, 2007-11-22 at 16:16 +0500, Shoaaib Mehmood wrote:
> hi,
>
> is there a way of calculating of measuring dependence between two
> categorical variables. i tried using the chi square test to test for
> independence but i got error saying that the lengths of the two
> vectors don't match. Suppose X and Y are two factors. X has 5 levels
> and Y has 7 levels. This is what i tried doing
>
> >temp<-chisq.test(x,y)
>
> but got error "the lengths of the two vectors don't match". any help
> will be appreciated
Hi Shoaaib,
Try using chisq.test(table(x,y)).
If you using chisq.test(x,y) R will testing goodness-of-fit.
--
Bernardo Rangel Tura, M.D,Ph.D
National Institute of Cardiology
Brazil
More information about the R-help
mailing list