Currently I have a dataset with an N of 3866 with two variables, Project (group variable, six levels) and Topbox (two levels; yes, no). We are looking to see if there is a difference in the proportion of 'Yes' responses between different projects (i.e., is there a significant difference between the project that has the lowest proportion of 'yes' responses versus the project that has the highest proportion of 'yes' responses). I've conducted a Chi-Square test in both SAS and R, and both give me different X^2 and p-values. Outputs shown below:
SAS:
proc freq data = aggregate;
tables q57_topbox*project / chisq;
run;
R:
chisq.test(records_filter$q57_topbox, records_filter$project,
correct=FALSE)
Chi-square output:
Pearson's Chi-squared test
data: records_filter$q57_topbox and records_filter$project
X-squared = 21.216, df = 5, p-value = 0.0007373
I have a couple questions regarding this.
- The X^2 and the p-value are different and I am not sure why.
- Looking more into this, I'm not sure if a Chi-square statistic is the right test for such a dataset. The cell counts are not only widely variable (counts between 37 and 1143 in the 'Yes' response), but the cell counts are also bigger than what I'm seeing most people would use a Chi-square for. Therefore I'm unsure if this is the correct test to begin with.
Any help at all is appreciated, thank you so much for reading. Please let me know if there's any other info I can provide (I'm quite new to asking questions to stack exchange, so apologies!)
NA
values are handled; judging from the degrees of freedom, SAS treats them as a valid category, but R drops them. Try removing them and rerun the SAS analysis to see what happens. $\endgroup$