If you have aggregate data, you need to multiply the contribution to the loglikelihood for each alternative by the number of times it is chosen.
logprob = nbr_alt_1 * bioLogLogit(V,av,1) + nbr_alt_2 * bioLogLogit(V,av,2) + … + nbr_alt_J * bioLogLogit(V,av,J)
> On 14 Jun 2022, at 13:40, Fani Hatziioannidu <
fhatzii...@gmail.com> wrote:
>
> Dear Modellers, dear Professor,
>
> I kindly ask for your advice to adjust the mode choice model in Biogeme
> with choice frequencies from RP data (more accurately from GPS average day values per origin-destination OD pair) eg,
> car 5.2, public transport 3.1, bike 2.3 (3 columns per OD)
> instead of individual choices 1,2,3 (1 column)
>
> First I would like to ask if using biogeme for a case like this is suitable and if it has been successfully used in similar cases for mode choice forecasts.
> I have a large dataset with almost 1mio OD pairs and corresponding records.
> I am using python biogeme (unfortunately I couldn't learn how to code in Panda biogeme)
>
> my draft code is like this (but I understand that there is a mistake in the logprob = bioLogLogit(V,av,CHOICE as this expects individual choices 1,2,3 instead of frequencies)
>
> ASC1 = Beta('ASC1',0,-10,10,0)
> B_CAR_TT0 = Beta('B_CAR_TT0',0,-10,10,0)
> B_PUT_PJT = Beta('B_PUT_PJT',0,-10,10,0)
> B_BIKE_TT0 = Beta('B_BIKE_TT0',0,-10,10,0)
> B_CAR_DIS = Beta('B_CAR_DIS',0,-10,10,0)
> B_PUT_SFQ = Beta('B_PUT_SFQ',0,-10,10,0)
> B_BIKE_DIS = Beta('B_BIKE_DIS',0,-10,10,0)
>
> # Definition of the utility functions
> CAR_TRIPS = B_CAR_TT0 * CAR_TT0 + B_CAR_DIS * CAR_DIS
> PUT_TRIPS = B_PUT_PJT * PUT_PJT + B_PUT_SFQ * PUT_SFQ
> BIKE_TRIPS = ASC1 + B_BIKE_TT0 * BIKE_TT0 + B_BIKE_DIS * BIKE_DIS
>
> # Associate utility functions with the numbering of alternatives
> V = {1: CAR_TRIPS,
> 2: PUT_TRIPS,
> 3: BIKE_TRIPS}
>
> # Associate the availability conditions with the alternatives
> av = {1: CAR_TRIPS,
> 2: PUT_TRIPS,
> 3: BIKE_TRIPS}
>
> # The choice model is a logit, with availability conditions
> logprob = bioLogLogit(V,av,CHOICE)
>
> # Defines an itertor on the data
> rowIterator('obsIter')
>
> # Define the log likelihood function for the estimation
> BIOGEME_OBJECT.ESTIMATE = Sum(logprob,'obsIter')
>
> Looking forward to your response and thank you in advance/
>
> kind regards,
> Fani Hatziioannidu
>
>