Tests, confidence intervals, and comparisons of multinomial variable probabilities


Suppose each subject in a sample of many subjects is categorized into one level of a multinomial variable (either nominal or ordinal) and you want to estimate the probabilities of the levels, test one or more hypotheses concerning the those probabilities (such as pairwise differences), and get confidence intervals for probabilities of each of the levels.

This can be done by fitting a categorical response model, without covariates, to the variable using a suitable procedure such as PROC LOGISTIC. By including an ESTIMATE statement in the PROC LOGISTIC, it can provide the probabilities of all variable levels, along with confidence intervals, except for the last level. This is because there are only k-1 independent probabilities for a multinomial variable with k levels, so only k-1 logits can be modeled. Probability estimates, standard errors, tests, and confidence intervals for all levels can be obtained using the NLMeans macro (version 3.1 or later is required). If only probabilities and confidence intervals are needed, they can be obtained using the SCORE statement.

The latest version of the NLMeans macro can be downloaded from the NLMeans macro documentation. The NLMeans macro requires version 2.1 or later of the NLEST macro. The latest version of the NLEST macro can be downloaded from the NLEST macro documentation. After downloading each macro, they must be made available in your SAS® session using the %INCLUDE statement. Follow the instructions in the Usage section in the documentation of each macro.

Example: Nominal Response

The following uses the data in the example titled "Nominal Response Data: Generalized Logits Model" in the LOGISTIC documentation. These statements show the observed probabilities in the Style variable. The levels are presented in the order they were encountered in the data.

proc freq data=School order=data; 
   table style; 
   weight count; 
   run;

The probabilities of the three Style levels, expressed as percents, appear in the Percent column in the PROC FREQ results.

These statements fit an intercepts-only generalized logit model. The ESTIMATE statement with the ILINK CL CATEGORY=JOINT options displays the probabilities, standard errors, and confidence intervals for the first two of the three Style levels. The E option in this statement as well as the ODS OUTPUT and STORE statements are needed to save the fitted model and data set of estimating coefficients for later use in the NLMeans macro. The SCORE statement with the CLM option creates a data set (ScorSchool) containing the probability estimates for all three Style levels along with their confidence limits. It also contains the predicted Style, which is the Style having the largest estimated probability.

proc logistic data=School;
   freq Count;
   model Style(order=data)= / link=glogit;
   estimate 'Pr(self) & Pr(team)' intercept 1/e ilink cl category=joint;
   score out=ScorSchool clm;
   store mod;
   ods output coef=c;
   run;

The probabilities (expressed as proportions), as well as standard errors and 95% confidence intervals (obtained by the delta method) for the Self and Team levels, appear in the "Means" columns of the Estimates table.

Estimates for all levels can be provided by the NLMeans macro using the saved model and estimate coefficients. The three probabilities are referred to by the names mu1, mu2, and mu3. You can include fdata= to specify a data set providing the probabilities, or functions of probabilities, that you want to estimate. The following DATA step creates a data set (FD) with character variable F, that specifies each probability, and character variable LABEL providing labels for each. It is also necessary to have a numeric SET variable. Since the ESTIMATE statement creates a single set of estimates, SET=1. In order for the macro to provide estimates and tests for all levels of a multinomial response variable, options=difall must also be specified and title= provides a title for the table of results.

data fd; 
   set=1;
   length label f $32767; 
   infile datalines delimiter=',';
   input label f; 
   datalines;
P(self),  mu1
P(team),  mu2
P(class), mu3
;
%nlmeans(instore=mod, coef=c, link=glogit, fdata=fd,
         options=difall, title=Style Probabilities)

The probability, standard error, test of equality to zero, and 95% confidence interval for each Style level are displayed below. The NLMeans macro always uses the delta method to obtain standard errors and confidence limits of the specified functions of means. If it is of interest to test a hypothesis that each probability equals some other value, you can specify the value in null= and include it in the NLMeans macro call. The same probability estimates and confidence limits can be found in the OUT= data set (ScorSchool) from the SCORE statement (not shown). However, standard error estimates and tests of the probabilities are not available with the SCORE statement.

Pairwise comparisons among the three probabilities can also be provided. This is the default action of the NLMeans macro.

%nlmeans(instore=mod, coef=c, link=glogit, options=difall,
         title=Style probabilities)

The Label column indicates the differences of the probabilities that are estimated. For example, the label, 1 -1 0, means that the probability of the second level (Team) is subtracted from the probability of the first level (Self). If you prefer the opposite direction of the difference in each pair, add options=reverse in the NLMeans macro call.

Example: Ordinal Response

When a k-level response variable is ordinal, categorical modeling procedures typically model an independent set of k-1 cumulative logits defined on the cumulative probabilities Pr(Y=1), Pr(Y=1 or 2), Pr(Y=1 or 2 or 3), ... , Pr(Y<k). Note that the probabilities of the individual levels can be obtained from these as differences of adjacent cumulative probabilities and the probability of the Y=k level is obtained as 1-Pr(Y<k).

Using the example titled "Ordinal Logistic Regression" in the LOGISTIC documentation, these statements fit the cumulative logit model. The ILINK option in the ESTIMATE statement produces the cumulative probabilities of the nine-level response variable. The CL option provides confidence limits on the cumulative probabilities. The SCORE statement produces estimates of the probabilities of the individual response levels. The CUMULATIVE option adds the estimates of the cumulative probabilities. The CLM option produces confidence limits for both sets of estimates.

proc logistic data=Cheese;
   freq freq;
   model y=;
   estimate 'y1-8' intercept 1/e ilink cl category=joint;
   score out=scorchees clm cumulative;
   ods output coef=c;
   store mod;
   run;

The cumulative probabilities, their standard errors, and confidence limits appear in the ESTIMATE table columns whose label includes "Mean." Note that the Standard Error of Mean values are obtained via the delta method. The Lower Mean and Upper Mean limits are obtained by applying the inverse link function to the limits in the Lower and Upper columns rather than using the delta method standard error.

The probabilities of the individual response levels, along with their confidence limits (obtained by the delta method) are also available from the SCORE statement as noted above. The estimated probabilities are in variables with prefix P_, and confidence limits are in variables with prefixes LCL_ and UCL_. The cumulative probability estimates (from the CUMULATIVE option) are in variables with prefix CP_ and their limits in variables with prefixes CLCL_ and CUCL_. However, standard error estimates and tests of the probabilities are not available with the SCORE statement.

The probabilities of the individual response levels can also be obtained from the ordinal response model by computing the difference in adjacent pairs of cumulative probabilities. Estimates for all nine response levels can be obtained in one run of the NLMeans macro by specifying a data set of the necessary functions (differences in this case) of the model estimates. Standard errors and tests of the probabilities are also provided. The following DATA step defines a data set with character variable F, that defines each difference of estimates, and character variable LABEL providing labels for each difference. It is also necessary to have a numeric SET variable. Since the ESTIMATE statement creates a single set of estimates, SET=1.

data fd; 
   set=1;
   length label f $32767; 
   infile datalines delimiter=',';
   input label f; 
   datalines;
P1, mu1
P2, mu2-mu1
P3, mu3-mu2
P4, mu4-mu3
P5, mu5-mu4
P6, mu6-mu5
P7, mu7-mu6
P8, mu8-mu7
P9, 1-mu8
;
%nlmeans(instore=mod, coef=c, link=clogit, fdata=fd, 
         options=difall, title=Response Probabilities)

The probability of each of the nine response levels is shown below. Standard errors and confidence limits are based on the delta method.