Changeset 20034 in main


Ignore:
Timestamp:
03/13/20 18:08:32 (3 years ago)
Author:
Paul Leo
Message:

First pass at using binomial exact confidence intervals.
For USE only on TEST!!!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • adopters/mt/trunk/src/main/backend_qModules/birth23/test/MT_Percentage_data_frame.def

    r19749 r20034  
    165165 *              weight as % of live births, or ratios like maternal mortality           ;
    166166 *              per 100 live births.                                                                                            ;
    167  *              if 20<=count<=100       (events between 20 and 100)                                                     ;
    168  *                      (according to Cody this does not apply for avgs??                                       ;
     167 *              if 20<=count    events= or greater than 20                                                              ;
     168 *                      use binomial exact confidence intervals                                                         ;
    169169 *  2. If denominater (popcount < 300)                                                                                  ;
    170170 *              2a. If count > 20                                                                                                               ;
    171171 *                      Report count and rates with confidence intervals                                        ;
     172 *                              using binomial exact confidence intervals                                               ;
    172173 *              2b. If count < 20                                                                                                               ;
    173174 *                      Suppress rates and counts                                                                                       ;
     
    185186                n=count;  *ibis-q needs a count variable named 'n';
    186187                rate=count/totalnum;
    187 
     188                rateper=(rate*100);
     189               
    188190                if popcount>=300 then do;
    189191
     
    219221                                redflag=put('Suppressed %', $16.);
    220222                        end;
    221 
    222                         if 20<=count<=100 then do;
    223                         * for events between 20 and 100, use Poisson to calculate confidence intervals;
    224 
    225                                 rateper=(rate*100);
    226                                 t1= GAMINV(.025,count)/totalnum*100;
    227                                 if (t1<0) then t1=0;
    228                                 LL=put(t1, 8.2);
    229                                 UL=put(( GAMINV(.975,count)/totalnum*100),8.2);
    230                         end;
    231 
    232                         *  and normal approximation for more than 100 events. ;
    233                        
    234                         if count>100 then do;
    235                                 rateper=(rate*100);
    236                                 stderr=sqrt(rate*(1-rate)/totalnum)*100;
    237                                 t1=(rateper-(1.96*stderr));
    238                                 if (t1<0) then t1=0;
    239                                 LL=put(t1, 8.2);
    240                                 UL=put((rateper+(1.96*stderr)), 8.2);
     223                       
     224                        * for events >= 20 use binomial exact confidence intervals;
     225                       
     226                        if count >= 20 then do;
     227                                diffcountL=popcount-count-1;
     228                                diffcountU=popcount-count;
     229                                countplus1=count+1;
     230                        /************* Keeping lines for steps to obtain  LL and UL    *************
     231                                Lowerquant=betainv(.975,diffcountL,count);
     232                                Upperquant=betainv(.025,diffcountU,countplus1);
     233                                Lowerval=(1-Lowerquant)*100;
     234                                Upperval=(1-Upperquant)*100;
     235                                LL=rateper-Lowerval;
     236                                UL=rateper+Upperval;
     237                        ***************************************************************************/
     238                                LL=rateper-(1-(betainv(.975,diffcountL,count)))*100;
     239                                UL=rateper+(1-(betainv(.025,diffcountU,countplus1)))*100;
    241240                                LL=compress(LL);
    242241                                UL=compress(UL);
    243242                                redflag=put('-', $15.);
    244243                        end;
     244                       
    245245                end;
    246246               
     
    267267                       
    268268                       
    269                         * report rate and n if popcount <300 and count >= 20 events.    ;
    270 
    271                         if 20<=count<=100 then do;
    272                         * for events between 20 and 100, use Poisson to calculate confidence intervals;
    273 
    274                                 rateper=(rate*100);
    275                                 t1= GAMINV(.025,count)/totalnum*100;
    276                                 if (t1<0) then t1=0;
    277                                 LL=put(t1, 8.2);
    278                                 UL=put(( GAMINV(.975,count)/totalnum*100),8.2);
    279                         end;
    280 
    281                         *  and normal approximation for more than 100 events. ;
    282                        
    283                         if count>100 then do;
    284                                 rateper=(rate*100);
    285                                 stderr=sqrt(rate*(1-rate)/totalnum)*100;
    286                                 t1=(rateper-(1.96*stderr));
    287                                 if (t1<0) then t1=0;
    288                                 LL=put(t1, 8.2);
    289                                 UL=put((rateper+(1.96*stderr)), 8.2);
     269                        * report rate and n if popcount <300 and count >= 20 events, using binomial exact confidence intervals  ;
     270
     271                       
     272                        if count >= 20 then do;
     273                                diffcountL=popcount-count-1;
     274                                diffcountU=popcount-count;
     275                                countplus1=count+1;
     276                        /************* Keeping lines for steps to obtain  LL and UL    *************
     277                                Lowerquant=betainv(.975,diffcountL,count);
     278                                Upperquant=betainv(.025,diffcountU,countplus1);
     279                                Lowerval=(1-Lowerquant)*100;
     280                                Upperval=(1-Upperquant)*100;
     281                                LL=rateper-Lowerval;
     282                                UL=rateper+Upperval;
     283                        ***************************************************************************/
     284                                LL=rateper-(1-(betainv(.975,diffcountL,count)))*100;
     285                                UL=rateper+(1-(betainv(.025,diffcountU,countplus1)))*100;
    290286                                LL=compress(LL);
    291287                                UL=compress(UL);
Note: See TracChangeset for help on using the changeset viewer.