/**********************************************************************************************************************; February 1, 2014 THIS MACRO IS USED TO CALCULATE THE 95% CONFIDENCE INTERVALS AND P-VALUE FOR A SINGLE SIR Added rounding of p-value to 4 decimal places and SIR/CIs to 3 decimal places Used in output for calculating SIR CIs (called from SAS programs in NHSN and internal). sir_pval, sir_l, and sir_u are the output parameters. 2 SIDED P-VALUE FOR 'SIR ne 1' /*Exact mid-p will be computed only when observed (and expected) numbers of events are <=100 (point estimate of mu 'u'<=100). Otherwise, Byar approximation method is used, assuming identical results with mid-P, based on the large sample theory. REFERENCE: 1. JH ABRAMSON. WINPEPI PROGRAMS. DESCRIBE MANUAL (VERSION 2.42), PAGE-52. Available at 'http://www.brixtonhealth.com/pepi4windows.html' 2. Dean AG, Sullivan KM, Soe MM. OpenEpi: Open Source Epidemiologic Statistics for Public Health, Version. www.OpenEpi.com. 3. Rothman KJ, Boice JD Jr: Epidemiologic analysis with a programmable calculator. NIH Pub No. 79-1649. Bethesda, MD: National Institutes of Health, 1979;31-32. 4. Rothman KJ, Greenland S. Modern Epidemiology, 2nd Edition. Lippincott-Raven Publishers, Philadelphia, 1998. 5. GEOFFREY RC, SHU-YING Y. MID-P CONFIDENCE INTERVALS FOR THE POISSON EXPECTATION. STATISTICS IN MEDICINE, 13,2189-2203 (1994) Significance tests One-tailed tests are done for the significance of the SMR's departure from 100%, or the observed:expected ratio's departure from unity (displayed as the departure of the SMR from 100%), or the standardized rate's departure from the rate in the standard population. If the observed and expected numbers of events are '100' or less, exact Fisher's and mid-P probabilities are shown. otherwise a large-sample test is used. Fisher's P expresses the probability of occurrence, under the null hypothesis, of the observed or a more extreme number of events, and the mid-P value expresses the probability of a more extreme number plus half the probability of the observed number. The one-tailed P-values are doubled to provide two-tailed P-values. * **********************************************************************************************************************/ **************************P-VALUE for SIR NE 1 ************************************ **********************************************************************************************************************; %macro SIRcomp(OBS,EXP); e=2.718281828459045235; **********missing data handling and when &EXP<1; IF &OBS = . or &EXP = . or &EXP<1 THEN DO; SIR_pval=.;Byar_p=.;SIR=.;SIR_U=.;SIR_L=.; end; else do; ****when &OBServed numbers of events 'mu' are <=100; if (&OBS<=100) /*AND (&EXP<=100)*/ THEN DO; if (&OBS<&EXP) then do; k=&OBS-1; do while (k>=0); numerator=(e**-&EXP)* (&EXP**k); kk=k; denom=1; do while (kk>0); denom=denom*kk; kk=kk-1; *calculate the value of a factorial; end; subtotal=numerator/denom; total=sum(total,subtotal); k=k-1; end; *first part of equation; num=0; deno=0; i=0; aa=0; num=(e**-&EXP)* (&EXP**&OBS); deno=1; i=&OBS; do while (i>0); deno=deno*i; i=i-1;end; aa=(num/deno)*0.5; *combine both parts of equation; SIR_pval=round(2*(sum(aa,total)),.0001); end; if (&OBS>=&EXP) then do; k=&OBS-1; do while (k>=0); numerator=(e**-&EXP)* (&EXP**k); kk=k; denom=1; do while (kk>0); denom=denom*kk; kk=kk-1; *calculate the value of a factorial; end; subtotal=numerator/denom; total=sum(total,subtotal); k=k-1; end; *first part of equation; num=0; deno=0; i=0; aa=0; num=(e**-&EXP)* (&EXP**&OBS); deno=1; i=&OBS; do while (i>0); deno=deno*i; i=i-1;end; aa=(num/deno)*0.5; *combine both parts of equation; SIR_pval=round(2*(1-(sum(aa+total))),.0001); end; if SIR_pval>1 then SIR_pval=1; if SIR_pval<0 then SIR_pval=0; END; ****when &OBServed numbers of events are >100, use Byar poisson approximation (Rothman KJ, Boice JD); ELSE DO; Byar_p=0; z=0; OBS_=0; OBS_=&OBS; if (&OBS<=&EXP) then OBS_=&OBS+1; z= sqrt(9*OBS_) * ( 1 - 1/(9*OBS_) - (&EXP/OBS_)**(1/3) ); if &OBS<=&EXP then Byar_p=round(2*probnorm(z),.0001); else Byar_p=round(2*(1-probnorm(z)),.0001); /* if (&OBS<=&EXP) then &OBS=&OBS+1; z= sqrt(9*&OBS) * ( 1 - 1/(9*&OBS) - (&EXP/&OBS)**(1/3) ); if &OBS<=&EXP then Byar_p=2*probnorm(z); else Byar_p=2*(1-probnorm(z)); */ if Byar_p>1 then Byar_p=1; SIR_pval=Byar_p; END; ************************************************************************************************************ 95%CI ************************************************************************************************************; %macro fish(z=,x1=,x2=); q=1; tot=0; s=0; k=0; do while(k<&z or q>(tot*10**-10)); tot=tot+q; if(k>=&x1 and k<=&x2) then s=s+q ; if(tot>10**30)then do; s=s/10**30; tot=tot/10**30; q=q/10**30; end; k=k+1; q=q*&Z/k; end; poisP=s/tot; %mend; %macro fish2(z=,x1=,x2=); q=1; tot=0; s=0; k=0; do while(k<&z or q>(tot*10**-10)); tot=tot+q; if(k>=&x1 and k<=&x2) then s=s+q ; if(tot>10**30)then do; s=s/10**30; tot=tot/10**30; q=q/10**30; end; k=k+1; q=q*&Z/k; end; poisP2=0.5*(s/tot); %mend; *point estimate; if &exp=>1 then do; SIR = round(&obs/&exp,.001); *Lower tail; v=0.5; dv=0.5; p=2.5/100; do while(dv>10**-5); dv=dv/2; *component-A; %fish(z=(1+&obs)*v/(1-v), x1=(&obs+1), x2=10**10); *component-B; %fish2(z=(1+&obs)*v/(1-v), x1=&obs, x2=&obs); if( (PoisP+PoisP2)>p) then v=v-dv; else v=v+dv; end; if &obs=0 then SIR_L=.; *LEAVE LOWER LIMIT BLANK IF NO EVENT OCCURED; else SIR_L= round(((1+&obs)*v/(1-v))/&exp,.001); *Upper tail; v=0.5; dv=0.5; p=2.5/100; do while(dv>10**-5); dv=dv/2; *component-A; %fish(z=(1+&obs)*v/(1-v), x1=0, x2=(&obs-1) ); *component-B; %fish2(z=(1+&obs)*v/(1-v), x1=&obs, x2=&obs); if( (PoisP+PoisP2)