Page 1 of 1

Models with reaction time

Posted: 27 May 2020, 14:44
by silvia
Dear Stephane,

I would like to implement a driver behaviour model including the estimation of the reaction time component as in Paschalidis, Choudhury, and Hess (2019).
https://doi.org/10.1016/j.amar.2019.02.001
Can Apollo directly account for the impact of explanatory variables including a stochastic reaction time?

Thank you in advance.

Kind regards,
Silvia

Re: Models with reaction time

Posted: 27 May 2020, 23:18
by stephanehess
Hi Silvia

this is a very specific application of a model. You could definitely code the model in Apollo but this would involve some manual coding of the model components and then using Apollo for the estimation

Best wishes

Stephane

Re: Models with reaction time

Posted: 28 May 2020, 07:53
by silvia
Dear Stephane,

Thank you very much.
Yes, I understand how to combine different model components (e.g., choice model and reaction time distribution) in the likelihood function.
It is not clear to me how to include explanatory variables that vary based on a stochastic reaction time in the choice model.
Is there a way to directly code it in Apollo or do I need the pre-process the data?

Kind regards,
Silvia

Re: Models with reaction time

Posted: 28 May 2020, 08:48
by stephanehess
Hi Silvia

if an attribute is stochastic, whether as a function of reaction time or some other phenomenon, then you can code it in apollo_randCoeff - it makes no difference whether the components included in that list are random coefficients or random variables

Best wishes

Stephane

Re: Models with reaction time

Posted: 06 Jun 2020, 16:19
by vagg_pi
Hi Silvia,

I estimated this model using numerical integration and a previous version of the Choice Modelling Centre code. I haven’t tried this in Apollo yet but with some tweaking it should be feasible to use Gauss-Legendre also here.

- So as a first step, in the “apollo_draws” I created in advance every random element I would need later. This included nodes, weights, lagged relative speed and every other lagged component I would need. I created these as uniform. It doesn’t really matter as I just used this only to have the format of the matrices and I later pasted the values I actually needed (see last step later)

- I created the nodes and weights for integration using the ‘pracma’ package

- In the previous process I also edited the nodes to have the range I needed, I assume 0-3 or 0-4 in your case, or something similar

- After creating the draws (and before running the function of the model – apollo_probabilities) I called the matrix of reaction time values and did some processing to calculate lagged values of speed, headway etc.

- The approach to do the step above is up to you. I used interpolation and kinematics, but you can really use any approach you think is the best. The matrices that include these values are outside the list of draws currently

- Now that you have the matrices of the lagged variables, you need to use them to replace the initial draws you had from first step, and incorporate them in the list of your draws

That’s it pretty much. Please keep in mind that when mixed effects are included, Apollo is using the apollo_avgInterDraws function to calculate the average probability. You need to multiply this by number_of_draws*(b-a)/2 as the formula of Gauss-Legendre is a weighted sum and not an average.

Also, the approach above only works for a unidimensional integral. For instance, if you also want to have random space headway for free flow, some further processing will be needed. Unfortunately, I have not tried this yet.

I hope this made things a bit clearer, I’m happy to help if you have further questions.

Best,
Evangelos