/** Two-Sample Approximate Score (Agresti-Coull) Confidence Interval **/ /******************************************** Macro to compute two-sample approximate score (Agresti-Coull) confidence interval. INPUT: o y1,y2: number having characteristic in samples 1 and 2 o n1,n2: sample size, samples 1 and 2 o conf_level: desired confidence level OUTPUT: o Point estimate of p1-p2 o Approximate score CI for p1-p2 *********************************************/ %macro ac2(y1,n1,y2,n2,conf_level); data ac2; tail_area=(1+&conf_level)/2; z=probit(tail_area); p1hat=&y1/&n1; p2hat=&y2/&n2; point_est=p1hat-p2hat; n1_tilde=&n1+.5*z**2; n2_tilde=&n2+.5*z**2; p1_tilde=(&y1+.25*z**2)/n1_tilde; p2_tilde=(&y2+.25*z**2)/n2_tilde; se=sqrt(p1_tilde*(1-p1_tilde)/n1_tilde+p2_tilde*(1-p2_tilde)/n2_tilde); ci_low=p1_tilde-p2_tilde-z*se; ci_up=p1_tilde-p2_tilde+z*se; run; proc print noobs; var point_est ci_low ci_up; run; %mend ac2; /******************************************** Sample call using numbers from example in lecture notes: %ac2(24,200,26,100,.95); *********************************************/