mooc-discrete-choice's People
Forkers
magick42mooc-discrete-choice's Issues
The last request for help
Hoping I get help from anyone in charge of this platform I repost my issue and any help is appreciated and the platform is really meant to bring change in using biogeme software.
Any help is greatly appreciated.
I have difficulty estimating mixed logit model based on the following
information and need help.I tried to go through the biogeme documentation
and unable to see discussion related with unlabelled format modeling using
mixed logit model.
Unlabelled format with three alternatives(1,2,3)represented with
Concept,third alternative is the status quo;Attributes are water
supply(levels 1,2,3),Water quality(two levels:1=yes,0=otherwise),and
prices(5 levels:3,5,10,15 and 20).I want to apply mixed logit with error
components and Quasi-Monte Carlo Simulation,code given below.Any help
please.
Assume you have a pandas DataFrame df
with your data
database = db.Database("myDatabase", df)
Use the names of the variables in your data
chosen_alternative = database.variables["Chosen"]
#water_supply = database.variables["Wsup"]
#water_quality = database.variables["Wqua"]
#price_increase = database.variables["Price"]
Define parameters to be estimated (betas)
#beta1 = ex.Beta('beta1', 0, None, None, 0)
#beta2 = ex.Beta('beta2', 0, None, None, 0)
#beta3 = ex.Beta('beta3', 0, None, None, 0)
#beta3_stddev = ex.Beta('beta3_stddev', 0.5, None, None, 0)
Define the alternative specific constants
ASC1 = ex.Beta('ASC1', 1, None, None, 0)
ASC2 = ex.Beta('ASC2', 1, None, None, 0)
Define parameters to be estimated
beta1_mean = ex.Beta('beta1_mean', 0, -1000, 1000, 0) # Mean of the
distribution for beta1
beta1_stddev = ex.Beta('beta1_stddev', 0, None, None, 0) # Standard
deviation of the distribution for beta1
beta1 = beta1_mean + beta1_stddev * ex.bioDraws('beta1', 'UNIFORM')
beta2_mean = ex.Beta('beta2_mean', 0, None, None, 0) # Parameter for
water_quality
beta2_stddev = ex.Beta('beta2_stddev', 0, None, None, 0) # Standard
deviation of the distribution for beta2
beta2 = beta2_mean + beta2_stddev * ex.bioDraws('beta2', 'NORMAL')
beta3_mean = ex.Beta('beta3_mean', 0, None, None, 1) # Parameter for
price_increase
beta3_stddev = ex.Beta('beta3_stddev', 0, None, None, 0) # Standard
deviation of the distribution for beta3
beta3 = beta3_mean + beta3_stddev * ex.bioDraws('beta3', 'UNIFORM')
Define utility functions
V0 = beta1 * water_supply + beta2 * water_quality + beta3 * price_increase
V1 =ASC1 + beta1 * water_supply + beta2 * water_quality + beta3 *
price_increase
V2 =ASC1 + beta1 * water_supply + beta2 * water_quality + beta3 *
price_increase
Associate utility functions with the numbering of alternatives
V = {1: V0, 2: V1,3:V2}
Define the availability of alternatives
You should adjust these based on the specific structure of your data
Define the availability of alternatives
#av = {1: database.variables['Concept'] == 1,
2: database.variables['Concept'] == 2,
3: database.variables['Concept'] == 3}
av = {1:1,2:1,3:1}
num_draws = 10 # Number of Halton draws
draws = ex.bioDraws('draws', 'HALTON')
Estimate the parameters with a maximum of 1000 iterations
#results = biogeme.estimate(maxiter=1000)
Define the model. The choice model is a logit, with availability
conditions
prob = models.logit(V, av, chosen_alternative)
Define the log likelihood function
logprob = ex.MonteCarlo(ex.log(prob))
Create the Biogeme object
biogeme = bio.BIOGEME(database, logprob)
Estimate the parameters
#results = biogeme.estimate()
Get the estimated parameters
#parameters = results.getEstimatedParameters()
Print the parameters
#print(parameters)
Estimate the parameters
results = biogeme.estimate()
Get the estimated parameters
parameters = results.getEstimatedParameters()
Print the parameters
print(parameters)
โฆ
Mixed logit model
while trying to estimate mixed logit model I encountered the following error.Any help is greatly appreciated.
BiogemeError: The norm of the gradient is inf: g=[-1.79769313e+308 -1.79769313e+308 -1.79769313e+308 -1.79769313e+308
-1.79769313e+308]
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.