Page 1 of 1
need to define utilities for categorical variables in MNL model
Posted: 05 Jun 2021, 13:57
by akash212
Hello,
I am very new to choice modeling and r coding. I am working on vehicle mode choice analysis.
I have 4 alternatives namely
1. Car
2. Walk
3. Bicycle
4. Public Transport
I have a variable called "motive" in my data set, which states the trip taken.
"motive" variable has 4 values (1=work purpose, 2=errands purpose, 3=social purpose, 4=leisure purpose). Now, I want to make use of this variable in my MNL choice model. But, I am not sure how we can define utilities for such variables.
Until now, I have used the below variables in my model. Where the "dist" variable gives the distance between 2 locations, and the "trip_duration" variables give the time taken to travel between 2 locations.
V[['walk']] = asc_walk + b_dist_w * log(dist + 1) + b_time_w * log(trip_duration+1)
V[['bicycle']] = asc_bicycle + b_dist_b * log(dist + 1) + b_time_b * log(trip_duration+1)
V[['pt']] = asc_pt + b_dist_p * log(dist + 1) + b_time_p * log(trip_duration+1)
V[['car']] = 0
Please let me know how can use the "motive" variable in the above equations.
Re: need to define utilities for categorical variables in MNL model
Posted: 06 Jun 2021, 19:26
by stephanehess
Hi
you can just use:
V[['walk']] = asc_walk + b_dist_w * log(dist + 1) + b_time_w * log(trip_duration+1) + b_work_w * (motive==1) + b_errands_w * (motive==2) + b_social_w * (motive==3)
so that leisure is the base
and then do this for all alternatives except for car which is your base
Stephane
Re: need to define utilities for categorical variables in MNL model
Posted: 06 Jun 2021, 21:25
by akash212
Thank you for the reply, Stephane.
It is working as expected.

Re: need to define utilities for categorical variables in MNL model
Posted: 15 Jun 2021, 21:45
by akash212
Hello Stephane,
I have a very general question to ask while implementing interaction of characteristics, how can we decide with the variables? Shall we check the correlation between variables and then create an interaction model with highly correlated features?
For example,
We took the interaction of characteristics between the "Business_trip" and "Income" variables in the mode choice behavior for the available choices of Car and Train.
What should be our approach while working with interaction variables?
Thanks in Advance,
Akash
Re: need to define utilities for categorical variables in MNL model
Posted: 18 Jun 2021, 11:25
by stephanehess
Hi
correlation between the variables in the data does not imply anything behavioural in terms of possible interaction effects. So what you need to do instead is consider what kind of behavioural effects might make sense, and also look at tabulating your data before model specification to see whether specific combinations are more likely to be chosen than others.
Stephane
Re: need to define utilities for categorical variables in MNL model
Posted: 18 Jun 2021, 11:51
by akash212
OKay, understood. Thank you for the answer.
Re: need to define utilities for categorical variables in MNL model
Posted: 29 Jul 2021, 19:56
by bokapatsila
akash212 wrote: 05 Jun 2021, 13:57
Hello,
I am very new to choice modeling and r coding. I am working on vehicle mode choice analysis.
I have 4 alternatives namely
1. Car
2. Walk
3. Bicycle
4. Public Transport
I have a variable called "motive" in my data set, which states the trip taken.
"motive" variable has 4 values (1=work purpose, 2=errands purpose, 3=social purpose, 4=leisure purpose). Now, I want to make use of this variable in my MNL choice model. But, I am not sure how we can define utilities for such variables.
Until now, I have used the below variables in my model. Where the "dist" variable gives the distance between 2 locations, and the "trip_duration" variables give the time taken to travel between 2 locations.
V[['walk']] = asc_walk + b_dist_w * log(dist + 1) + b_time_w * log(trip_duration+1)
V[['bicycle']] = asc_bicycle + b_dist_b * log(dist + 1) + b_time_b * log(trip_duration+1)
V[['pt']] = asc_pt + b_dist_p * log(dist + 1) + b_time_p * log(trip_duration+1)
V[['car']] = 0
Please let me know how can use the "motive" variable in the above equations.
Hi! I'm also new to choice modelling and trying to work my way through the examples. This topic seems to be relevant to my question:
What is the difference between the use of "V[['car']] = 0" as it is specified above, and "V[['car']] = asc_car + b_dist_car * log(dist + 1) + b_time_car * log(trip_duration+1) " together with setting "apollo_fixed = c("asc_car")" - something that is more common in the apollo examples? Thank you!
Re: need to define utilities for categorical variables in MNL model
Posted: 12 Aug 2021, 10:17
by stephanehess
Hi
is the same as
together with setting
But of course, this is different from
Code: Select all
V[['car']] = asc_car + b_dist_car * log(dist + 1) + b_time_car * log(trip_duration+1)
as you have other terms in the utility function.
But you can't have dist and trip_duration in all 4 utilities, as you need a normalisation.
Stephane
Re: need to define utilities for categorical variables in MNL model
Posted: 12 Aug 2021, 19:23
by bokapatsila
Thank you, Stephane!
Re: need to define utilities for categorical variables in MNL model
Posted: 13 Aug 2021, 06:41
by stellagreen
Ok I get it. thank you for the answer.