Skip to content

Chi Square Test on two groups of variables

2 messages · Brett Stansfield, Guohui Ding

#
Dear R help
I have been trying to conduct a chi square test on two groups of variables
to test whether there is any relationship between the two sets of variables

chisq.test(oxygen, train)

        Pearson's Chi-squared test

data:  oxygen 
X-squared = 26.6576, df = 128, p-value = 1
Pearson's Chi-squared test

data:  oxygen 
X-squared = 26.6576, df = 128, p-value = 1

It looks as if R is only reading the first set of variables pertaining to
oxygen. Is there a way for it to test for two groups of variables?

brett stansfield

Brett Stansfield 
Environmental Scientist - Water Quality 
Hawke's Bay Regional Council 
102 Vautier Street 
Private Bag 6006 
Napier 
Phone (06) 835-9200 extn 9334 
Fax (06) 835-3601
#
If 'oxygen' is a matrix with one row or column, 'oxygen' is treated as
a one-dimensional contingency table.  In this case, the hypothesis
tested is whether the population probabilities equal those in 'p', or
are all equal  if 'p' is not given.

you can convert the 'oxygen' and 'train' variables to vector or take a
two-dimensional contingency table by matrix(c(oxygen, train), nr=2).

you will get more information when you type ?chisq.test.

2005/5/27, Brett Stansfield <brett at hbrc.govt.nz>: