- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I have run a Ch-squareD test on 2 variables and that was the SAS output (above).
The categories for both variables are (yes vs no). why there isn't any rows depicting the (0 observations)? Can I run chi-squared test if one variable has 0 obs in one category?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
That output shows that you have no values of 0 or maybe "No" for the Adult3 variable.
If you created Adult3 using code from other variable(s) then you may want to consider sharing that code along with the starting data.
You said that "have run a Ch-squareD test". What did the LOG show?
I suspect there is a note along the lines of :
NOTE: No statistics are computed for adult3* adult11 because adult3 has less than 2 nonmissing levels.
If you do not have at least 2 non-missing values for each variable you cannot run chi-square.
Additionally if each cell has fewer than 5 you may well have unreliable results.
Part of what goes on is that a chi-square calculated the expected cell count for each cell and calculates the test statistic from the difference of those expected counts with the actual counts. If a variable only has one value then there is no "expected" value for the other value(s) that do not appear in the data. So there is no valid test statistic to calculate.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
thanks. yes I got this message in the log:
NOTE: No statistics are computed for adult3* adult11 because adult3 has less than 2 nonmissing levels.
ok. int his case what test can I use if I want to detect the significance of the difference between the 2 variables?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
That message suggests that the only other value of your ADULT3 variable, other than Yes, is a missing value. That is, there are no observations with ADULT3=No. If you want to treat ADULT3=. (missing) as a valid level of that variable, then you can add the MISSING option in the TABLE statement. That will make a second row of the table with the counts from the observations where ADULT3 is missing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
thank you so much. I did this but nothing changed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
No. You can't . You would get this error.
data have; input adult1 $ adult3 $ w; cards; Yes Yes 76 Yes No 0 No Yes 1 No No 0 ; proc freq data=have; table adult3*adult1/chisq; weight w/zero; run;
You would notice this message:
Row or column sum zero. No statistics computed for this table. |
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
thanks. do you suggest another test?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@sumah wrote:
thanks. do you suggest another test?
If you only have one value of adult3, then a Chi-square test is impossible.
What hypothesis do you want to test? Please be specific. Normally, you test two things against each other, for example: the hypothesis is the percent of events in group 1 is equal to the percent of events in group 2. There are many other possibilities. What are your two percents (or two things) that you want to test against each other????
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@sumah wrote:
Thank you. So I wanted to see if there’s a significant difference between % of respondents who took the vaccine in 2019 vs % of respondents who took the vaccine in 2020 and since it’s a categorical variable (yes vs no) I picked chi-squared test
This does not seem to have anything to do with your two variables named adult3 and adult11. Please explain further.
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
not quite sure I understand your reply. here is a screenshot
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
But which is "% of respondents who took the vaccine in 2019" and which is "% of respondents who took the vaccine in 2020"?
If either one of them is adult3, then you can't do this comparison because you have only one value for adult3. You don't seem to be grasping this point.
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I would suggest BINOMIAL Test since adult3 has only one level ,which means you can't do CHISQ Test .
data have; input adult1 $ adult3 $ w; cards; Yes Yes 76 No Yes 1 ; proc freq data=have; table adult1/binomial(p=0.02); exact binomial; weight w/zero; run;