BookmarkSubscribeRSS Feed
sumah
Fluorite | Level 6

ewewee.png

 

 

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?

13 REPLIES 13
ballardw
Super User

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.

sumah
Fluorite | Level 6

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?

StatDave
SAS Super FREQ

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.

sumah
Fluorite | Level 6

thank you so much. I did this but nothing changed. 

StatDave
SAS Super FREQ
If nothing changed when you added the MISSING option, then you must not have any observations in the data with a value other than Yes for ADULT3. With no data for the ADULT3=No population, you cannot conduct a test.
Ksharp
Super User

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;

Ksharp_0-1632832420497.png

 

 

You would notice this message:

Row or column sum zero. No statistics computed for this table.
sumah
Fluorite | Level 6

thanks. do you suggest another test?

PaigeMiller
Diamond | Level 26

@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
sumah
Fluorite | Level 6
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
PaigeMiller
Diamond | Level 26

@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
sumah
Fluorite | Level 6

not quite sure I understand your reply. here is a screenshot Inkedewewee (1)_LI.jpg

PaigeMiller
Diamond | Level 26

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
Ksharp
Super User

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;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 13 replies
  • 2027 views
  • 2 likes
  • 5 in conversation