TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

60
Phd in Transportation / Transport Demand Modelling 1 Phd Program in Transportation Transport Demand Modeling Filipe Moura ([email protected]) Session 2 Discrete Choice Models An Application of Multinomial Logit and Nested Logits (Aknowledgements are given to Gonรงalo Correia who prepared the previous version of this slides)

Transcript of TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Page 1: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 1

Phd Program in Transportation

Transport Demand Modeling

Filipe Moura([email protected])

Session 2Discrete Choice Models

An Application of Multinomial Logit and Nested Logits

(Aknowledgements are given to Gonรงalo Correia who prepared the previous version of this slides)

Page 2: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 2

Application of a Multinomial Logit

Page 3: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 3

Revealed Preference Experiments

q When calibrating discrete choice models we may recur to two different types of data: Revealed Preference (RP) or Stated Preference (SP).

q Revealed Preference: We survey the population to what they are doing now, with the choice set they perceive to have available now. In mode choice (our most important choice in Transportation) this means having the attributes of the respondents, the attributes of the modes they have available (this is not straightforward) and the choices they make everyday.

Page 4: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 4

A Modal Choice Revealed Preference Survey in Australia โ€“ Lab (I)

q This survey is part of the Book โ€œApplied Choice Analysis: A Primerโ€ by David Hensher, et al (2005). They have a Revealed and a Stated Preference Survey.

q We start just with the Revealed Preference (RP) survey for understanding how to estimate MNL models in NLOGIT (Econometric Software Inc.).

q Each respondent in the sample answered a questionnaire about the trip they had the day before of the survey.

q For this Lab we have filtered the data, selecting just some of the available explanatory variables.

Page 5: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 5

Variable Meaning

ALTIJ Alternative Number: 1 = DRIVE ALONE, 2 = RIDE SHARE, 3 = BUS, 4 = TRAIN, 5 = WALK, 6 = BICYCLE;

CHOICE 1, chosen, 0 not chosen

CSET Number of alternatives in each comparison. In this case there are always 2.

MPTRFARE Cost of public transport ($AUS)

MPTRTIME Time on public transport (min)

WAITTIME Time waiting for public transport (min)

AUTOTIME Time inside the automobile (min)

VEHPRKCT Cost of parking in destination ($AUS)

VEHTOLCT Paid toll ($AUS)

NUMBVEHS (SDC) Number of vehicles in household

WKROCCUP (SDC) Occupation category:1 = Managers and Admin, 2 = Professionals, 3 = Para-professional, 4 = Tradespersons, 5 = Clerks, 6 = Sales, 7 = Plant operators, 8 = Laborers , 9 = Other

PERAGE (SDC) Age

A Modal Choice Revealed Preference Survey in Australia โ€“ Lab (II)

Page 6: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 6

q Variables ALTIJ, CHOICE and CSET, allow building the dependent variable of the DCM.

q ALTIJ will identify the mode of transportation that each line of data represents, CHOICE will tell which of the lines (modes) has been chosen from the Choice set, and finally CSET will tell how many lines (alternatives) are in each choice which respondents have answered.

q In this RP survey each choice is made between the mode of transportation that the user has selected the day before and in the questionnaire they were also asked to give attribute levels of a single alternative means of traveling to work as perceived by that respondent. This second mode was deemed the alternative mode.

A Modal Choice Revealed Preference Survey in Australia โ€“ Lab (III)

Variable (continue) Meaning

DISDWCBD (like an SDC) Distance to the Central Business District (CBD) (km)

TRIPTIME Trip time in Bicycle or walking (min)

Page 7: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 7

Data Sample

(โ€ฆ)

Page 8: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 8

Building the Utility Functions for an MNLThe first step on running an MNL is thinking of an initial structure for the Utility functions. My proposal is the following:

Drive alone Utility:U(DA) =ASDR+TDRDA*AUTOTIME+COST*VEHPRKCT+COST*VEHTOLCT+VEHD*NUMBVEHS+AGE*PERAGE+MANAGE*MANAGERS/Ride Share Utility:U(RS) = ASRS +COST*VEHPRKCT+COST*VEHTOLCT/Bus Utility:U(BUS) = ASBU +COST*MPTRFARE + TPTBUS*MPTRTIME+TW*WAITTIME/Train Utility:U(TRAIN) = ASTR + COST*MPTRFARE/ +TPTTRA*MPTRTIME+TW*WAITTIME+DISTAN*DISDWCBDWalk Utility:U(WALK) = ASWA+TRPEDBI*TRIPTIME/Cycle Utility:U(CYCLE) = TRPEDBI*TRIPTIME

New Variable!

Reference Alternative

Coefficient Variable

Page 9: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 9

MNLโ€™s in Nlogitq The command in Nlogit to create MNL models is the DISCRETECHOICE

(or NLOGIT) command. Go to Model->Discrete Choice->Discrete Choice.

Instead of having the choice we could have a frequency of choices, which Nlogit transforms in probabilities.

If we want to give a higher weigh to some choices, for instance, due to sample stratification

Page 10: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 10

MNLโ€™s in NlogitIt does not allow to specify different weighs for the same alternative attribute like travel time of BUS and travel time of Car.

Best Option! We have all the freedom we want

Page 11: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 11

The code in Nlogit

Will produce a new variable called โ€œProbโ€ with the probability of the alternative being chosen in its choice set

Cross tabulation of true versus predicted choices

Verifies the data before estimation

Describes all utility functions and their coefficients estimates

Creates the new variable according to an existing one. We should not introduce a categorical variable directly in the model because we are implicitly considering a linear effect of the categories on the utility which is most of the times false.

qRun the model by selecting all text with your cursor and pressing go!

But the best to do is really to write the code it self:

Considers all the data for estimating the model

Page 12: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 12

The output

Be careful this Chi-squared is not computed correctly. It is supposed to be the test comparing LL(c) and LL(*) that is why it has 10 degrees of freedom: 15-5. However what is doing is wrong! He is applying the following: 2*(LL(c)+LL(*))=2*(392,51+344,18)=1473

It is the Log Likelihood

Choice Makers, not data lines

Page 13: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 13

q Due to the error in Nlogit we must compute ourselves, the Log Likelihood ratio and the pseudo-R2 for a base model with equal shares.

q Each respondent chooses one of two alternatives, thus equal shares means 0.5 probability of choice in each choice set for each of the alternatives, thus we have:

๐ฟ๐ฟ 0 = (1 โˆ— ln 0.5 + 0 โˆ— ln(0.5)) โˆ— 854=-591,94q The Log Likelihood ratio will then be: โˆ’2(๐ฟ(0) โˆ’ ๐ฟ(โˆ—)) =โˆ’2(โˆ’591.94โˆ’ (โˆ’344.1845)) = 495,511With degrees of freedom=15-0=15

Comparing to a model with equal shares

In Excel:=INV.CHI(0.05,15)=24,99

24.99

5%

495,511(โ€ฆ)We reject the hypothesis that our model is the same as a base model with equal shares.

Pseudo R2 (McFadden)= 1-(-344.1845/-591,94)=0.419

Page 14: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 14

q NLOGIT;Lhs=CHOICE,CSET,ALTIJ;Choices=DA,RS,BUS,TRAIN,WALK,CYCLE;Rh2=ONE$

Comparing to a model with ASCs

In Excel:=INV.CHI(0.05,10)=18.307

18.307

We reject the hypothesis that our model is the same as a base model with just the alternative specific constants.

5%

96,651(โ€ฆ)

โˆ’2(๐ฟ(๐‘) โˆ’ ๐ฟ(โˆ—)) =โˆ’2(โˆ’๐Ÿ‘๐Ÿ—๐Ÿ.๐Ÿ“๐Ÿ โˆ’ (โˆ’344.1845)) == 96.651

degrees of freedom=15-5=10

Page 15: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 15

Crosstab of Actual vs Predicted

DA RS BUS TRAIN WALK CYCLE Total

DA 446 19 17 11 3 3 499 58,4%

RS 11 79 16 21 3 4 135 15,8%

BUS 20 15 53 7 0 0 95 11,12%

TRAIN 15 18 9 33 2 0 78 9,13%

WALK 3 2 0 2 9 4 20 2,34%

CYCLE 4 2 0 4 3 15 27 3,16%

Total 499 135 95 78 20 27 854

58,4% 15,8% 11,12% 9,13% 2,34% 3,16%

qThe predicted choices are obtained by computing the probabilities and if ๐‘ƒ ๐‘– >๐‘ƒ ๐‘— โˆ€๐‘—๐œ–๐ฝ we say that alternative ๐‘– is chosen.

%๐ถ๐‘œ๐‘Ÿ๐‘Ÿ๐‘’๐‘๐‘ก๐‘ƒ๐‘Ÿ๐‘’๐‘‘๐‘–๐‘๐‘ก๐‘–๐‘œ๐‘›๐‘  =635854 = 74% Good prediction ability.

Actual

Predicted

Page 16: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 16

MNL Coefficients results

Number of vehicles in the household is very positive for choosing to drive alone

Time walking and bicycling is very negative for those alternatives

Experiment at home: Try considering one alternative specific coefficient for the travel time in bicycle and another for the time walking โ€ฆ see what happens. Determine the value of driving time alone.

Not being able to explain part of the disutility of these modes against the reference alternative, the Bicycle

Page 17: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 17

Wald StatisticTest if we can reject the hypothesis of the cost parameter being zero:WALD;FN1:COST-0$

This results in exactly the same value as in the previous table. Because we are testing the same hypothesis.

Test if we can reject the hypothesis of the travel time inside the bus and the time waiting for the bus have the same weight in the Utility function:WALD;FN1:TPTBUS-TW$

We reject the hypothesis that both are the same

Page 18: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 18

Aggregating across Individualsq With the Prob variable we may aggregate across individuals and obtain

the modal shares using Excel:

q See that the model is reproducing the shares in the sample. This must always happen because it is a direct result of the estimation process.

Page 19: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 19

Application of a Nested Logit

Page 20: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 20

A mode choice SP experiment Australia (I)

q The experiment showed 4 transportation alternatives to the respondents in several cities in Australia.

q However the choice set was between: Car with toll; Car with no toll; bus; train; busway and light rail (these last two, were non-existent at that time).

(Hensher et al, 2005)

Page 21: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 21

q To initiate this experiment the trip length in terms of travel time relevant for each respondentโ€™s current commuting trip was first established so that the travel choices could be given in a context that had some reality for the respondent. The travel choice sets were divided into trip lengths of:

ยง Less than 30 minutes: Short tripยง 30โ€“45 minutes: Medium tripยง Over 45 minutes: Long trip

q In participating in the choice experiments, each respondent was asked to consider a context in which the offered set of attributes and levels represented the only available means of undertaking a commuter trip from the current residential location to the current workplace location. It was made clear that the purpose was to establish each respondentโ€™s coping strategies under these circumstances.

A mode choice SP experiment Australia (II)

Page 22: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 22

The set of attributes and their levels

(Hensher et al, 2005)

Table 9.4. The set of attributes and attribute levels in the mode-choice experimentAll cost items are in Australian $, all time items are in minutes

short (<30 mins.) car no toll car toll rd public transport bus train busway light rail

Travel time to work 15, 20, 25 10, 12, 15 Total time in the vehicle (one-way) 10, 15, 20 10, 15, 20 10, 15, 20 10, 15, 20Pay toll if you leave at this

time (otherwise free)None 6โ€“10, 6:30โ€“8:30,

6:30โ€“9Frequency of service Every 5, 15, 25 Every 5, 15, 25 Every 5, 15, 25 Every 5, 15, 25

Toll (one-way) None 1, 1.5, 2 Time from home to closest stop Walk 5, 15, 25 Walk 5, 15, 25 Walk 5, 15, 25 Walk 5, 15, 25Fuel cost (per day) 3, 4, 5 1, 2, 3 Time to destination from closest stop Walk 5, 15, 25 Walk 5, 15, 25 Walk 5, 15, 25 Walk 5, 15, 25Parking cost (per day) Free, $10, 20 Free, $10, 20 Return fare 1, 3, 5 1, 3, 5 1, 3, 5 1, 3, 5Time variability 0, ยฑ4, ยฑ6 0,ยฑ1,ยฑ2

medium (30โ€“45 mins.) car no toll car toll rd public transport bus train busway light rail

Travel time to work 30, 37, 45 20, 25, 30 Total time in the vehicle (one-way) 20, 25, 30 20, 25, 30 20, 25, 30 20, 25, 30Pay toll if you leave

at this time (otherwisefree)

None 6โ€“10, 6:30โ€“8:30,6:30โ€“9

Frequency of service Walk 5, 15, 25 Walk 5, 15, 25 Walk 5, 15, 25 Walk 5, 15, 25

Toll (one-way) None 2, 3, 4 Time from home to closest stop Walk 5, 15, 25 Walk 5, 15, 25 Walk 5, 15, 25 Walk 5, 15, 25Fuel cost (per day) 6, 8, 10 2, 4, 6 Time to destination from closest stop Walk 5, 15, 25

Bus 4, 6, 8Walk 5, 15, 25Bus 4, 6, 8

Walk 5, 15, 25Bus 4, 6, 8

Walk 5, 15, 25Bus 4, 6, 8

Parking cost (per day) Free, $10, 20 Free, $10, 20 Return fare 2, 4, 6 2, 4, 6 2, 4, 6 2, 4, 6Time variability 0, ยฑ7, ยฑ11 0, ยฑ2, ยฑ4

long (>45 mins.) car no toll car toll rd public transport bus train busway light rail

Travel time to work 45, 55, 70 30, 37, 45 Total time in the vehicle (one-way) 30, 35, 40 30, 35, 40 30, 35, 40 30, 35, 40Pay toll if you leave

at this time (otherwisefree)

None 6โ€“10, 6:30โ€“8:30,6:30โ€“9

Frequency of service Walk 5, 15, 25 Walk 5, 15, 25 Walk 5, 15, 25 Walk 5, 15, 25

Toll (one-way) None 3, 4.5, 6 Time from home to closest stop Walk 5, 15, 25 Walk 5, 15, 25 Walk 5, 15, 25 Walk 5, 15, 25Fuel cost (per day) 9, 12, 15 3, 6, 9 Time to destination from closest stop Walk 5, 15, 25

Bus 4, 6, 8Walk 5, 15, 25Bus 4, 6, 8

Walk 5, 15, 25Bus 4, 6, 8

Walk 5, 15, 25Bus 4, 6, 8

Parking cost (per day) Free, $10, 20 Free, $10, 20 Return fare 3, 5, 7 3, 5, 7 3, 5, 7 3, 5, 7Time variability 0, ยฑ11, ยฑ17 0, ยฑ7, ยฑ11

Page 23: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 23

Stated preference databaseq We will use this data in the next session to use Nested Logit models.

(โ€ฆ)

(โ€ฆ)

Page 24: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 24

The Hausman IIA Test of the IIA hypothesis (I)

Page 25: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 25

The Hausman IIA Test of the IIA hypothesis (II)

Page 26: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 26

The Hausman IIA Test of the IIA hypothesis (III)

Page 27: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 27

The Hausman IIA Test of the IIA hypothesis (IV)

Page 28: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 28

The Hausman IIA Test of the IIA hypothesis (V)

Page 29: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 29

The Hausman IIA Test of the IIA hypothesis (VI)

Page 30: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 30

The Hausman IIA Test of the IIA hypothesis (VII)

Page 31: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 31

The Hausman IIA Test of the IIA hypothesis (VIII)

Page 32: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 32

The Hausman IIA Test of the IIA hypothesis (IX)

Page 33: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 33

The Hausman IIA Test of the IIA hypothesis (X)

Page 34: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 34

The Hausman IIA Test of the IIA hypothesis (XI)

Page 35: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 35

The Hausman IIA Test of the IIA hypothesis (XII)

.026792

Page 36: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 36

q The decision regarding the shape of the nested structure is the analyst choice. We first start with a structure which has proved many times to be significant:

Applying the Nested Logit Structure to the SP data experiment

q In this perspective we are saying that both car options are correlated in their error components, that is, all the attributes that we are forgetting in the systematic part of utility may be correlated in that branch.

q We are proposing the same for the public transport branch.

Page 37: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 37

First NL model (I)

q The menu to run a Nested Model in Nlogit: Model -> Discrete Choice -> Nested Logit.

q In the first screen you do exactly the same as you did for the MNLโ€™s.

Page 38: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 38

First NL model (II)

Utility Functions

The tree

It does not allow to specify RU1 or RU2. By default it will use RU1: normalization in the Level 1 alternatives!

Page 39: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 39

First NL model (III)

Marginal probabilities: The probabilities of each of the four alternatives in each comparison (sum=1)

Conditional probability: The probabilities for each alternative given that they are inside each branch

The IV values of each branch

The Utility of each alternative

Page 40: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 40

NLOGIT;lhs = choice, cset, altij;choices = cart, carnt, bus, train, busway, LR;tree = car(cart, carnt), PT(bus, train, busway, LR);RU1;start = logit;ivset: (car)=[1.0];maxit = 100;Prob=MARGPROB;cprob=ALTPROB;ivb=IVBRANCH;Utility=U1;model:U(cart) = asccart + fuel*fuel /U(carnt) = asccarnt + fuel*fuel /U(bus) = ascbus + fare*fare /U(train) = asctn + fare*fare /U(busway) = ascbusw + fare*fare /U(LR) = fare*fare;Crosstab$

First NL model (IV)

Begins by running an MNL for having initial values for estimating the parameters.

IV parameter normalization: the IV parameter will be 1 which normalizes the scale of the car branch to 1.

We choose to normalize the IV parameter of the car branch because it has the highest scale.

Branch1(alt1, alt2),Branch2(alt3, (โ€ฆ))

Page 41: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 41

q Nlogit will start by calibrating an MNL to generate initial coefficients for the iterative calibration.

q It gives exactly the same results as if you run an MNL with those 6 alternatives.

First NL model (V)

Page 42: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 42

First NL model (VI)

q Then the output shows the results for the Nested structure that we want to fit.

q The pseudo R-Squared with no information base model is presented immediately.

q In Nested Logits we will use only this, because a model with just the alternative specific constants in nests is not the same as in an MNL.

๐‘ƒ๐‘ ๐‘’๐‘ข๐‘‘๐‘œ๐‘…2 = 1 โˆ’๐ฟ(โˆ—)๐ฟ(0) =

1 โˆ’ 2โˆ’4768.225โˆ’6324.968

; = 0.2437

Page 43: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 43

First NL model (VII)IV(Car) normalizationIV(PT) = 0.01986

qWe canโ€™t reject the hypothesis that the IVPT is zero.

qThere is too much correlation between the alternatives in the PT branch. Huge common variance.

Page 44: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 44

q You may proceed with several Wald tests to the data.

q The first test is exactly the same as the output test from the previous slide, we are testing the hypothesis of the coefficient being zero.

q The second one is about testing the hypothesis that the IVPT is 1, which would mean equal scales, (equal variances) between both levels thus pointing to an MNL.

First NL model (IX)

We reject with great certainty the hypothesis that the coefficient may be 1, an MNL is definitely not advisable! Hence we should search for a new structure of the NL.

Page 45: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 45

Second Nested Model (I)

q We are not yet satisfied with the Nested Model we have just tested.

q A second alternative model can be having three branches. We may study the following structure:

Existing PT New PT

Page 46: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 46

NLOGIT;lhs = choice, cset, altij;choices = cart, carnt, bus, train, busway, LR;tree = car(cart, carnt), PTEX(bus, train),PTNW (busway, LR);RU1;start = logit;ivset: (car)=[1.0];maxit = 100;Prob=MARGPROB;cprob=ALTPROB;ivb=IVBRANCH;Utility=U1;model:U(cart) = asccart + fuel*fuel /U(carnt) = asccarnt + fuel*fuel /U(bus) = ascbus + fare*fare /U(train) = asctn + fare*fare /U(busway) = ascbusw + fare*fare /U(LR) = fare*fare;Crosstab$

Second Nested Model (II)

Page 47: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 47

Second Nested Model (III)

q The initial MNL model is the same

q Notice that we havenโ€™t been worrying much about the significance of the variables, looking mainly at the model structure.

q Coefficient of variable ASCTN is irrelevant for now.

Page 48: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 48

Second Nested Model (IV)

q Model has improved against a model with equal shares (no information)

Page 49: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 49

Second Nested Model (V)

qThe IV parameters are in the expected interval, neither 0 nor 1, meaning that the branches that we defined are significant for the data we are analyzing and for the Utility functions which we have proposed.

Page 50: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 50

CART CARNT BUS TRAIN BUSWAY LR TotalCART 182 195 97 91 122 111 798CARNT 187 214 96 105 119 118 838BUS 94 97 126 49 62 0 428TRAIN 95 97 51 126 0 58 428BUSWAY 125 117 58 0 184 84 569LR 115 118 0 58 82 154 526Total 798 838 428 428 570 525 3587

%๐ถ๐‘œ๐‘Ÿ๐‘Ÿ๐‘’๐‘๐‘ก๐‘ƒ๐‘Ÿ๐‘’๐‘‘๐‘–๐‘๐‘ก๐‘–๐‘œ๐‘›๐‘  =9863587 = 27.48%

Second Nested Model (VI)

CART CARNT BUS TRAIN BUSWAY LR Total

CART 183 195 97 91 122 111 798

CARNT 186 213 97 105 119 118 838

BUS 92 96 125 54 61 0 428

TRAIN 95 97 55 125 0 57 428

BUSWAY 126 118 54 0 183 88 569

LR 116 119 0 54 85 153 526

Total 798 838 428 428 569 526 3587

%๐ถ๐‘œ๐‘Ÿ๐‘Ÿ๐‘’๐‘๐‘ก๐‘ƒ๐‘Ÿ๐‘’๐‘‘๐‘–๐‘๐‘ก๐‘–๐‘œ๐‘›๐‘  =9823587 = 27.37%

q NL Three branches

q MNL model

No great difference!

Page 51: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 51

Specifying utility functions at higher levels of the NL tree (I)

q Up to now we have only specified the utility functions at level 1, the level of the alternatives. But what if there are variables which better explain the choice between the branches (level 2) and not the conditional probabilities (probability in each nest)?

q The nested Logit model allows to specify these utility functions. Letโ€™s consider the same Nested Logit structure of the current example, but letโ€™s now include as explanatory variables on the option to use Car the number of licensed drivers at the home of the respondent and the number of vehicles available. Intuitively these should motivate the choice for driving in either tolled or non tolled roads.

Page 52: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 52

Specifying utility functions at higher levels of the NL tree (II)NLOGIT

;lhs = choice, cset, altij;choices = cart, carnt, bus, train, busway, LR;tree = car(cart, carnt), PTEX(bus, train),PTNW (busway, LR);RU1;start = logit;ivset: (car)=[1.0];maxit = 100;Prob=MARGPROB;cprob=ALTPROB;ivb=IVBRANCH;Utility=U1;model:U(Car)=ndrivlic*ndrivlic+numbvehs*numbvehs/U(ptex)=asptex/U(cart) = asccart + fuel*fuel /U(carnt) = asccarnt + fuel*fuel /U(bus) = ascbus + fare*fare /U(train) = asctn + fare*fare /U(busway) = ascbusw + fare*fare /U(LR) = fare*fare;Crosstab$

qThis is off course something that only a Nested Logit can do.

Page 53: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 53

As there are more members of the household with a driverโ€™s license there is more competition for using the vehicle

The presence of more vehicles increases the probability of using the automobile

Pseudo-R2 has increased (using a null base model/equal shares model as reference)

Specifying utility functions at higher levels of the NL tree (III)

Page 54: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 54

q The two IV parameters are statistically different from 1 and from 0 (previous table)

Specifying utility functions at higher levels of the NL tree (IV)

Page 55: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 55

CART CARNT BUS TRAIN BUSWAY LR Total

CART 193 204 94 87 115 105 798

CARNT 196 222 91 98 117 114 838

BUS 87 91 132 55 64 0 428

TRAIN 91 94 55 129 0 60 428

BUSWAY 123 114 59 0 185 88 569

LR 109 113 0 57 88 159 526

Total 798 838 431 425 569 526 3587

%๐ถ๐‘œ๐‘Ÿ๐‘Ÿ๐‘’๐‘๐‘ก๐‘ƒ๐‘Ÿ๐‘’๐‘‘๐‘–๐‘๐‘ก๐‘–๐‘œ๐‘›๐‘  =10223587

= 28.49%

Specifying utility functions at higher levels of the NL tree (V)

q This is not to say that the model will predict everything wrong: the shares as you remember are estimated through expectancy, aggregating probabilities across individuals so every probability will contribute.

q Modeling has as much of science as it has of art. It is difficult to say you have reached the best model. This model still does not have many explanatory variables.

Page 56: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 56

Computing probabilities (I)

Marginal probabilities:

Conditional probabilities:

Branch Probabilities:

Same thing

๐‘ƒ(๐ฟ๐‘…|๐‘ƒ๐‘‡๐‘๐‘Š) =๐‘’IJ.KLLโˆ—MNOP

๐‘’IJ.KLLโˆ—MNOP + ๐‘’J.QRSSLIJ.KLLโˆ—MNOP

๐‘ƒ(๐‘ƒ๐‘‡๐‘๐‘Š) =๐‘’J.STUTVJโˆ—WXYZ[

๐‘’Qโˆ—W\]^ + ๐‘’J.LSKQVRโˆ—WXY_` +๐‘’J.STUTVJโˆ—WXYZ[

=๐‘’J.STUTVJโˆ—ab(Pcd.effโˆ—g]^hiPd.jkllfcd.effโˆ—g]^h)

๐‘’Qโˆ—(IJ.KRURRโˆ—bmOnoanpiJ.LLTQqโˆ—brstoPuviwW\]^) + ๐‘’J.LSKQVRโˆ—(J.VLTSJiwWXY_` ) +๐‘’J.STUTVJโˆ—(wWXYZ[)

๐‘ƒ(๐ฟ๐‘…) = ๐‘ƒ(๐ฟ๐‘…/๐‘ƒ๐‘‡๐‘๐‘Š) โˆ— ๐‘ƒ(๐‘ƒ๐‘‡๐‘๐‘Š)

Page 57: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 57

q The marginal probability: Computing probabilities (II)

๐‘ƒ(๐ต๐‘ข๐‘ ) = ๐‘ƒ(๐ต๐‘ข๐‘ |๐‘ƒ๐‘‡) โˆ— ๐‘ƒ(๐‘ƒ๐‘‡)

marginal probability Probability of the alternative inside each branch

q Remember that in each choice the respondent had 4 alternatives, the first two were cart and carnt, the two other were Public Transport alternatives picked from 4 possible.

Utility of each alternative

cartcarnttrainLRcartcarnt

LRbusway

Page 58: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 58

q Regarding aggregation be careful because you canยดt just copy the Probability attribute to excel, it will only bring 1900 lines. You have to export the variables:

q Go to project -> Export -> Variables then Choose Excel Worksheet, give the name for your file and choose the variables you want to export: ALTIJ and MARGPROB.

Aggregating across alternatives (I)

Page 59: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 59

Aggregating across alternatives (II)

q Be aware that we are aggregating across alternatives which have been produced synthetically, thus outputting indicative shares which you should be careful on using! An advanced topic on avoiding these issues is combining RP and SP data, but we will not see that on this course.

Page 60: TDM Session MNL and NL Lab - fenix.tecnico.ulisboa.pt

Phd in Transportation / Transport Demand Modelling 60

Bibliographyq Ben-Akiva, M. and Lerman, Steven R. (1985) โ€œDiscrete Choice Analysis: Theory

and Applications to Travel Demandโ€, MIT Press.q Hensher, Rose and Greene (2005) โ€œApplied Choice Analysis: A Primerโ€

Cambridge.q Ortรบzar J. and Willumsen L. (2001) Modelling Transport. 3rd Edition. John Wiley

and Sons. West Sussex, England.

Case study data is free to be accessed from: http://www.cambridge.org/0521605776