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.

Log-uniform distribution (always positive)

Ask questions about model specifications. Ideally include a mathematical explanation of your proposed model.
Post Reply
DamienJ
Posts: 10
Joined: 08 Nov 2022, 08:57

Log-uniform distribution (always positive)

Post by DamienJ »

In a WTP-space mixed logit model, I want to test a log-uniform distribution for the price attribute '(rationale: always positive and avoid long tail of log-normal);

I have two questions (related code below)

1. Is the specification "exp(b_lambda * draws_lambda)" correct if I want a log-uniform distribution with positive numbers?
2. So far, I have assumed correlation only among non-price attributes. Is is legitimate to test the correlation between lamba and other random parameters when not all variables are normally distributed? If yes, how can I write the lambda draws to estimate a potential correlation between let say wtp_legu and lambda?


Damien

Code: Select all

apollo_draws = list(
  interDrawsType="mlhs",           
  interNDraws= 100,                   
  interUnifDraws=c("draws_lambda"),                
  interNormDraws=c("draws_work" , 
                    "draws_fodd" ,
                    "draws_legu" , 
                    "draws_engr"),    
  
  intraDrawsType="mlhs",
  intraNDraws=0,
  intraUnifDraws=c(),
  intraNormDraws=c()
)

### Create random parameters
apollo_randCoeff = function(apollo_beta, apollo_inputs){
  randcoeff = list()
  randcoeff[["wtp_work"]] = w_work + s_work * draws_work 
  randcoeff[["wtp_fodd"]] = w_fodd +  s_work_fodd * draws_work + s_fodd_fodd * draws_fodd
  randcoeff[["wtp_legu"]] = w_legu +  s_work_legu * draws_work + s_fodd_legu * draws_fodd + s_legu_legu * draws_legu
  randcoeff[["wtp_engr"]] = w_engr +   s_work_engr * draws_work + s_fodd_engr * draws_fodd + s_legu_engr * draws_legu +   s_engr_engr * raws_engr
  randcoeff[["lambda"]] = exp(b_lambda * draws_lambda) #log-uniform distribution
    
   return(randcoeff)
}
stephanehess
Site Admin
Posts: 998
Joined: 24 Apr 2020, 16:29

Re: Log-uniform distribution (always positive)

Post by stephanehess »

Hi

you're missing the offset for the uniform, so something more like

Code: Select all

randcoeff[["lambda"]] = exp(a_lambda + b_lambda * draws_lambda)
instead of

Code: Select all

randcoeff[["lambda"]] = exp(b_lambda * draws_lambda)
regarding the correlation, you could add off diagonal terms into the above calculations too, but the problem is that once you do that with the normal draws, your distribution will of course no longer be log-uniform

Stephane
--------------------------------
Stephane Hess
www.stephanehess.me.uk
DamienJ
Posts: 10
Joined: 08 Nov 2022, 08:57

Re: Log-uniform distribution (always positive)

Post by DamienJ »

Thank you for the clarification about the correlation. For the offset, I assumed that it was equal to zero, but I guess it is better to verify this!

Damien
stephanehess
Site Admin
Posts: 998
Joined: 24 Apr 2020, 16:29

Re: Log-uniform distribution (always positive)

Post by stephanehess »

If you make it zero, think about what this implies for where the exponential of the distribution will start from
--------------------------------
Stephane Hess
www.stephanehess.me.uk
DamienJ
Posts: 10
Joined: 08 Nov 2022, 08:57

Re: Log-uniform distribution (always positive)

Post by DamienJ »

Indeed, I haven't put enough thought on this, as this will make the distribution start at at 1
Thank you.
Post Reply