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
<luysgar...@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@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@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@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.

Reply via email to