2022년 11월 12일 토요일

ch.22 McNemar test Cochran Q test

easier R than SPSS with Rcmdr : Contents

ch.22 McNemar test Cochran Q test


I don’t have the proper data, so let’s create some machining data. Thanks to this , we can learn the syntax of R scripts.

Line 1 means ‘Call up the birthwt data contained in the MASS package.’

Row 2 means ‘Pull out columns 5, 7, and 8 of the birthwt data and put them in the data called df.’ They created new data.

 

Row 3 means ‘Name the columns of the data df as Tr1, Tr2, and Tr3, respectively.’

 

 

Click Data and set to replace df with active data. As shown in the figure, there are 3 columns, each with a value of 0 and 1.

Each row is a single person’s data, showing ‘satisfaction/dissatisfaction’ or ‘success/failure’ when 3 treatments were performed. In the paired t-test that we learned earlier, the result variable was a continuous variable, the study design is the same, the data structure is the same, but there is a difference that the result variable is a nominal variable(even they are 0 or 1).

 

Select McNemar test.

 

Select 2 columns. By default, this enables continuity correction.

The first thing you should see in the result is table. If the decision value of 1 is a success, then 108 of the two treatments are successful, and 5 of the failures of both treatments.

Tr1 succeeds, Tr2 fails in7. Tr2 succeeds, Tr1 fails in 69. When you look at this table, you can compare the diagonal directions of 7 and 69 to think that Tr2 would be better.

 

If you look at the ‘McNemar test with continuity correction’ results that p<0.05, you can determine that it is statistically significant.

 

Select Cochran’s Q test.

I currently have 3 variables, select all three.

 

This is a p < 0.05, so we conclude that the three treatments are not the same. Then you have to perform McNemar test for every pairs as a post-hoc test to compare them manually, and you have to manually do adjust for the p value.

 

Meanwhile, you can select only 2 variables in Cochran’s Q test.

The result is called Cochran’s Q test, but it’s actually the same as McNemar test. (This means Cochran’s Q test is an extension of McNemar test)

 

 

When implementing McNemar test without continuity modification, it is the same as the result of the Cochran’s Q test for only 2 variables.

 

This is similar to how an ANOVA for only 2 groups is like a t-test, and an RM ANOVA for only two groups is like a paired t-test. Continuity correction is only possible if the data is summarized in a 2x2 table, whether it is a chi-squared test or a McNemar test.

 

 

 

easier R than SPSS with Rcmdr : Contents

=================================================

  • R data visualization book 2
https://tinyurl.com/R-plot-II-2  simple variables
https://tinyurl.com/R-plot-II-3-4   many variables / map
https://tinyurl.com/R-plot-II-5-6   time related / statistics related
https://tinyurl.com/R-plot-II-7-8   others / reactive chart 
 

 

댓글 없음:

댓글 쓰기