MDC Procedure

Example 23.5 Choice of Time for Work Trips: Nested Logit Analysis

(View the complete code for this example.)

This example uses sample data of 527 automobile commuters in the San Francisco Bay Area to demonstrate the use of the nested logit model.[2]

Brownstone and Small (1989) analyzed a two-level nested logit model that is displayed in Figure 30. The probability of choosing j at level 2 is written as

upper P Subscript i Baseline left-parenthesis j right-parenthesis equals StartFraction exp left-parenthesis tau Subscript j Baseline upper I Subscript j Baseline right-parenthesis Over sigma-summation Underscript j prime equals 1 Overscript 3 Endscripts exp left-parenthesis tau Subscript j prime Baseline upper I Subscript j prime Baseline right-parenthesis EndFraction

where upper I Subscript j prime is an inclusive value and is computed as

upper I Subscript j prime Baseline equals ln left-bracket sigma-summation Underscript k prime element-of upper C Subscript j prime Baseline Endscripts exp left-parenthesis bold x prime Subscript i k prime Baseline bold-italic beta right-parenthesis right-bracket

The probability of choosing an alternative k is denoted as

upper P Subscript i Baseline left-parenthesis k vertical-bar j right-parenthesis equals StartFraction exp left-parenthesis bold x prime Subscript i k Baseline bold-italic beta right-parenthesis Over sigma-summation Underscript k prime element-of upper C Subscript j Baseline Endscripts exp left-parenthesis bold x prime Subscript i k prime Baseline bold-italic beta right-parenthesis EndFraction

The full information maximum likelihood (FIML) method maximizes the following log-likelihood function,

script upper L equals sigma-summation Underscript i equals 1 Overscript upper N Endscripts sigma-summation Underscript j equals 1 Overscript upper J Endscripts d Subscript i j Baseline left-bracket ln left-parenthesis upper P Subscript i Baseline left-parenthesis k vertical-bar j right-parenthesis right-parenthesis plus ln left-parenthesis upper P Subscript i Baseline left-parenthesis j right-parenthesis right-parenthesis right-bracket

where d Subscript i j Baseline equals 1 if a decision maker i chooses j, and 0 otherwise.

Figure 30: Decision Tree for Two-Level Nested Logit

Decision Tree for Two-Level Nested Logit


Sample data of 527 automobile commuters in the San Francisco Bay Area have been analyzed by Small (1982); Brownstone and Small (1989). The regular time of arrival is recorded as between 42.5 minutes early and 17.5 minutes late, and indexed by 12 alternatives, using five-minute interval groups. For more information about these data, see Small (1982). The following statements estimate the two-level nested logit model:

/*-- Two-level Nested Logit --*/
proc mdc data=small maxit=200 outest=a;
   model decision = r15 r10 ttime ttime_cp sde sde_cp
                    sdl sdlx d2l /
            type=nlogit
            choice=(alt);
   id id;
   utility u(1, ) = r15 r10 ttime ttime_cp sde sde_cp
                    sdl sdlx d2l;
   nest level(1) = (1 2 3 4 5 6 7 8 @ 1, 9 @ 2, 10 11 12 @ 3),
        level(2) = (1 2 3 @ 1);
run;

The following statements add the upalt variable, which describes the choice at the upper level of the nested tree to the data set:

data small;
   set small;
   upalt=1;
   if alt=9 then upalt=2;
   if alt>9 then upalt=3;
run;

The following statements show and alternative specification, which uses the CHOICE= option with two nested levels that are represented by upalt and alt:

proc mdc data=upalt maxit=200;
   model decision = r15 r10 ttime ttime_cp sde sde_cp
                    sdl sdlx d2l /
            type=nlogit
            choice=(upalt,alt);
   id id;
   utility u(1, ) = r15 r10 ttime ttime_cp sde sde_cp
                    sdl sdlx d2l;
run;

The estimation summary, discrete response profile, and the FIML estimates are displayed in Output 23.5.1 through Output 23.5.3.

Output 23.5.1: Nested Logit Estimation Summary

The MDC Procedure
 
Nested Logit Estimates

Model Fit Summary
Dependent Variabledecision
Number of Observations527
Number of Cases6324
Log Likelihood-990.81912
Log Likelihood Null (LogL(0))-1310
Maximum Absolute Gradient4.93868E-6
Number of Iterations18
Optimization MethodNewton-Raphson
AIC2006
Schwarz Criterion2057


Output 23.5.2: Discrete Choice Characteristics

Discrete Response Profile
IndexaltFrequencyPercent
0161.14
12101.90
236111.57
34152.85
45275.12
568015.18
675510.44
786412.14
8918735.48
910132.47
101181.52
111210.19


Output 23.5.3: Nested Logit Estimates

The MDC Procedure
 
Nested Logit Estimates

Parameter Estimates
ParameterDFEstimateStandard
Error
t ValueApprox
Pr > |t|
r15_L111.10340.12219.04<.0001
r10_L110.39310.11943.290.0010
ttime_L11-0.04650.0235-1.980.0474
ttime_cp_L11-0.04980.0305-1.630.1028
sde_L11-0.66180.0833-7.95<.0001
sde_cp_L110.05190.12780.410.6850
sdl_L11-2.10060.5062-4.15<.0001
sdlx_L11-3.52401.5346-2.300.0217
d2l_L11-1.09410.3273-3.340.0008
INC_L2G1C110.67620.27542.460.0141
INC_L2G1C211.09060.30903.530.0004
INC_L2G1C310.76220.16494.62<.0001


Now policy makers are particularly interested in predicting shares of each alternative to be chosen by population. One application of such predictions are market shares. Going even further, it is extremely useful to predict choice probabilities out of sample; that is, under alternative policies.

Suppose that in this particular transportation example you are interested in projecting the effect of a new program that indirectly shifts individual preferences with respect to late arrival to work. This means that you manage to decrease the coefficient for the "late dummy" D2L, which is a penalty for violating some margin of arriving on time. Suppose that you alter it from an estimated –1.0941 to almost twice that level, –2.0941.

But first, in order to have a benchmark share, you predict probabilities to choose each particular option and output them to the new data set with the following additional statement:

   /*-- Create new data set with predicted probabilities --*/
   output out=predicted1 p=probs;

Having these in sample predictions, you sort the data by alternative and aggregate across each of them as shown in the following statements:

/*-- Sort the data by alternative --*/
proc sort data=predicted1;
   by alt;
run;

/*-- Calculate average probabilities of each alternative --*/
proc means data=predicted1 nonobs mean;
   var probs;
   class alt;
run;

Output 23.5.4 shows the summary table that is produced by the preceding statements.

Output 23.5.4: Average Probabilities of Choosing Each Particular Alternative

The MEANS Procedure

Analysis Variable : probs
altMean
10.0178197
20.0161712
30.0972584
40.0294659
50.0594076
60.1653871
70.1118181
80.1043445
90.3564940
100.0272324
110.0096334
120.0049677


Now you change the preference parameter for variable D2L. In order to fix all the parameters, you use the MAXIT=0 option to prevent optimization and the START= option in MODEL statement to specify initial parameters.

/*-- Two-level Nested Logit --*/
proc mdc data=small maxit=0 outest=a;
   model decision = r15 r10 ttime ttime_cp sde sde_cp
                    sdl sdlx d2l /
            type=nlogit
            choice=(alt)
            start=( 1.1034 0.3931 -0.0465 -0.0498
                   -0.6618 0.0519 -2.1006 -3.5240
                   -2.0941 0.6762  1.0906  0.7622);
   id id;
   utility u(1, ) = r15 r10 ttime ttime_cp sde sde_cp
                    sdl sdlx d2l;
   nest level(1) = (1 2 3 4 5 6 7 8 @ 1, 9 @ 2, 10 11 12 @ 3),
        level(2) = (1 2 3 @ 1);
   output out=predicted2 p=probs;
run;

You apply the same SORT and MEANS procedures as applied earlier to obtain the following summary table in Output 23.5.5.

Output 23.5.5: Average Probabilities of Choosing Each Particular Alternative after Changing the Preference Parameter

The MEANS Procedure

Analysis Variable : probs
altMean
10.0207766
20.0188966
30.1138816
40.0345654
50.0697830
60.1944572
70.1315588
80.1228049
90.2560674
100.0236178
110.0090781
120.0045128


Comparing the two tables shown in Output 23.5.4 and Output 23.5.5, you clearly see the effect of increased dislike of late arrival. People shifted their choices towards earlier times (alternatives 1–8) from the on-time option (alternative 9).

Brownstone and Small (1989) also estimate the two-level nested logit model with equal scale parameter constraints, tau 1 equals tau 2 equals tau 3. Replication of their model estimation is shown in the following statements:

/*-- Nested Logit with Equal Dissimilarity Parameters --*/
proc mdc data=small maxit=200 outest=a;
   model decision = r15 r10 ttime ttime_cp sde sde_cp
                    sdl sdlx d2l /
            samescale
            type=nlogit
            choice=(alt);
   id id;
   utility u(1, ) = r15 r10 ttime ttime_cp sde sde_cp
                    sdl sdlx d2l;
   nest level(1) = (1 2 3 4 5 6 7 8 @ 1, 9 @ 2, 10 11 12 @ 3),
        level(2) = (1 2 3 @ 1);
run;

The parameter estimates and standard errors are almost identical to those in Brownstone and Small (1989, p. 69). Output 23.5.6 and Output 23.5.7 display the results.

Output 23.5.6: Nested Logit Estimation Summary with Equal Dissimilarity Parameters

The MDC Procedure
 
Nested Logit Estimates

Model Fit Summary
Dependent Variabledecision
Number of Observations527
Number of Cases6324
Log Likelihood-994.39402
Log Likelihood Null (LogL(0))-1310
Maximum Absolute Gradient2.97172E-6
Number of Iterations16
Optimization MethodNewton-Raphson
AIC2009
Schwarz Criterion2051


Output 23.5.7: Nested Logit Estimates with Equal Dissimilarity Parameters

The MDC Procedure
 
Nested Logit Estimates

Parameter Estimates
ParameterDFEstimateStandard
Error
t ValueApprox
Pr > |t|
r15_L111.13450.109210.39<.0001
r10_L110.41940.10813.880.0001
ttime_L11-0.16260.0609-2.670.0076
ttime_cp_L110.12850.08531.510.1319
sde_L11-0.75480.0669-11.28<.0001
sde_cp_L110.22920.09812.340.0195
sdl_L11-2.07190.4860-4.26<.0001
sdlx_L11-2.82161.2560-2.250.0247
d2l_L11-1.31640.3474-3.790.0002
INC_L2G110.80590.17054.73<.0001


However, the test statistic for upper H 0 colon tau 1 equals tau 2 equals tau 3 rejects the null hypothesis at the 5% significance level since negative 2 asterisk left-parenthesis ln upper L left-parenthesis 0 right-parenthesis minus ln upper L right-parenthesis equals 7.15 greater-than chi Subscript 0.05 comma 2 Superscript 2 Baseline equals 5.99. The p-value is computed in the following statements and is equal to 0.0280:

data _null_;
   /*-- test for H0: tau1 = tau2 = tau3 --*/
   /*   ln L(max) = -990.8191             */
   /*   ln L(0)   = -994.3940             */
   stat = -2 * ( -994.3940 + 990.8191 );
   df = 2;
   p_value = 1 - probchi(stat, df);
   put stat= p_value=;
run;


[2] These data were provided by Professor Kenneth Small. They were collected for the urban travel demand forecasting project, which was carried out by McFadden, Talvitie, and Associates (1977). The project was supported by the National Science Foundation, Research Applied to National Needs Program, through grants GI-43740 and APR74-20392 and by the Alfred P. Sloan Foundation through grant 74-21-8.

Last updated: June 19, 2025