Question about cochran test in R
Hi Luis, (Let's keep R-help in the loop for the benefit of others.)
On 2015-05-08 10:25, Luis Fernando Garc?a wrote:
Thanks a lot for your replies Henry! Your answer was specially a bless! Many thanks this was an issue which was breaking my head. I have another couple of questions, may be you could help me. For post hoc comparison I was planning to run a McNemar test with a bonferroni correction, but wanted to be sure my approach is correct.
It's an OK approach, I guess, but you should use the Holm correction rather than Bonferroni. (Holm dominates Bonferroni and is valid under the same arbitrary assumptions.) The "classical" approach, and as suggested in Cochran (1950), would be to partition the chi-squared statistic into components of interest. In a more general approach, a test of all the post-hoc comparisons is performed simultaneously. This is very efficient, in terms of power, since it takes account of the correlation between the test statistics. Ignoring such dependencies may result in "strange" results, due to loss of power, where none of the partial null hypotheses are rejected even though the global null hypothesis is rejected. Unfortunately, I'm not aware of any publicly available software that let's you do this. In theory, 'coin' should be able to, and there has even been some work done in this direction, but it's currently unfinished. Henric Winell
Sorry if I annoy you with this remaining question.
Thanks in advance!
2015-05-07 8:03 GMT-03:00 Henric Winell <nilsson.henric at gmail.com
<mailto:nilsson.henric at gmail.com>>:
On 2015-05-07 09:15, Jim Lemon wrote:
Hi Luis,
Try this page:
http://www.r-bloggers.com/cochran-q-test-for-k-related-samples-in-r/
Jim
Cochran's Q test is a marginal homogeneity test, and such tests can
be performed by the 'mh_test' function in the 'coin' package. The
following replicates the result in the blog post
> library("coin")
>
> dta <- data.frame(
+ method = factor(rep(LETTERS[1:4], 6)),
+ repellent = factor(c(1, 1, 0, 0,
+ 1, 1, 0, 1,
+ 1, 0, 0, 0,
+ 1, 1, 1, 0,
+ 1, 1, 0, 1,
+ 1, 1, 0, 1)),
+ fabric = gl(6, 4, labels = as.roman(1:6))
+ )
>
> mh_test(repellent ~ method | fabric, data = dta)
Asymptotic Marginal-Homogeneity Test
data: repellent by
method (A, B, C, D)
stratified by fabric
chi-squared = 9.3158, df = 3, p-value = 0.02537
and uses the asymptotic approximation to compute the p-value. The
'coin' package also allows you to approximate the exact null
distribution using Monte Carlo methods:
> set.seed(123)
> mh_test(repellent ~ method | fabric, data = dta,
+ distribution = approximate(B = 10000L))
Approximative Marginal-Homogeneity Test
data: repellent by
method (A, B, C, D)
stratified by fabric
chi-squared = 9.3158, p-value = 0.0202
For future reference, 'mh_test' is fairly general and handles both
matched pairs or matched sets. So, the well-known tests due
McNemar, Cochran, Stuart(-Maxwell) and Madansky are just special cases.
For more general symmetry test problems, the 'coin' package offers
the 'symmetry_test' function and this can be used to perform, e.g.,
multivariate marginal homogeneity tests like the multivariate
McNemar test (Klingenberg and Agresti, 2006) or the multivariate
Friedman test (Gerig, 1969).
Henric
On Thu, May 7, 2015 at 4:59 PM, Luis Fernando Garc?a
<luysgarcia at gmail.com <mailto:luysgarcia at gmail.com>> wrote:
Dear R Experts,
May be this is a basic question for you, but it is something
I need really
urgently. I need to perform a Chi Square analysis for more
than two groups
of paired observations. It seems to be ok For Cochran test.
Unfortunately I
have not found info about this test in R, except for
dealing with outliers
which is not my aim. I am looking for something like this
https://www.medcalc.org/manual/cochranq.php
I found a video to perform this analysis in R, but was not
specially
useful. Does some of you know have some info about how to
make this
analysis in R?
Thanks in advance!
[[alternative HTML version deleted]]
______________________________________________
R-help at r-project.org <mailto:R-help at r-project.org> mailing
list -- To UNSUBSCRIBE and more, see
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.
______________________________________________
R-help at r-project.org <mailto:R-help at r-project.org> mailing list
-- To UNSUBSCRIBE and more, see
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.