[R] testing independence of categorical variables

Moshe Olshansky m_olshansky at yahoo.com
Fri Nov 23 00:57:40 CET 2007


Hi,

When testing whether random variables X and Y are
independent the usual assumption is that you have n
pairs of outcomes - (X1,Y1), (X2,Y2), ... , (Xn,Yn)
and you are basically checking whether the value of X
affects the value of Y.
If you have 7 observations of X and 5 separate
observations of Y (which have nothing to do with the
observations of X) you can not test for independence.

Regards,

Moshe.

--- Shoaaib Mehmood <shoaaib at gmail.com> 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
> -- 
> Regards,
> Rana Shoaaib Mehmood
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained,
> reproducible code.
>



More information about the R-help mailing list