Discrete Choice Examples: Nested Logit


The nested logit model expands the use of logit modeling techniques to allow for dependence across responses, by grouping alternatives into broader categories or nests.  

The observed outcome then becomes the result of a multi-level decision process. At each level of that process, there are observed outcomes and attributes associated with specific choices. In addition, individuals making a decision may have specific characteristics that impact the outcomes but are NOT outcome specific.

In this example we consider the mode of transportation choice model found in Greene (2010). The dependent data, mode, measures mode of transportation across four possible choices: air, train, bus, or car. The choice specific attributes considered include terminal waiting time ( ttme ) and generalized cost ( GC ). In addition, an interaction term between each individuals' income level and the choice to fly is included ( AIRHINC ). Outcomes are considered on two nest levels: first the decision to fly or travel by ground, then the decision of what mode of air or ground transportation.

Step 1: Load the data

The data for this model is first loaded from an existing GAUSS matrix file (.fmt).

library dc;

// Load data
y = loadd("hensher_mat.fmt");

Step 2: Create a control structure

Once the data is loaded in GAUSS, the estimation features are specified using the dcControl structure.

// Declare dcControl structure
struct dcControl dcCt;

// Fill with default settings
dcCt = dcControlCreate();

Step 3: Specify data

Next, use dcSet procedures to specify the data structure of the model.

// Dependent variable

// Category labels

// Reference category
dcSetReferenceCategory(&dcCt, "Car");

// Independent variables

Step 4: Create nests

Once the data description is complete, nests can be set up. The first step is to create the number of desired nests, in this case, two.

// Create nests

With nests made, level specific attributes and outcomes categories are specified.

// Set attributes and categories for lower nest (Nest One)

// Set attributes and categories for upper nest (Nest Two)

Finally, lower level outcomes are assigned to proper branches:

// Make nest assignments
dcAssignLogitNests(&dcCt, 1,"Air,Train,Bus,Car", "Fly,Ground,Ground,Ground");

Step 5: Estimate nested logit model and print results

Once data and nests are set up the model is ready for estimation using the nestedLogit procedure.

// Declare structure to hold estimation results
struct dcout dcout1;

// Perform estimation and store results in 'dcout1'
dcout1 = nestedLogit(dcCt);

// Print output report
call printDCOut(dcOut1);

A model and data description is printed to screen.

Nested Logit Results

Number of Observations:   210
Degrees of Freedom:       202

  1 - Air
  2 - Train
  3 - Bus
  4 - Car

Distribution Among Outcome Categories For Mode 

Dependent Variable       Proportion  
Air                       0.2762     
Train                     0.3000     
Bus                       0.1429     
Car                       0.2810
Model coefficients and associated odd ratios are printed to screen:

Coefficient Estimates

       Variables      Coefficient               se            tstat             pval 
   Constant: Air          6.04***             1.33             4.54        5.66e-006 
 Constant: Train          5.06***            0.676             7.49        6.79e-014 
   Constant: Bus           4.1***            0.629             6.51        7.33e-011 
            TTME        -0.113***           0.0118            -9.52        1.68e-021 
              GC       -0.0316***          0.00743            -4.25        2.15e-005 
         AIRHINC           0.0153           0.0111             1.38            0.168 
       Corr: Fly         0.586***            0.113             5.18        2.18e-007 
    Corr: Ground          0.389**            0.158             2.46           0.0138 
*p-val<0.1 **p-val<0.05 ***p-val<0.001 


Odds Ratio

       Variables       Odds Ratio  95% Lower Bound  95% Upper Bound 
            TTME          0.89349          0.87302          0.91444 
              GC          0.96891          0.95489          0.98313 
         AIRHINC           1.0154          0.99355           1.0378 
       Corr: Fly           1.7968           1.4397           2.2425 
    Corr: Ground           1.4754           1.0827           2.0106 
As are the marginal effects: Finally summary and diagnostic statistics are printed to screen:

Have a Specific Question?

Get a real answer from a real person

Need Support?

Get help from our friendly experts.

Try GAUSS for 30 days for FREE

See what GAUSS can do for your data

© Aptech Systems, Inc. All rights reserved.

Privacy Policy