My first choice model with PandasBiogeme 3.2.6

preview_player
Показать описание
The video walks you through the specification and estimation of a simple choice model with the Python package PandasBiogeme
Рекомендации по теме
Комментарии
Автор

Thank you for adding the subtitle, and now I know better about some details which I missed in the first time watching.

ouyangsicong
Автор

Thank you so much for the explanation :)

mahnazbp
Автор

Hello Professor, thank you for the videos. I have two questions.
1) In my database, some alternatives are not available for everyone. Ex: Car is available only for car-owning people. In that case, how should I write the script?
2) How to include individual-specific variables such as socio-economics variables?

dilinikariyawasam
Автор

Hello professor,

I'm trying to apply this algorithm to my set of data, the alternatives are CAR, TRAIN and BUS, I have both travel time and travel cost for each one of them.

In the section "Parameters to be estimated" why did you considered the Swissmetro (ASC_SM) to be considered zero and not modified by Biogeme?
Does this means something like: the other Alternative Specific Constants will be calculated with reference to the ASC_SM?

I have this question because I don't know what would make sense in my case to tell Biogeme to not modify. Can you help me please?

Best regards

pedrodavidgomes
Автор

Thank you so much for the explanation! I have another question though:

In my DCE, I don't use ASC because I have a generic model, which means that I don't have to set a fixed value for any other parameter, right?
A_INV and A2_INV are the investment costs and A_OPE and A2_OPE are the operating costs with continuous numerical values. However, A_FRE, A2_FRE and A_REC, A2_REC have binary values with a value of 1 meaning that this alternative is recommended by either a FRIEND or through your own RESEARCH or 0 otherwise.
Can I use this model that combines continuous and binary input data without the need to set a value of a parameter to 0? Or do you see any errors?

# Parameters to be estimated
B_INV = Beta('B_INVES', 0, None, None, 0)
B_OPE = Beta('B_OPERA', 0, None, None, 0)
B_FRE = Beta('B_FRIEND', 0, None, None, 0)
B_REC = Beta('B_RESEARCH', 0, None, None, 0)

# Definition of new variables
A_INV_SCALED = A_INV / 1000
A_OPE_SCALED = A_OPE / 1000
A2_INV_SCALED = A2_INV / 1000
A2_OPE_SCALED = A2_OPE / 1000

# Definition of the utility functions
V1 = B_INV * A_INV_SCALED + B_OPE * A_OPE_SCALED + B_FRE * A_FRE + B_REC * A_REC
V2 = B_INV * A2_INV_SCALED + B_OPE * A2_OPE_SCALED + B_FRE * A2_FRE + B_REC * A2_REC

Or do I have to set one of the parameters for the binary data (B_FRE or B_REC) to 0 to compare it with the other parameter? Thank you for your time!

kenneth
Автор

Thank you for your clear explanations, But how could I handle situations where the independent variables are categorical using the Biogeme package?

abiytefera
Автор

Dear professor Michel, why am I unable to get the output for my model correct?Any help is greatly appreciated.Please see my code snippet.
The model syntax

# Import necessary libraries
import pandas as pd
import biogeme.biogeme as bio
from biogeme.expressions import Beta
import numpy as np
import biogeme.models as models
import biogeme.database as db
import biogeme.version as ver

# Load and reshape the dataset
df =

# Create a Biogeme database
database = db.Database('My_file', df)


## Parameters to be estimated
ASC_1 = Beta('ASC_1', 0, None, None, 0)
ASC_2 = Beta('ASC_2', 0, None, None, 0)
ASC_3 = Beta('ASC_3', 0, None, None, 1)
B_Wsup = Beta('B_Wsup', 0, -10000, 10000, 0)
B_Wqua = Beta('B_Wqua', 0, -10000, 10000, 0)
B_Price = Beta('B_Price', 0, -10000, 10000, 0)

Specification of utility functions(the choice design is generic/unlabelled and hence ASC_1 and ASC_2 are expected to be similar or same, also ASC_3 corresponds to the third alternative which is the status quo in the choice alternatives).Also tried without lower and upper bound setting or setting equal to 0(zero) but the result didn't change.
V1 = ASC_1 +\
B_Wsup*Wsup+\
B_Wqua*Wqua+\
B_Price*Price
V2 = ASC_2 +\
B_Wsup*Wsup+\
B_Wqua*Wqua+\
B_Price*Price
V3 = ASC_3 +\
B_Wsup*Wsup+\
B_Wqua*Wqua+\
B_Price*Price

Association of alternatives with the utility functions
V = {1:V1,
2:V2,
3:V3}
Associate the availability conditions with the alternatives (in the dataframe Concept column is for availability ie Concept =1 for alternative 1, Concept = 2, for alternative 2 and Concept = 3 for the alternative 3, which is the status quo)
av = {1: database.variables['Concept'] == 1,
2: database.variables['Concept'] == 2,
3: database.variables['Concept'] == 3}

define the contribution to the loglikelihood of each observation (Chosen =1 if alternative 1 is chosen, =2 if alternative 2 is chosen and =3 if alternative 3 is chosen)

logprob = models.loglogit(V, av, Chosen)

Biogeme
biogeme = bio.BIOGEME(database, logprob)
biogeme.modelName = '01logit'

Running the estimation
results = biogeme.estimate()

Get the result
pandasResults =
pandasResults

Value Rob. Std err Rob. t-test Rob. p-value





MM_ist
Автор

Can you show us an example of estimating path-size logit model for route choice using Biogeme package? I know we have to calculate the path-size factor first. Is there any way Biogeme can calculate ps factors between the alternatives? Thank you.

asadtanvir
Автор

Hello professor, thank you for the videos!
I tried to use this algorithm to calculate the utility functions of a set of data that I gathered through a survey.
The code runs with no issues but all the estimated parameters (ASC_CAR, ASC_TRAIN, B_TIME and B_COST) turned out to be zero
The only thing I did was changing the database, do you think there might be something wrong with my data that leads to this results?
Best regards!

pedrodavidgomes