![]() | ![]() | ![]() |
No procedure provides these statistics directly (although PROC LOGISTIC computes several of them for tables of predicted and observed classifications that result from a logistic model). However, they are easy to compute for a 2x2 table by using PROC FREQ. For the table later in this note, estimates of the sensitivity, specificity, positive predictive value (PPV), negative predictive value (NPV), false positive probability, and false negative probability all appear as row or column percentages of certain cells in the table, as indicated by color here and in the table.
Note that the ordering of rows and columns is very important in computing these statistics. For example, sensitivity is defined as the proportion of true positive responders (Response=1) that have a positive test result (Test=1). If the table is arranged with Response levels as the columns and Test levels as the rows and with Test=1, Response=1 as the upper-right (or 1,1) cell as shown, then sensitivity is the proportion of the first column that is in the 1,1 cell (11/13). As a percentage, this is given as the column percentage (Col Pct) for the 1,1 cell (84.62%).
The other statistics are defined as follows:
These statements read in the table's cell counts and use PROC FREQ to display the table. PROC SORT orders the row and column variables so that 1 appears before 0, and the ORDER=DATA option in PROC FREQ orders the table according to the order found in the data set. As a result, the 1 levels appear before the 0 levels, putting Test=1, Response=1 in the 1,1 cell as discussed earlier.
data FatComp;
input Test Response Count;
datalines;
0 0 6
0 1 2
1 0 4
1 1 11
;
proc sort data=FatComp;
by descending Test descending Response;
run;
proc freq data=FatComp order=data;
weight Count;
tables Test*Response ;
run;
Following are the results from PROC FREQ, with sensitivity, specificity, positive predictive value, negative predictive value, false positive probability, and false negative probability indicated by matching colors.
| |||||||||||||||||||||||||
Confidence intervals and tests (asymptotic and exact) for these statistics can be computed using PROC FREQ by selecting the proper row or column from the original table. The BINOMIAL option in the TABLE statement provides asymptotic and exact confidence intervals and an asymptotic test that the proportion equals 0.5 (by default). The BINOMIAL option in the EXACT statement provides all of this plus an exact test of the proportion. You can test against a null value other than 0.5 by specifying the value in parentheses after the BINOMIAL option. For example, BINOMIAL (0.75) tests against the null value of 0.75.
The following statements estimate and test each of the statistics as indicated in the TITLE statements. Note the use or omission of the ORDER=DATA option, which places the cell count that should be the numerator of the statistic first in the table. This ensures that PROC FREQ estimates and tests the proper statistic. The WHERE statement is used to select the proper row or column for the statistic.
title 'Sensitivity';
proc freq data=FatComp order=data;
where Response=1;
weight Count;
tables Test;
exact binomial;
run;
title 'Specificity';
proc freq data=FatComp;
where Response=0;
weight Count;
tables Test;
exact binomial;
run;
title 'Positive predictive value';
proc freq data=FatComp order=data;
where Test=1;
weight Count;
tables Response;
exact binomial;
run;
title 'Negative predictive value';
proc freq data=FatComp;
where Test=0;
weight Count;
tables Response;
exact binomial;
run;
title 'False Positive Probability (Col)';
proc freq data=FatComp order=data;
where Response=0;
weight Count;
tables Test;
exact binomial;
run;
title 'False Positive Probability (Row)';
proc freq data=FatComp;
where Test=1;
weight Count;
tables Response;
exact binomial;
run;
title 'False Negative Probability (Col)';
proc freq data=FatComp;
where Response=1;
weight Count;
tables Test;
exact binomial;
run;
title 'False Negative Probability (Row)';
proc freq data=FatComp order=data;
where Test=0;
weight Count;
tables Response;
exact binomial;
run;
The results for sensitivity are as follows:
The likelihood ratios, LR+ and LR, can be easily computed from the sensitivity and specificity as described above. They can also be computed using the following program, which provides a confidence interval for each. The first data line in the DATA step contains the numerator and denominator of the sensitivity. The second data line contains the numerator and denominator of the specificity. For any 2x2 table, the only change needed is to these two data lines.
data LR;
length stat $ 8;
input stat $ testpos total;
lntotal=log(total);
output;
if stat='sens' then do;
stat='senscomp';
testpos=total-testpos;
output;
end;
if stat='spec' then do;
stat='speccomp';
testpos=total-testpos;
output;
end;
datalines;
sens 11 13
spec 6 10
;
proc genmod;
where stat in ('sens','speccomp');
class stat;
model testpos/total=stat / d=b link=log;
estimate 'log LR+' stat 1 -1 / exp;
run;
proc genmod;
where stat in ('senscomp','spec');
class stat;
model testpos/total=stat / d=b link=log;
estimate 'log LR-' stat 1 -1 / exp;
run;
The ESTIMATE statement in PROC GENMOD provides point and confidence interval estimates of the log likelihood ratio (labeled log LR) and of the likelihood ratio itself (labeled Exp(log LR)). The point estimates of LR+ and LR agree with the computations above (2.1154 and 0.2564 respectively). The 95% confidence interval for LR+ is (0.9565, 4.6783) and for LR is (0.0651, 1.0107).
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Product Family | Product | System | SAS Release | |
| Reported | Fixed | |||
| SAS System | SAS/STAT | All | n/a | |
| Type: | Usage Note |
| Priority: | low |
| Topic: | SAS Reference ==> Procedures ==> FREQ SAS Reference ==> Procedures ==> GENMOD Analytics ==> Exact Methods Analytics ==> Categorical Data Analysis Analytics ==> Descriptive Statistics |
| Date Modified: | 2007-11-05 13:51:45 |
| Date Created: | 2004-09-23 15:44:42 |



