Grokbase Groups R r-help May 2005
FAQ

[R] Chi Square Test on two groups of variables

Brett Stansfield
May 26, 2005 at 10:00 pm
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
chisq.test(oxygen)
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
reply

Search Discussions

1 response

  • Guohui Ding at May 27, 2005 at 1:22 am
    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 <bre...@...nz>:
    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
    chisq.test(oxygen)
    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

    ______________________________________________
    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

    --
    ADDRESS: Bioinformatics Center, Shanghai Institutes for Biological
    Sciences, Chinese Academy of Sciences
    320 Yueyang Road, Shanghai 200031, P.R.China
    TELEPHONE: 86-21-54920086

Related Discussions

Discussion Navigation
viewthread | post

2 users in discussion

Guohui Ding: 1 post Brett Stansfield: 1 post