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.

parameter does not influence LL

Ask questions about errors you encouunter. Please make sure to include full details about your model specifications, and ideally your model file.
shengxiao
Posts: 8
Joined: 07 May 2021, 14:23

Re: parameter does not influence LL

Post by shengxiao »

Hi Stephane,
I am still confused at how to specify the functions in Apollo. I am testing what factors are related to a combination of residential location and vehicle ownership. This is the reason why I include the same parameters for each alternative. For example, I assume that the age is related to the probability of living in an urban area with a car and also related to that of living in a suburb without a car. Therefore, I would like to include all categories of age for each alternative. I understand that at least there should be some differences of the utility functions. So I have tried to include asc:

asc_Ru_N_value = asc_Ru_N+asc_Ru_N_burden*cost
asc_SEC_N_value = asc_SEC_N+asc_SEC_N_burden*cost
asc_SUB_N_value = asc_SUB_N+asc_SUB_N_burden*cost+asc_SUB_N_transit*pt
asc_URB_N_value = asc_URB_N+asc_URB_N_burden*cost+asc_URB_N_transit*pt
asc_Ru_D_value = asc_Ru_D+asc_Ru_D_burden*cost
asc_SEC_D_value =asc_SEC_D+asc_SEC_D_burden*cost
asc_URB_D_value = asc_URB_D+asc_URB_D_burden*cost+asc_URB_D_transit*pt

Unfortunately, the results are the same: Parameter b_age_65 does not influence the log-likelihood of your model! I try to use Cross-nested model because I like its relaxation on the IIA hypothesis.
In this case, I wonder what I should do. As I see on your website, I think it is fine to include the same utility function for all alternatives. So should I do b_age_65_i in stead of an uniform b_age_65 for all alternatives?

Thank you,
Alex
stephanehess
Site Admin
Posts: 974
Joined: 24 Apr 2020, 16:29

Re: parameter does not influence LL

Post by stephanehess »

Alex

it's very simple. You have the following, where I show only the first and last alternative

Code: Select all

V[['Ru_D']]  = acs_Ru_D + b_age_65 * (age_65_74==1) + b_age_75 * (age_75==1) + b_AA * (race_AA==1) + b_HIS * (race_HIS==1) + 
    b_OTHERS * (race_OTHERS==1) + b_inc * (income) + b_med*(medc==1) + b_retire_o * (retire_one==1) + 
    b_retire_t * (retire_two==1) + b_alonem * (alonem==1) + b_alonef * (alonef==1)+ b_incm * (data$incomem==1)
...
V[['URB_S']]  = acs_URB_S + b_age_65 * (age_65_74==1) + b_age_75 * (age_75==1) + b_AA * (race_AA==1) + b_HIS * (race_HIS==1) + 
    b_OTHERS * (race_OTHERS==1) + b_inc * (income) + b_med*(medc==1) + b_retire_o * (retire_one==1) + 
    b_retire_t * (retire_two==1) + b_alonem * (alonem==1) + b_alonef * (alonef==1)+ b_incm * (data$incomem==1)
You cannot estimate a constant for each alternative, as only the differences in utilities matter. So you would for example include asc_URB_S in apollo_fixed, so its value stays at 0. The estimate for acs_Ru_D would then be the difference in utility for Ru_D compared to URB_S, all else being equal.

Now, I understand you want to incorporate socio-demographic effects too. But what you have done is to include these in all of the utility functions, with the same parameters. So they would just drop out of the model as they would not capture any differences across alternatives. If you want to for example capture the impact of age being between 65 and 74, then you would need to use a separate parameter for that for each alternative, with one of them being fixed to zero. Just like for the ASCs. It's the exact same principle. So you would need e.g.

Code: Select all

V[['Ru_D']]  = acs_Ru_D + b_age_65_RU_D * (age_65_74==1) + ...
...
V[['URB_S']]  = acs_URB_S + b_age_65_URB_S * (age_65_74==1) + ...
where b_age_65_URB_S is also included in apollo_fixed

Stephane
--------------------------------
Stephane Hess
www.stephanehess.me.uk
shengxiao
Posts: 8
Joined: 07 May 2021, 14:23

Re: parameter does not influence LL

Post by shengxiao »

Hi Stephane,

It finally works. Thanks so much! But another quick question: I wonder how long does it take to run the model? I have around 80,000 samples, and 12 alternatives. It run for several days already, but did not work out. I wonder whether it is normal. If so, do you have any recommendations to make the computation less expensive?

Thank you,
Alex
stephanehess
Site Admin
Posts: 974
Joined: 24 Apr 2020, 16:29

Re: parameter does not influence LL

Post by stephanehess »

Alex

that's a big sample, but it shouldn't take that long or does your model also use mixing? What version of Apollo are you using and are you using multiple cores?

Stephane
--------------------------------
Stephane Hess
www.stephanehess.me.uk
shengxiao
Posts: 8
Joined: 07 May 2021, 14:23

Re: parameter does not influence LL

Post by shengxiao »

Hi Stephane,
Sorry about my late reply. I just want to have more information before reaching out to you. I do not think that I used mixing. The model structure is the same as your publication in Transportation in 2012 (vehicle type and fuel type). My apollo version is apollo_0.2.4. Thanks for the reminder of the number of cores. Now I have opened all cores on my computer (6), and it goes a little faster.

I can see that it should converge nearly 200 times, which makes it really slow. And it takes very long after the coverage (sometimes it cannot even converge). In this case, do you have any other suggestions? Should I reduce the number of parameters? Will that help?

Thank you,
Alex
stephanehess
Site Admin
Posts: 974
Joined: 24 Apr 2020, 16:29

Re: parameter does not influence LL

Post by stephanehess »

Alex

can you please show us the whole code and the output?

Thanks
--------------------------------
Stephane Hess
www.stephanehess.me.uk
Post Reply