GAUSS Conditional Logit Example

This example runs the conditional logit model using the GAUSS DC application. It uses data which includes 152 observations on the mode of transportation choice. The examples model transportation choice as a function of terminal waiting time ( TTME ), in-vehicle time ( INVT ), in-vehicle cost ( INVC ) and a generalized cost measure ( GC ).

Load the data

This example uses the formula string syntax to load data using loadd. The formula string syntax syntax allows users to load, transform and analyze data in one line.

new;
cls;
library dc;

//Load data
fname = getGAUSShome() $+ "examples/dc/powersxie.dat";
y = loadd(fname);

Set up the model parameters

The Discrete Choice Module uses a suite of dcSet functions to set various features of the model. An instance of the dcControl structure must be declared for storing all parameters prior to calling any dcSet functions.

//Step One: dcControl structure
//Declare dcControl struct
struct dcControl dcCt;
//Initialize dcControl struct
dcCt = dcControlCreate();

//Step two: Describe data Labels
//Variable name of category data
dcSetYVar(&dcCt,y[.,2]);
//Dependent variable
dcSetYLabel(&dcCt,"mode");

dcSetCategoryVarLabels(&dcCt,"choiceno");

//Category Labels
dcSetCategoryVar(&dcCt,y[.,1]);
dcSetYCategoryLabels(&dcCt,"train,bus,car");

//Set attributes Labels
dcSetAttributeVars(&dcCt,y[.,3:6]);
dcSetAttributeLabels(&dcCt,"ttme,invc,invt,GC");

//Turn off constant
//mydcData.d1.noconstant = 1;
dcSetConstant(&dcCt,"off");

//Set starting values
// No b0 because no constant
// No b because no x vars

//gm because including attributes
g1 = { .1  .1  .1 .1 };

mask = {1 1 1 1};
dcCt.startValues = pvPackmi(dcCt.startValues, g1' , "g1" , mask', 3);

Estimate the Model

The conditional logit model can be estimated using the conditionalLogit procedure. This function takes a dcControl structure as an input and returns all output to a dcOut structure. In addition, a complete report of results can be printed to screen using the printDCOut procedure.

//Step three: Declare dcOut struct
struct dcout dcout1;

//Step Four: Call ConditionalLogit
dcout1 = conditionalLogit(dcCt);

//Print Results
call printDCOut(dcOut1);

Output

The output from conditionalLogit reads

Conditional Logit Results
Number of Observations:   152
Degrees of Freedom:       148

  1 - train
  2 - bus
  3 - car

Distribution Among Outcome Categories For mode
Dependent Variable       Proportion
train 0.4145
bus 0.1974
car 0.3882
COEFFICIENTS Coefficient Estimates --------------------------------------------------------------------------- Variables Coefficient se tstat pval ttme -0.00224 0.00714 -0.314 0.754 invc -0.435** 0.133 -3.28 0.00105 invt -0.0772*** 0.0194 -3.99 6.57e-05 GC 0.431** 0.133 3.24 0.00121 --------------------------------------------------------------------------- *p-val<0.1 **p-val<0.05 ***p-val<0.001
ODDS RATIO Odds Ratio ---------------------------------------------------------------------------- Variables Odds Ratio 95% Lower Bound 95% Upper Bound ttme 0.99776 0.98389 1.0118 invc 0.64719 0.4989 0.83957 invt 0.92567 0.89122 0.96146 GC 1.539 1.1854 1.9981 ---------------------------------------------------------------------------- MARGINAL EFFECTS
Partial probability with respect to mean attributes Marginal Effects for Attribute: ttme ------------------------------------------------------------ Variables train bus car
train -0.00029 9.5e-05 0.000195
( 0.000928) ( 0.000295) ( 0.000633)
bus 9.5e-05 -0.000218 0.000123
( 0.000295) ( 0.000683) ( 0.000388)
car 0.000195 0.000123 -0.000318
( 0.000633) ( 0.000388) ( 0.00102)
------------------------------------------------------------ Estimate se in parentheses. *p-val<0.1 **p-val<0.05 ***p-val<0.001
Marginal Effects for Attribute: invc -------------------------------------------------------- Variables train bus car
train -0.0564*** 0.0184*** 0.0379***
( 0.0159) ( 0.00526) ( 0.0111)
bus 0.0184*** -0.0423*** 0.0238**
( 0.00526) ( 0.0123) ( 0.00738)
car 0.0379*** 0.0238** -0.0618***
( 0.0111) ( 0.00738) ( 0.0181)
-------------------------------------------------------- Estimate se in parentheses. *p-val<0.1 **p-val<0.05 ***p-val<0.001
Marginal Effects for Attribute: invt ------------------------------------------------------------ Variables train bus car
train -0.01*** 0.00327*** 0.00674***
( 0.00225) ( 0.000769) ( 0.00159)
bus 0.00327*** -0.0075*** 0.00423***
( 0.000769) ( 0.00172) ( 0.00103)
car 0.00674*** 0.00423*** -0.011***
( 0.00159) ( 0.00103) ( 0.00254)
------------------------------------------------------------ Estimate se in parentheses. *p-val<0.1 **p-val<0.05 ***p-val<0.001
Marginal Effects for Attribute: GC -------------------------------------------------------- Variables train bus car
train 0.0559*** -0.0183*** -0.0376**
( 0.0161) ( 0.00528) ( 0.0113)
bus -0.0183*** 0.0419*** -0.0236**
( 0.00528) ( 0.0122) ( 0.00731)
car -0.0376** -0.0236** 0.0612***
( 0.0113) ( 0.00731) ( 0.0182)
-------------------------------------------------------- Estimate se in parentheses. *p-val<0.1 **p-val<0.05 ***p-val<0.001
********************SUMMARY STATISTICS******************** MEASURES OF FIT: -2 Ln(Lu): 192.6971 -2 Ln(Lr): All coeffs equal zero 333.9781 -2 Ln(Lr): J-1 intercepts 320.0034 LR Chi-Square (coeffs equal zero): 141.2811 d.f. 4.0000 p-value = 0.0000 LR Chi-Square (J-1 intercepts): 127.3064 d.f. 2.0000 p-value = 0.0000 Count R2, Percent Correctly Predicted: 123.0000 Adjusted Percent Correctly Predicted: 0.6742 Madalla's pseudo R-square: 0.5672 McFadden's pseudo R-square: 0.3978 Ben-Akiva and Lerman's Adjusted R-square: 0.3978 Cragg and Uhler's pseudo R-square: 0.1818 Akaike Information Criterion: 1.3204 Bayesian Information Criterion: 1.4000 Hannan-Quinn Information Criterion: 1.3527 OBSERVED AND PREDICTED OUTCOMES | Predicted Observed | train bus car Total ---------------------------------------------------------- train | 47 0 16 63 bus | 0 23 7 30 car | 3 3 53 59 ---------------------------------------------------------- Total | 50 26 76 152

Have a Specific Question?

Get a real answer from a real person

Need Support?

Get help from our friendly experts.

REQUEST A FREE QUOTE

Thank you for your interest in the GAUSS family of products.

© Aptech Systems, Inc. All rights reserved.

Privacy Policy | Sitemap