Important: Read this before posting to this forum

  1. This forum is for questions related to the use of Apollo. We will answer some general choice modelling questions too, where appropriate, and time permitting. We cannot answer questions about how to estimate choice models with other software packages.
  2. There is a very detailed manual for Apollo available at http://www.ApolloChoiceModelling.com/manual.html. This contains detailed descriptions of the various Apollo functions, and numerous examples are available at http://www.ApolloChoiceModelling.com/examples.html. In addition, help files are available for all functions, using e.g. ?apollo_mnl
  3. Before asking a question on the forum, users are kindly requested to follow these steps:
    1. Check that the same issue has not already been addressed in the forum - there is a search tool.
    2. Ensure that the correct syntax has been used. For any function, detailed instructions are available directly in Apollo, e.g. by using ?apollo_mnl for apollo_mnl
    3. Check the frequently asked questions section on the Apollo website, which discusses some common issues/failures. Please see http://www.apollochoicemodelling.com/faq.html
    4. Make sure that R is using the latest official release of Apollo.
  4. If the above steps do not resolve the issue, then users should follow these steps when posting a question:
    1. provide full details on the issue, including the entire code and output, including any error messages
    2. posts will not immediately appear on the forum, but will be checked by a moderator first. This may take a day or two at busy times. There is no need to submit the post multiple times.

MDCNEV

Ask questions about model specifications. Ideally include a mathematical explanation of your proposed model.
Post Reply
punyabeet
Posts: 19
Joined: 08 May 2020, 11:43

MDCNEV

Post by punyabeet »

Hi Prof Hess

Is the apollo package capable to estimate a cross-nested MDCEV model?
I tried to modify apollo_example_13.r and run the model but I get the following error :

Error in mdcnev_settings$mdcnevNests[[which(as.vector(mdcnev_settings$mdcnevStructure[, :
subscript out of bounds

These are the modifications I did in the code:

Fragment 1
### Vector of parameters, including any that are kept fixed in estimation
apollo_beta = c(alpha_base = 0,
gamma_work = 1,
gamma_school = 1,
gamma_shopping = 1,
gamma_private = 1,
gamma_leisure = 1,
delta_work = 0,
delta_school = 0,
delta_shopping = 0,
delta_private = 0,
delta_leisure = 0,
delta_work_FT = 0,
delta_work_wknd = 0,
delta_school_young = 0,
delta_leisure_wknd = 0,
theta_subsistence = 0.9,
theta_nonwork = 0.9,
theta_other = 0.9,
alpha0_shopping_subsistence = 0,
alpha0_shopping_nonwork = 0)

### Vector with names (in quotes) of parameters to be kept fixed at their starting value
apollo_fixed = c("theta_other", "alpha0_shopping_nonwork")

Fragment 2
### Define nesting structure
mdcnevNests = list(subsistence = theta_subsistence,
nonwork = theta_nonwork,
other = theta_other)

### Specify nest allocation parameters for alternatives included in multiple nests
alpha_shopping_subsistence = exp(alpha0_shopping_subsistence)/(exp(alpha0_shopping_subsistence) + exp(alpha0_shopping_nonwork))
alpha_shopping_nonwork = 1 - alpha_shopping_subsistence

mdcnevStructure = matrix(0, nrow=length(mdcnevNests), ncol=length(V))
### outside work school shopping private leisure
mdcnevStructure[1,] = c( 0, 1, 1, alpha_shopping_subsistence, 0, 0) # subsistence
mdcnevStructure[2,] = c( 0, 0, 0, alpha_shopping_nonwork, 0, 1) # nonwork
mdcnevStructure[3,] = c( 1, 0, 0, 0, 1, 0) # other
stephanehess
Site Admin
Posts: 974
Joined: 24 Apr 2020, 16:29

Re: MDCNEV

Post by stephanehess »

Hi

the MDCNEV model assumes that each alternative falls into exactly one nest.

We will improve the error message that you're getting, but all the columns in mdcnevStructure need to only include 0/1 values, and sum to 1 across rows

Stephane
--------------------------------
Stephane Hess
www.stephanehess.me.uk
punyabeet
Posts: 19
Joined: 08 May 2020, 11:43

Re: MDCNEV

Post by punyabeet »

Thanks, Prof Hess for the clarification.
Post Reply