Dear all!
Could you please help me with the following question:
I need to calculate the simultaneous confidence limits for multinomial proportions based on Goodman method (1965 year) like it id done here:
https://blogs.sas.com/content/iml/2017/02/15/confidence-intervals-multinomial-proportions.html
But I don't have SAS/IML, is it possible to done the calculation using base SAS without IML module?
Thanks in advance!
Best Regards,
Andrey
Hello @AndreyMyslivets,
Yes, this is possible. Here's how (using Rick Wicklin's example data):
%let c=4; /* number of categories */
%let a=0.05; /* alpha */
data have;
input n1-n&c;
cards;
91 49 37 43
;
data GoodmanCI;
array n[&c]; /* counts */
array p[&c]; /* percentages */
array lcl[&c]; /* lower confidence limits */
array ucl[&c]; /* upper confidence limits */
set have;
nt=sum(of n[*]); /* total n */
x=cinv(1-&a/&c,1); /* chi-square quantile, df=1, with Bonferroni adjustment */
do i=1 to &c;
p[i]=n[i]/nt;
lcl[i]=(x+2*n[i]-sqrt(x*(x+4*n[i]*(nt-n[i])/nt)))/(2*(nt+x));
ucl[i]=(x+2*n[i]+sqrt(x*(x+4*n[i]*(nt-n[i])/nt)))/(2*(nt+x));
end;
drop i;
run;
I took the formulas from a 2016 post of mine where I estimated some coverage probabilities for this and other suggested confidence intervals for multinomial proportions.
Hello @AndreyMyslivets,
Yes, this is possible. Here's how (using Rick Wicklin's example data):
%let c=4; /* number of categories */
%let a=0.05; /* alpha */
data have;
input n1-n&c;
cards;
91 49 37 43
;
data GoodmanCI;
array n[&c]; /* counts */
array p[&c]; /* percentages */
array lcl[&c]; /* lower confidence limits */
array ucl[&c]; /* upper confidence limits */
set have;
nt=sum(of n[*]); /* total n */
x=cinv(1-&a/&c,1); /* chi-square quantile, df=1, with Bonferroni adjustment */
do i=1 to &c;
p[i]=n[i]/nt;
lcl[i]=(x+2*n[i]-sqrt(x*(x+4*n[i]*(nt-n[i])/nt)))/(2*(nt+x));
ucl[i]=(x+2*n[i]+sqrt(x*(x+4*n[i]*(nt-n[i])/nt)))/(2*(nt+x));
end;
drop i;
run;
I took the formulas from a 2016 post of mine where I estimated some coverage probabilities for this and other suggested confidence intervals for multinomial proportions.
See examples 2 and 3 in this note using PROC CATMOD.
@StatDave wrote:
See examples 2 and 3 in this note using PROC CATMOD.
According to another post in the 2016 thread I mentioned in my reply to @AndreyMyslivets, that Usage Note 32609 was not very helpful for computing simultaneous confidence intervals (EDIT: as far as non-IML techniques are concerned), unfortunately.
Dear @FreelanceReinh @StatDave @Ksharp
Many thanks for your help!
There is a macro in @Rick_SAS blog. maybe you can use it .
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.