help please. 2 tables, which test?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

help please. 2 tables, which test?

aaral singh
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: help please. 2 tables, which test?

glsnow
The chi-squared test is one option (and seems reasonable to me if it
the the proportions/patterns that you want to test).  One way to do
the test is to combine your 2 matrices into a 3 dimensional array (the
abind package may help here) and test using the loglin function.

On Thu, Mar 8, 2012 at 5:46 AM, aaral singh <[hidden email]> wrote:

> Hi.Please help if someone can.
>
> Problem:
> I have 2 matrices
>
> Eg
>
> matrix 1:
>                Freq  None  Some
>  Heavy    3        2          5
>  Never    8       13         8
>  Occas    1        4          4
>  Regul     9        5         7
>
> matrix 2:
>                  Freq     None     Some
>  Heavy        7          1             3
>  Never      87         18          84
>  Occas      12           3            4
>  Regul        9            1            7
>
>
> I want to see if matrix 1 is significantly different from matrix 2. I
> consider using a chi-squared test. Is this appropriate?
> Could anyone advise?
> Many thank you.
> Aaral Singh
>
> --
> View this message in context: http://r.789695.n4.nabble.com/help-please-2-tables-which-test-tp4456312p4456312.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] 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.



--
Gregory (Greg) L. Snow Ph.D.
[hidden email]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: help please. 2 tables, which test?

aaral singh
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: help please. 2 tables, which test?

Michael Weylandt
You should probably read up on what the chi-squared test actually
tests: in one form, it asks whether some set of observations could
have come from a given multinomial distribution. Concretely, it asks
whether it is "reasonable" to get 3 blues, 4 reds, and 2 whites from a
uniform distribution over read white and blue. (Real statisticians
will have all sorts of problems with that over-simplification) What
you seem to be asking is whether it is "reasonable" to get 3 blues 4
reds, 2 whites, and 6 greens from a uniform distribution over red
white and blue -- obviously something doesn't fit here. Caveat: if
matrix1 matches matrix2 but there were null observations that got
dropped, then this can be done.

https://en.wikipedia.org/wiki/Pearson%27s_chi-squared_test

The website http://stats.stackexchange.com/ can (and will) provide
more statistically oriented help.

Michael

On Fri, Mar 9, 2012 at 11:46 AM, aoife doherty <[hidden email]> wrote:

> Thank you. Can the chi-squared test compare two matrices that are not the
> same size, eg if matrix 1 is a 2 X 4 table, and matrix 2 is a 3 X 5 matrix?
>
>
> On Fri, Mar 9, 2012 at 4:37 PM, Greg Snow <[hidden email]> wrote:
>
>> The chi-squared test is one option (and seems reasonable to me if it
>> the the proportions/patterns that you want to test).  One way to do
>> the test is to combine your 2 matrices into a 3 dimensional array (the
>> abind package may help here) and test using the loglin function.
>>
>> On Thu, Mar 8, 2012 at 5:46 AM, aaral singh <[hidden email]> wrote:
>> > Hi.Please help if someone can.
>> >
>> > Problem:
>> > I have 2 matrices
>> >
>> > Eg
>> >
>> > matrix 1:
>> >                Freq  None  Some
>> >  Heavy    3        2          5
>> >  Never    8       13         8
>> >  Occas    1        4          4
>> >  Regul     9        5         7
>> >
>> > matrix 2:
>> >                  Freq     None     Some
>> >  Heavy        7          1             3
>> >  Never      87         18          84
>> >  Occas      12           3            4
>> >  Regul        9            1            7
>> >
>> >
>> > I want to see if matrix 1 is significantly different from matrix 2. I
>> > consider using a chi-squared test. Is this appropriate?
>> > Could anyone advise?
>> > Many thank you.
>> > Aaral Singh
>> >
>> > --
>> > View this message in context:
>> http://r.789695.n4.nabble.com/help-please-2-tables-which-test-tp4456312p4456312.html
>> > Sent from the R help mailing list archive at Nabble.com.
>> >
>> > ______________________________________________
>> > [hidden email] 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.
>>
>>
>>
>> --
>> Gregory (Greg) L. Snow Ph.D.
>> [hidden email]
>>
>> ______________________________________________
>> [hidden email] 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.
>>
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: help please. 2 tables, which test?

Stephen Ellison
In reply to this post by aaral singh
 

> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of aoife doherty
>
> Thank you. Can the chi-squared test compare two matrices that
> are not the same size, eg if matrix 1 is a 2 X 4 table, and
> matrix 2 is a 3 X 5 matrix?

No.

S*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: help please. 2 tables, which test?

glsnow
In reply to this post by aaral singh
Just what null hypothesis are you trying to test or what question are
you trying to answer by comparing 2 matrices of different size?

I think you need to figure out what your real question is before
worrying about which test might work on it.

Trying to get your data to fit a given test rather than finding the
appropriate test or other procedure to answer your question is like
buying a new suit then having plastic surgery to make you fit the suit
rather than having the tailor modify the suit to fit you.

If you can give us more information about what your question is we
have a better chance of actually helping you.

On Fri, Mar 9, 2012 at 9:46 AM, aoife doherty <[hidden email]> wrote:

>
> Thank you. Can the chi-squared test compare two matrices that are not the
> same size, eg if matrix 1 is a 2 X 4 table, and matrix 2 is a 3 X 5 matrix?
>
>
>
> On Fri, Mar 9, 2012 at 4:37 PM, Greg Snow <[hidden email]> wrote:
>>
>> The chi-squared test is one option (and seems reasonable to me if it
>> the the proportions/patterns that you want to test).  One way to do
>> the test is to combine your 2 matrices into a 3 dimensional array (the
>> abind package may help here) and test using the loglin function.
>>
>> On Thu, Mar 8, 2012 at 5:46 AM, aaral singh <[hidden email]> wrote:
>> > Hi.Please help if someone can.
>> >
>> > Problem:
>> > I have 2 matrices
>> >
>> > Eg
>> >
>> > matrix 1:
>> >                Freq  None  Some
>> >  Heavy    3        2          5
>> >  Never    8       13         8
>> >  Occas    1        4          4
>> >  Regul     9        5         7
>> >
>> > matrix 2:
>> >                  Freq     None     Some
>> >  Heavy        7          1             3
>> >  Never      87         18          84
>> >  Occas      12           3            4
>> >  Regul        9            1            7
>> >
>> >
>> > I want to see if matrix 1 is significantly different from matrix 2. I
>> > consider using a chi-squared test. Is this appropriate?
>> > Could anyone advise?
>> > Many thank you.
>> > Aaral Singh
>> >
>> > --
>> > View this message in context:
>> > http://r.789695.n4.nabble.com/help-please-2-tables-which-test-tp4456312p4456312.html
>> > Sent from the R help mailing list archive at Nabble.com.
>> >
>> > ______________________________________________
>> > [hidden email] 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.
>>
>>
>>
>> --
>> Gregory (Greg) L. Snow Ph.D.
>> [hidden email]
>>
>> ______________________________________________
>> [hidden email] 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.
>
>



--
Gregory (Greg) L. Snow Ph.D.
[hidden email]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: help please. 2 tables, which test?

aaral singh
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: help please. 2 tables, which test?

glsnow
For this case I would use a permutation test.  Start by choosing some
statistic that represents your 4 students across the different grades,
some possibilities would be the sum of scores across grades and
students, or mean, or median, or ...

Compute the selected statistic for your 4 students and save that
value.  Now select 4 students at random and compute the same
statistic, repeat this a bunch of times (thousands) and compute the
statistic each time.  All those stats on the random selections
represent the distribution of the statistic under the null hypothesis
that your 4 students were randomly chosen (vs. chosen based on
something that is related to the grade).  Now you just compare the
stat on the original 4 students to the distribution (if you need a
specific p-value it is just the proportion of the random stats that
are as or more extreme as your original 4).

On Sat, Mar 10, 2012 at 4:04 AM, aoife doherty <[hidden email]> wrote:

> Thank you for the replies.
> So what my test wants to do is this:
>
> I have a big matrix, 30 rows (students in a class) X 50 columns (students
> grades for the year).
> An example of the matrix is as such:
>
>
>                     grade1       grade2        grade3     .....  grade 50
> student 1
> student 2***
> student 3
> student 4***
> student 5***
> student 6
> .
> .
> .
> .
> .
> student 30***
>
> As you can see, four students (students 2,4,5 and 30) have stars beside
> their name. I have chosen these students based on a particular
> characteristic that they all share.I then pulled these students out to make
> a new table:
>
>                     grade1          grade2         grade3 ....... grade 50
>
> student 2
> student 4
> student 5
> student 30
>
>
> and what i want to see is basically is there any difference between the
> grades this particular set of students(i.e. student 2,4,5 and 30) got, and
> the class as a whole?
>
> So my null hypothesis is that there is no difference between this set of
> students grades, and what you would expect from the class as a whole.
>
> Aaral
>
>
>
>
>
>
> On Sat, Mar 10, 2012 at 12:18 AM, Greg Snow <[hidden email]> wrote:
>>
>> Just what null hypothesis are you trying to test or what question are
>> you trying to answer by comparing 2 matrices of different size?
>>
>> I think you need to figure out what your real question is before
>> worrying about which test might work on it.
>>
>> Trying to get your data to fit a given test rather than finding the
>> appropriate test or other procedure to answer your question is like
>> buying a new suit then having plastic surgery to make you fit the suit
>> rather than having the tailor modify the suit to fit you.
>>
>> If you can give us more information about what your question is we
>> have a better chance of actually helping you.
>>
>> On Fri, Mar 9, 2012 at 9:46 AM, aoife doherty <[hidden email]>
>> wrote:
>> >
>> > Thank you. Can the chi-squared test compare two matrices that are not
>> > the
>> > same size, eg if matrix 1 is a 2 X 4 table, and matrix 2 is a 3 X 5
>> > matrix?
>> >
>> >
>> >
>> > On Fri, Mar 9, 2012 at 4:37 PM, Greg Snow <[hidden email]> wrote:
>> >>
>> >> The chi-squared test is one option (and seems reasonable to me if it
>> >> the the proportions/patterns that you want to test).  One way to do
>> >> the test is to combine your 2 matrices into a 3 dimensional array (the
>> >> abind package may help here) and test using the loglin function.
>> >>
>> >> On Thu, Mar 8, 2012 at 5:46 AM, aaral singh <[hidden email]>
>> >> wrote:
>> >> > Hi.Please help if someone can.
>> >> >
>> >> > Problem:
>> >> > I have 2 matrices
>> >> >
>> >> > Eg
>> >> >
>> >> > matrix 1:
>> >> >                Freq  None  Some
>> >> >  Heavy    3        2          5
>> >> >  Never    8       13         8
>> >> >  Occas    1        4          4
>> >> >  Regul     9        5         7
>> >> >
>> >> > matrix 2:
>> >> >                  Freq     None     Some
>> >> >  Heavy        7          1             3
>> >> >  Never      87         18          84
>> >> >  Occas      12           3            4
>> >> >  Regul        9            1            7
>> >> >
>> >> >
>> >> > I want to see if matrix 1 is significantly different from matrix 2. I
>> >> > consider using a chi-squared test. Is this appropriate?
>> >> > Could anyone advise?
>> >> > Many thank you.
>> >> > Aaral Singh
>> >> >
>> >> > --
>> >> > View this message in context:
>> >> >
>> >> > http://r.789695.n4.nabble.com/help-please-2-tables-which-test-tp4456312p4456312.html
>> >> > Sent from the R help mailing list archive at Nabble.com.
>> >> >
>> >> > ______________________________________________
>> >> > [hidden email] 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.
>> >>
>> >>
>> >>
>> >> --
>> >> Gregory (Greg) L. Snow Ph.D.
>> >> [hidden email]
>> >>
>> >> ______________________________________________
>> >> [hidden email] 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.
>> >
>> >
>>
>>
>>
>> --
>> Gregory (Greg) L. Snow Ph.D.
>> [hidden email]
>>
>> ______________________________________________
>> [hidden email] 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.
>
>



--
Gregory (Greg) L. Snow Ph.D.
[hidden email]

______________________________________________
[hidden email] 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.