In a 2 × 2 table, a zero cell count in a row of the table causes the risk (event probability) to be either zero or infinite. As a result, the relative risk (risk ratio) and odds ratio is also either zero or infinite. One option is to add a small value such as 0.5 to every cell count in the table. However, in addition to concern over altering the data, the choice of the added value is arbitrary and can significantly affect the estimate. Another option that does not involve changing the data uses a model-based approach. Both are illustrated below for a single table and a stratified table.
Single table, PROC FREQ analysis
The following statements create a 2 × 2 table with binary response, Y, in two conditions, T. Y=1 is considered the event of interest. The table has zero events in the T=2 row. PROC FREQ analyzes the table. The ORDER=DATA option is used to arrange the table with Y=1 as the first column. The RELRISK option requests estimation of the relative risk and odds ratio without changing the zero count. The CMH option also estimates the relative risk and odds ratio. The logit estimator provided by the CMH option adds 0.5 to the zero count. Both options attempt to estimate the relative risk when column 1 (Y=1) is considered the event as well as when column 2 (Y=0) is considered the event. Since Y=1 is considered the event, the Column 1 relative risk is of interest:
data a;
do t=1,2; do y=1,0;
input f @@; output;
end; end;
datalines;
7 248
0 129
;
proc freq data=a order=data;
weight f;
table t*y / relrisk cmh;
run;
The results from the RELRISK option show that the odds ratio and Column 1 relative risk cannot be estimated because of the zero count. The CMH option provides logit-based estimates of the odds ratio (7.8169) and Column 1 relative risk (7.6172) by adding 0.5 to all cell counts.
Single table, PROC LOGISTIC and NLMeans analysis
An alternative is to fit a logistic model to the data and then use the NLMeans macro to estimate the odds ratio and relative risk. But just as the zero count inhibits estimation of these statistics in PROC FREQ, it also causes problems in fitting the model. The effect of the zero count in PROC LOGISTIC is that the parameters of the model are actually infinite but manifests as large parameter estimates and standard errors as well as Warning messages about "separation." Separation is further discussed in SAS KB0056924. The problem of separation can often (though not always) be avoided by altering the iterative model estimation method to use a penalized likelihood function. This can be done by adding the FIRTH option in the MODEL statement. Note that the Firth method is not currently available in PROC LOGSELECT.
The following statements fit a logistic model to the table data above using the Firth method. The EVENT="1" option designates Y=1 as the event level. The LSMEANS statement with the ILINK and CL options estimate the risk (event probability) at each level of T. The E option displays the table of coefficients that define each risk. The STORE statement saves the fitted model, and the ODS OUTPUT statement saves the risk coefficients. These are needed by the NLMeans macro to estimate the relative risk:
proc logistic data=a; freq f; class t / param=glm; model y(event="1")=t / firth; lsmeans t / ilink cl e; store log; ods output coef=c; run;
The odds ratio estimate provided by PROC LOGISTIC is 7.815, similar to the CMH estimate above. In the table from the LSMEANS statement below, the Mean column displays the estimated risks. The following columns provide the standard errors and confidence limits for the risks. Note that the estimated risks, 0.0293 and 0.0038 differ slightly from the row probabilities shown in the PROC FREQ table above. Interestingly, if you add 0.5 to each of the cell counts in the table, the row probabilities in the resulting table almost exactly match the estimated risks in the LSMEANS table.
The NLMeans macro can then estimate the relative risk. The saved model and the risk coefficients are specified with instore= and coef=. Since the model is a logistic model, link=logit is specified. To request the ratio of the risks rather than the difference, which is the default, specify options=ratio. With a ratio, testing its equality to 1 is usually of interest and this is specified using null=1. A title is also specified:
%nlmeans(instore=log, coef=c, link=logit, null=1,
options=ratio, title=Relative Risk)
In the resulting table, "1 /1" in the Label indicates that the ratio was formed as the first (T=1) risk divided by the second (T=2) risk. The estimated relative risk, 7.6150, is similar to the estimate from the CMH option in PROC FREQ above. The estimate does not differ significantly from 1 (p=0.5524) with a wide confidence interval (the negative lower limit can effectively be considered zero).
Stratified table, PROC FREQ analysis
The same issue exists in stratified 2 × 2 tables. Again, zero counts in a stratum's table can prevent the estimate of the relative risk and odds ratio in that table. But in stratified tables, the common (overall) relative risk and odds ratio are usually of interest. These can be provided by the CMH option. As above, CMH will add 0.5 to all cell in any table with zero counts allowing estimation of the common relative risk and odds ratio. The model-based approach can also be used.
In this example, the tables in both strata have a zero count. The RELRISK option displays the relative risk and odds ratio table for each stratum and the CMH option displays the table of common relative risks and odds ratio:
data b;
do z=1,2;
do x=1,2;
do y=1,0;
input f @@; output;
end; end; end;
datalines;
6 9 0 6
4 21 0 14
;
proc freq order=data;
weight f;
table z*x*y / relrisk cmh;
run;
In each stratum table, the odds ratio and Column 1 relative risk cannot be computed by the RELRISK option. However, the Column 1 common relative risk estimate (5.4445) and the common odds ratio estimate (7.3255) are provided by the CMH option after adding 0.5 in each cell in each table.
Stratified table, PROC LOGISTIC and NLMeans analysis
In the model-based approach, the stratifying variable, Z, is included in the model with X whose ratio of risks is of interest:
proc logistic data=b;
freq f;
class x z / param=glm;
model y(event="1") = z x / firth;
lsmeans x / e cl ilink;
ods output coef=c;
store log;
run;
%nlmeans(instore=log, coef=c, link=logit, null=1,
options=ratio, title=Relative Risk)
The estimated common odds ratio for X (13.686) and common relative risk for X from the model-based approach (10.2076) are somewhat larger than is estimated by the CMH method above. For both statistics, their confidence intervals are quite wide, including the value 1 in both intervals. This suggests that neither statistic differs significantly from 1.