[R] R help contingency table

Lucie Dupond loupiote93 at hotmail.fr
Mon Jun 20 04:09:44 CEST 2016


Hello,
I'm sorry if my question is really basic, but I'm having some troubles with the statistics for my thesis, and especially the khi square test and contingency tables.

For what I understood, there are two "kinds" of khisquare test, that are quite similar :
- Homogeneity, when we have one variable and we want to compare it with a theorical distribution
- Independence test, when we have 2 variable and we want to see if they are linked

-- -

I'm working on color transitions, with 3 possible factors : « High » , « Medium » and « Low »
I want to know if an individual will go preferably from a color « High » to another color « High », more than from a color « High » to a color « Medium » (for example)

I have this table :

trans1<-c(51,17,27,12,21,13,37,15,60)
transitions1<-matrix(trans1, nrow=3, ncol=3, byrow=T)
rownames(transitions1) <- c("High"," Medium", "Low")
colnames(transitions1) <- c("High"," Medium", "Low")

The first colomn is showing the first color, and the second is showing the second color of the transition

It looks like I'm in the case of an Independence test, in order to see if the variable "second color" is linked to the "first color".

So I'm making the test :

chisq.test(transitions1)


(If I understood well, the test on the matrix is the independence  test, and the test on the vector trans1 is the homogeneity test ?)

The result is significatif, it means that some transitions are prefered.

My problem is that I have other transition tables like this one (with other individuals or other conditions)
For example, I also have this one :


trans2<-c(13,7,8,5,16,18,11,8,17)
transitions2<-matrix(trans2, nrow=3, ncol=3, byrow=T)
rownames(transitions2) <- c("High","Low", "Stick")
colnames(transitions2) <- c("High","Low", "Stick")

I want to know if the "prefered" transitions in the table 1 are the same in the table 2.
But if I try a khisquare test on those two matrix, R only takes the first one.

How can I compare those tables
Maybe with another test ?

Thanks in advance !

Kind regards

Lucie S.

	[[alternative HTML version deleted]]



More information about the R-help mailing list