Estimate and compare statistics in two or more independent 2x2 tables


The following extends the use of the NLMIXED procedure, as shown in SAS Note 24170, to compare various 2×2 table statistics computed in two tables. Illustrated below is the comparison of four statistics (sensitivity, specificity, LR+, and LR−) between two 2×2 tables. However, the basic method can be used to compare other table statistics among more than two tables, though the number of parameters and complexity increases with more tables.

The likelihood ratio statistics, LR+ and LR−, are often used to assess diagnostic tests. Both are ratios involving sensitivity and specificity, as shown in SAS Note 24170, and estimate the multiplicative change in the probability of a test result given presence or absence of a condition. Both are only bounded below at zero. A value of 1 indicates no change and no diagnostic value. Importantly, like sensitivity and specificity, LR+ and LR− are not affected by the prevalence of the condition.

Interpretations of the LR+ and LR− ratios are clearer when written as functions of sensitivity and specificity. Sensitivity is the probability of a positive test result given that the condition is present: Pr(T+|C+). Specificity is the probability of a negative test result given that the condition is absent: Pr(T−|C−).

LR+ = Sensitivity/(1-Specificity) = Pr(T+|C+) / Pr(T+|C−)
⇒ Pr(T+|C+) = (Pr(T+|C−)) · LR+
⇒ 1/LR+ · Pr(T+|C+) = (Pr(T+|C−))

So, LR+ > 1 indicates how much more probable a positive test is for those with the condition than for those without the condition. Equivalently, it indicates how much less probable a positive test is for those without the condition than for those with the condition.

LR− = (1-Sensitivity)/Specificity = Pr(T−|C+) / Pr(T−|C−)
⇒ Pr(T−|C+) = Pr(T−|C−) · LR−
⇒ 1/LR− · Pr(T−|C+) = Pr(T−|C−)

So, LR− < 1 indicates how much less probable a negative test is for those with the condition than for those without the condition. Equivalently, it indicates how much more probable a negative test is for those without the condition than for those with the condition.

Consider two independent groups of subjects. In each group, each subject is observed to have a condition or not and to show either a positive or negative response on a diagnostic test for the condition. The following creates the data and displays the tables for the two groups. The SENSPEC option in the TABLES statement in the FREQ procedure displays statistics including the sensitivity and specificity for each table.

data a;
      do Group=0,1; 
      do Test=0,1; 
      do Response=0,1;
         input Count @@; output;
      end; end; end;
      datalines;
      6 2 4 11
      5 4 5 8
      ;
   proc sort data=a;
      by Group descending Test descending Response;
      run;
   proc freq data=a order=data;
      weight Count;
      tables Group*Test*Response / senspec;
      run;

Tables: "Table 1 of Test by Response" and "Statistics for Table 1 of Test by Response Controlling for Group=0""Table 2 of Test By Response" and "Statistics for Table 2 of Test by Response Controlling for Group=1"

SAS Note 24170 shows how PROC NLMIXED can be used to fit a saturated Poisson model to the data in a 2×2 table and compute a wide range of statistics. By using a saturated model whose parameters are the individual cell counts in the table, each statistic can easily be written as a function of the cell counts. These functions are specified in ESTIMATE statements to compute the statistics along with tests and confidence intervals. Note that these are large-sample tests and confidence intervals since the DF= option in the PROC NLMIXED statement is set to a large value (1e8=100,000,000).

You can take a similar approach when there is more than one table that creates a three-way table. For the two groups above, the table is a 2×2×2 table with eight cell counts, which become the parameters in a saturated Poisson model. With this model, a particular statistic can be computed for each table, and a test can be made of whether the statistic differs between the two tables.

In the following PROC NLMIXED statements, the MU= and MODEL statements define a saturated and log-linked Poisson model on the counts in the 2×2×2 table. Under the model, each cell of the table has its own Poisson distribution with mean μijk, i=0,1, j=0,1, k=0,1. Cells are identified by a combination of Group (i), Test (j), and Response (k) values. To encompass all cells of the table, the model is written in the MU= statement as the exponentiated sum of parameters (βijk) associated with the eight individual cells of the table,

μijk = exp(Σ(βijk·cellijk)) ,

where cellijk=1 for a given cell and 0 otherwise. Equivalently, the model can be written

log(μijk) = Σ(βijk·cellijk) ,

indicating that the log is the link function in the Poisson model since it links the mean to a linear combination of model parameters. Then, for a given cell, ijk*, its mean under the model is

μijk* = exp(βijk*) .

The statements labeled "Means (cell counts)" compute the eight means. Since there are eight cells and the model defines eight parameters, the model is considered saturated with no degrees of freedom remaining. As a result, these eight means exactly reproduce the observed cell counts in the table, nijk. These can then be used to compute any statistic of interest, such as those discussed in SAS Note 24170.

The statements labeled "Group statistics" compute the sensitivity, specificity, LR+, and LR− statistics for each of the two tables.

The ESTIMATE statements labeled "Estimate and compare statistics" display the estimates and provide tests and confidence intervals for the four statistics and also compare the statistics between the two group tables. In the sets of ESTIMATE statements for LR+ and LR−, the first ESTIMATE statement for each group tests if the statistic equals zero and provides a confidence interval. However, for these statistics, it is of more interest to test if they equal 1, which indicates no diagnostic value. The second ESTIMATE statement for each group provides this test by testing the absolute value of the difference between the statistic and 1.

proc nlmixed data=a df=1e8;
    mu=exp(
           b000*(group=0 and test=0 and response=0) + b001*(group=0 and test=0 and response=1) + 
           b010*(group=0 and test=1 and response=0) + b011*(group=0 and test=1 and response=1) +
           b100*(group=1 and test=0 and response=0) + b101*(group=1 and test=0 and response=1) + 
           b110*(group=1 and test=1 and response=0) + b111*(group=1 and test=1 and response=1)
           );
    model count ~ poisson(mu);

    /* Means (cell counts) */
    n011=exp(b011); n010=exp(b010); n001=exp(b001); n000=exp(b000);
    n111=exp(b111); n110=exp(b110); n101=exp(b101); n100=exp(b100);

    /* Group statistics */
    Sens0=n011/(n011+n001); Sens1=n111/(n111+n101);
    Spec0=n000/(n000+n010); Spec1=n100/(n100+n110);
    
    LRplus0=Sens0/(1-Spec0); LRplus1=Sens1/(1-Spec1);
    LRminus0=(1-Sens0)/Spec0; LRminus1=(1-Sens1)/Spec1;

    /* Estimate and compare statistics */
    estimate 'Sensitivity in Group0' Sens0;
    estimate 'Sensitivity in Group1' Sens1;
    estimate 'Sensitivity Group0-Group1' Sens0-Sens1;
    
    estimate 'Specificity in Group0' Spec0;
    estimate 'Specificity in Group1' Spec1;
    estimate 'Specificity Group0-Group1' Spec0-Spec1;
    
    estimate 'Estimate LR+ in Group0' LRplus0;
    estimate 'Test LR+ in Group0 = 1' abs(LRplus0-1);
    estimate 'Estimate LR+ in Group1' LRplus1;
    estimate 'Test LR+ in Group1 = 1' abs(LRplus1-1);
    estimate 'LR+ Group0-Group1' LRplus0 - LRplus1;
    
    estimate 'Estimate LR- in Group0' LRminus0;
    estimate 'Test LR- in Group0 = 1' abs(LRminus0-1);
    estimate 'Estimate LR- in Group1' LRminus1;
    estimate 'Test LR- in Group1 = 1' abs(LRminus1-1);
    estimate 'LR- Group0-Group1' LRminus0 - LRminus1;    

    run;

In the "Additional Estimates" table displayed by the ESTIMATE statements, note that the sensitivity and specificity for each group reproduce those provided by the SENSPEC option in PROC FREQ shown above. Any slight differences with the PROC FREQ results are due to use of a different estimation method (delta method in NLMIXED). Estimates of LR+ and LR− for each group table are also presented. A large-sample test of equality to zero (Pr > |t|) and a 95% confidence interval (Lower, Upper) is provided for each statistic. For the statements testing the absolute difference with 1, the test is a test that the statistic equals 1. Each statistic is then compared between the two group tables.

The results indicate that sensitivity, specificity, and LR+ all significantly differ from zero in both groups (p < 0.05). When testing equality to 1, only LR− in group 0 differs significantly from 1 (p < 0.0001). This suggests that, in group 0, a negative test is significantly less likely for those with the condition than for those without the condition. The two groups do not differ significantly on any of the four statistics.

"Additional Estimates" table