Page 1 of 1

Three-levels NL model, utility equation

Posted: 09 Dec 2023, 13:29
by kkkkk
Dear authors,

I am applying nested-logit model recently and have read the examples on your website. http://www.apollochoicemodelling.com/fi ... e_levels.r

The example is quite clear. But I don't know how to write the code if I want to add utilities specific to nests, which is named Wnk in the chapter of DISCRETE CHOICE METHODS WITH SIMULATION:
4.2.3. Decomposition into Two
Logits Expression (4.2) is not very illuminating as a formula. However, the choice probabilities can be expressed in an alternative fashion that is quite simple and readily interpretable. Without loss of generality, the observed component of utility can be decomposed into two parts: (1) a part labeled W that is constant for all alternatives within a nest, and (2) a part labeled Y that varies over alternatives within a nest. Utility is written as
(4.3) Unj = Wnk + Ynj + εnj
for j ∈ Bk, where:
Wnk depends only on variables that describe nest k. These variables differ over nests but not over alternatives within each nest.
Ynj depends on variables that describe alternative j. These variables vary over alternatives within nest k.
To speak specifically, suppose a variable pa, referring to "the Parking accessibility in the neighborhood" . pa influences choice between nest "car"(a degenerate nest) and "PT". Then how to write the utility equation with the nest specific utility( 𝛽 * pa ) ?

Here is the code in your example, with no nest specific utility.

Code: Select all

### List of utilities: these must use the same names as in nl_settings, order is irrelevant
  V = list()
  V[["car"]]  = asc_car        + b_tt_car_value  * time_car                           + b_cost_value * cost_car
  V[["bus"]]  = asc_bus_value  + b_tt_bus_value  * time_bus  + b_access * access_bus  + b_cost_value * cost_bus 
  V[["air"]]  = asc_air_value  + b_tt_air_value  * time_air  + b_access * access_air  + b_cost_value * cost_air   + b_no_frills * ( service_air == 1 )  + b_wifi * ( service_air == 2 )  + b_food * ( service_air == 3 )
  V[["rail"]] = asc_rail_value + b_tt_rail_value * time_rail + b_access * access_rail + b_cost_value * cost_rail  + b_no_frills * ( service_rail == 1 ) + b_wifi * ( service_rail == 2 ) + b_food * ( service_rail == 3 )
  
  ### Specify nests for NL model
  nlNests      = list(root=1, PT=lambda_PT, fastPT=lambda_fastPT)
  
  ### Specify tree structure for NL model
  nlStructure= list()
  nlStructure[["root"]]   = c("car","PT")
  nlStructure[["PT"]]     = c("bus","fastPT")
  nlStructure[["fastPT"]] = c("air","rail")
I will be very grateful if you can help with this question.

Best regards,

Kathy

Re: Three-levels NL model, utility equation

Posted: 19 Jan 2024, 01:13
by stephanehess
Kathy

apologies for the slow reply, David and I have been away.

There is no specific provision in Apollo for nest-specific utilities, but you can add those parts into the utilities for each of the alternatives in the nest

Stephane