Dear SAS Community,
Looking at the this graph, I would like to know if the percentage of PeelColor 3 (red) is significantly different between the Variety BL516 and Hass for the Season 2021. PeelColor is the dep categorical variable (ordinal) with more than 2 levels.
If I am correct, with an lsmestimate statement I should be able to answer that, so this is the code I am using. However I would like to know how to specify the level of the dep var (PeelColor=3) for this comparison.
proc logistic data=one desc;
where Season=2021;
class Variety/param=glm;
model PeelColor= Variety/ link=clogit/*y is ordinal*/ ;
lsmeans Variety/diff;
lsmestimate Variety 'BL516 vs Hass' 0 0 0 0 0 1 0 0 0 0 -1/adjust=simulate(seed=1);
run;
I would greatly appreciate your help!
Thanks
A logistic model for this is overkill. For what you want, you can just use PROC FREQ since you are only looking at data for 2021. Also, I would assume that PeelColor is a nominal response, not ordinal, unless you are really interested in the color frequency. Effectively, you just have data for a 2x2 table with Variety as the rows and PeelColor (red vs anything else) as the columns. So, create a ColorRed variable which is 1 for Red and 0 otherwise and the use PROC FREQ:
proc freq;
where season=2021;
table variety*colorred/chisq;
run;
This tests whether the proportions of ColorRed in the two varieties are equal.
A logistic model for this is overkill. For what you want, you can just use PROC FREQ since you are only looking at data for 2021. Also, I would assume that PeelColor is a nominal response, not ordinal, unless you are really interested in the color frequency. Effectively, you just have data for a 2x2 table with Variety as the rows and PeelColor (red vs anything else) as the columns. So, create a ColorRed variable which is 1 for Red and 0 otherwise and the use PROC FREQ:
proc freq;
where season=2021;
table variety*colorred/chisq;
run;
This tests whether the proportions of ColorRed in the two varieties are equal.
Thank you so much for your reply StatDave, that makes sense.
I will then apply these steps for every level of the dep var PeelColor I'm interested in, in order to get a 2x2 table:
data one1; set one;
if PeelColor=3 then ColorRed=1;
else ColorRed=0;
run;
proc freq data=one1;
where Season=2021 and Variety in('BL516', 'Hass');
table Variety*colorRed/chisq riskdiff;
run;
I have a question; Is the two-sided Pearson chi-square test in the Fisher's Exact Test Table the one that will tell me if the proportions for ColorRed (1) are significantly different between the two Varieties?
|
|
Statistics for Table of Variety by Colorred |
Statistic | DF | Value | Prob |
---|---|---|---|
Chi-Square | 1 | 49.0915 | <.0001 |
Likelihood Ratio Chi-Square | 1 | 53.0439 | <.0001 |
Continuity Adj. Chi-Square | 1 | 47.5168 | <.0001 |
Mantel-Haenszel Chi-Square | 1 | 49.0098 | <.0001 |
Phi Coefficient | -0.2858 | ||
Contingency Coefficient | 0.2748 | ||
Cramer's V | -0.2858 |
Fisher's Exact Test | |
---|---|
Cell (1,1) Frequency (F) | 224 |
Left-sided Pr <= F | <.0001 |
Right-sided Pr >= F | 1.0000 |
Table Probability (P) | <.0001 |
Two-sided Pr <= P | <.0001 |
Yes, the Pearson Chi-Square test will test the equality of the two proportions as detailed in this usage note.
22561 - Testing the equality of two or more proportions from independent samples
If you want an exact test, then you can report Fisher's exact test.
Thanks. So should I use the Fisher's exact test (two -sided Pr<=P) in case the cell counts are too small, but otherwise the Chi square test I get with the chisq option?
Great, thanks!
Thank you very much Ksharp for this useful option!
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.