Simulation for an ordered hybrid choice model

19 views
Skip to first unread message

Hafsoah Ahmad

unread,
Mar 12, 2025, 3:14:50 AMMar 12
to Biogeme
Dear Professor Bierlaire,

I am trying to simulate a hybrid choice model with a single ordered choice variable.
After estimating the model, I tried the following code to simulate the choices: 

----------------
PROB = MonteCarlo(Elem(the_prob, Choice))
simulate = {'PROB': PROB}
the_biogeme = bio.BIOGEME(database, simulate)
the_biogeme.modelName = "model6.1"
betas = the_biogeme.freeBetaNames
results = res.bioResults(pickleFile='Model_6.pickle')
betaValues=results.getBetaValues()
simulatedValues = the_biogeme.simulate(betaValues)



This is the error I got:

TypeError                                 Traceback (most recent call last)
<ipython-input-149-ca44dd1e3edf> in <cell line: 0>()
----> 1 simulatedValues = the_biogeme.simulate(betaValues)

/usr/local/lib/python3.11/dist-packages/biogeme/biogeme.py in simulate(self, theBetaValues)
   1623                 raise excep.BiogemeError('\n'.join(listOfErrors))
   1624
-> 1625         result = self.theC.simulateSeveralFormulas(
   1626             formulas_signature,
   1627             betaValues,

src/cythonbiogeme/cpp/cythonbiogeme.pyx in cythonbiogeme.cythonbiogeme.pyBiogeme.simulateSeveralFormulas()

TypeError: simulateSeveralFormulas() takes exactly 6 positional arguments (5 given)




I got the same error when I tried to validate the model.


validation_data = database.split(slices=5)
validation_results = the_biogeme.validate(results, validation_data)
for slide in validation_results:
    print(
        f'Log likelihood for {slide.shape[0]} validation data: '
        f'{slide["Loglikelihood"].sum()}'
    )
TypeError                                 Traceback (most recent call last)
<ipython-input-190-688ad2f46bfc> in <cell line: 0>()
----> 1 validation_results = the_biogeme.validate(results, validation_data)
      2 for slide in validation_results:
      3     print(
      4         f'Log likelihood for {slide.shape[0]} validation data: '
      5         f'{slide["Loglikelihood"].sum()}'

________________________________________
1 frames
________________________________________
/usr/local/lib/python3.11/dist-packages/biogeme/biogeme.py in simulate(self, theBetaValues)
   1623                 raise excep.BiogemeError('\n'.join(listOfErrors))
   1624
-> 1625         result = self.theC.simulateSeveralFormulas(
   1626             formulas_signature,
   1627             betaValues,

src/cythonbiogeme/cpp/cythonbiogeme.pyx in cythonbiogeme.cythonbiogeme.pyBiogeme.simulateSeveralFormulas()

TypeError: simulateSeveralFormulas() takes exactly 6 positional arguments (5 given)

Kindly suggest how to proceed. Looking forward to your reply. Thank you.

Regards,
Hafsoah

CONFIDENTIALITY NOTICE: The contents of this email message and any attachments are intended solely for the addressee(s) and may contain confidential and/or privileged information and may be legally protected from disclosure. If you are not the intended recipient of this message or their agent, or if this message has been addressed to you in error, please immediately alert the sender by reply email and then delete this message and any attachments. If you are not the intended recipient, you are hereby notified that any use, dissemination, copying, or storage of this message or its attachments is strictly prohibited.
Reply all
Reply to author
Forward
0 new messages