[R] compare two matrices
Kehl Dániel
kehld at ktk.pte.hu
Tue Apr 10 10:26:42 CEST 2012
Dear Members,
I have two estimated transition matrices and I want to compare them.
In fact I want to check the hypothesis if they come from the same process.
I tried to look for some test but all I found was independence test of
contingency tables.
The following code shows that the usual chi-squared test statistic does
not follow chisq distribution.
MCRepl <- 5000
khi12 <- rep(0,MCRepl)
for (i in 1:MCRepl){
n <- 10000
M1 <- matrix(table(sample(1:9, size = n, replace = TRUE)),3,3)
M1 <- M1/rowSums(M1)
M2 <- matrix(table(sample(1:9, size = n, replace = TRUE)),3,3)
M2 <- M2/rowSums(M2)
khi12[i] <- sum((M1-M2)^2/M2)
}
plot(density(khi12))
Is there a procedure implemented in R to make this comparison? If not,
what could be a nice test statistic?
Thank you so much,
Daniel
More information about the R-help
mailing list