Page 1 of 1

Cross-nested specification

Posted: 18 Feb 2021, 12:58
by jbas
Hi,

I'm finding trouble in estimating a CNL specification that is slighlty different than that shown in the examples.
In Apollo_example_6.r, as the manual explains, there are three nests; One for air and rail, One of Bus and Rail, and one in which Car is all alone. Since car is on its own, the nesting parameter for the car nest is set to 1.

Well, my nesting structure is different, I have four alternatives: Car, Bike, Walk, Other; and I'd like to put in nest1 Car and Other, while in nest2 Bike, Walk, and Other. For that, I wrote:

Code: Select all

 ### Specify nests for CNL model
  cnlNests = list(motor=lambda_motor, nomotor=lambda_nomotor) 

  ### Specify nest allocation parameters for alternatives included in multiple nests
  alpha_other_motor   = exp(alpha0_other_motor)/(exp(alpha0_other_motor) + exp(alpha0_other_nomotor))
  alpha_other_nomotor = 1 - alpha_other_motor
  
  
  ### Specify tree structure, showing membership in nests (one row per nest, one column per alternative)
  cnlStructure      = matrix(0, nrow=length(cnlNests), ncol=length(V))
  cnlStructure[1,] = c( 0,  0, 1, alpha_other_motor  ) 
  cnlStructure[2,] = c( 1,  0, 0, alpha_other_nomotor) 
  
  
  ### Define settings for NL model
  cnl_settings <- list(
    alternatives = c(car=1, bike=2, walk=3, other=4),
    avail        = list(car=av_car, bike=av_bike, walk=av_walk, other=av_other),
    choiceVar    = CHOICE,
    V            = V,
    cnlNests      = cnlNests,
    cnlStructure  = cnlStructure
  )
  
Note that I have changed three things with respect to the example:
- I removed 'car=1' in cnlNests, and not replaced with any other alternative since there is no nest with one only alternative
- Removed cnlStructure[2] since there is no third nest
- Switch the '1' in cnlStructure[2,] from the second to the first position.

Is this structure correct? When I code it like this, apollo_estimates throws the error:
Error in apollo_estimate(apollo_beta, apollo_fixed, apollo_probabilities, : Log-likelihood calculation fails at values close to the starting values!.
However, no matter the starting values, it always gives that error. That's why I thought the problem is in the nesting structure.

Thanks for your help.

J.

Re: Cross-nested specification

Posted: 21 Feb 2021, 21:11
by stephanehess
Hi

in your model, you are not including bike in any nest as the second column in cnlStructure is just 0.

Apollo should give a different error message here, and we will fix that

Stephane