Manoj Aravind
2010-Dec-28 17:05 UTC
[R] Problem applying McNemar's - Different values in SPSS and R
Hi friends, I get different values for McNemar's test in R and SPSS. Which one should i rely on when the p values differ. I came across this problem when i started learning R and seriously give up on SPSS or any other proprietary software. Thank u in advance Output in SPSS follows *Crosstab* hsc Total ABN NE ABN tvs ABN Count 40 3 43 Row % 93.0% 7.0% 100.0% COL% 78.4% 30.0% 70.5% NE Count 11 7 18 Row % 61.1% 38.9% 100.0% COL% 21.6% 70.0% 29.5% Total Count 51 10 61 Row % 83.6% 16.4% 100.0% COL% 100.0% 100.0% 100.0% * Chi-Square Tests* Value Exact Sig. (2-sided) McNemar Test .057(a) N of Valid Cases 61 a Binomial distribution used. Output from R is as follows....> tvshsc<-+ matrix(c(40,11,3,7), + nrow=2, + dimnames=list("TVS"=c("ABN","NE"), + "HSC"=c("ABN","NE")))> tvshscHSC TVS ABN NE ABN 40 3 NE 11 7> mcnemar.test(tvshsc)McNemar's Chi-squared test with continuity correction data: tvshsc McNemar's chi-squared = 3.5, df = 1, p-value = 0.06137 Regards Dr. B Manoj Aravind [[alternative HTML version deleted]]
Marc Schwartz
2010-Dec-28 17:30 UTC
[R] Problem applying McNemar's - Different values in SPSS and R
On Dec 28, 2010, at 11:05 AM, Manoj Aravind wrote:> Hi friends, > I get different values for McNemar's test in R and SPSS. Which one should i > rely on when the p values differ. > I came across this problem when i started learning R and seriously give up > on SPSS or any other proprietary software. > Thank u in advance > > Output in SPSS follows > > *Crosstab* > > > hsc > > Total > > ABN > > NE > > ABN > > tvs > > ABN > > Count > > 40 > > 3 > > 43 > > Row % > > 93.0% > > 7.0% > > 100.0% > > COL% > > 78.4% > > 30.0% > > 70.5% > > NE > > Count > > 11 > > 7 > > 18 > > Row % > > 61.1% > > 38.9% > > 100.0% > > COL% > > 21.6% > > 70.0% > > 29.5% > > Total > > Count > > 51 > > 10 > > 61 > > Row % > > 83.6% > > 16.4% > > 100.0% > > COL% > > 100.0% > > 100.0% > > 100.0% > > > > * Chi-Square Tests* > > > Value > > Exact Sig. (2-sided) > > McNemar Test > > .057(a) > > N of Valid Cases > > 61 > > a Binomial distribution used. > > Output from R is as follows.... > >> tvshsc<- > > + matrix(c(40,11,3,7), > > + nrow=2, > > + dimnames=list("TVS"=c("ABN","NE"), > > + "HSC"=c("ABN","NE"))) > >> tvshsc > > HSC > > TVS ABN NE > > ABN 40 3 > > NE 11 7 > >> mcnemar.test(tvshsc) > > > McNemar's Chi-squared test with continuity correction > > > data: tvshsc > > McNemar's chi-squared = 3.5, df = 1, p-value = 0.06137 > > Regards > > Dr. B Manoj AravindThe SPSS test appears to be an exact test, whereas the default R function does not perform an exact test, so you are not comparing Apples to Apples... Try this using the 'exact2x2' CRAN package:> require(exact2x2)Loading required package: exact2x2 Loading required package: exactci> mcnemar.exact(matrix(c(40, 11, 3, 7), 2, 2))Exact McNemar test (with central confidence intervals) data: matrix(c(40, 11, 3, 7), 2, 2) b = 3, c = 11, p-value = 0.05737 alternative hypothesis: true odds ratio is not equal to 1 95 percent confidence interval: 0.04885492 1.03241985 sample estimates: odds ratio 0.2727273 HTH, Marc Schwartz
Apparently Analagous Threads
- McNemar test in R & SPSS
- Using McNemar's test to detect shifts in response from pre- to post-treatment
- mcnemar.test odds ratios, CI, etc.
- Can I use "mcnemar.test" for 3*3 tables (or is there a bug in the command?)
- Update to exact2x2 package: Exact McNemar's test