Calculating indicators with PythonBiogeme
Michel Bierlaire · Infoscience (Ecole Polytechnique Fédérale de Lausanne) · 2017
Robust Parameter Coeff.Asympt.number Description estimate std.error t-stat p-value 1 ASC CAR 0.261 0.100 2.61 0.01 2 ASC SM 0.0590 0.217 0.27 0.79 3 BETA COST -0.716 0.138 -5.18 0.00 4 BETA DIST FEMALE -0.831 0.193 -4.31 0.00 5 BETA DIST MALE -0.686 0.161 -4.27 0.00 6 BETA DIST UNREPORTED -0.703 0.196 -3.58 0.00 7 BETA TIME FULLTIME -1.60 0.333 -4.80 0.00 8 BETA TIME OTHER -0.577 0.296 -1.95 0.05 9 NEST NOCAR 1.53 0.306 1.73 1 0.08 Summary statistics Number of observations = 1906 Number of excluded observations = 359 Number of estimated parameters = 9 L(β 0 ) = -2093.955L( β) = -1298.498-2[L(β 0 ) -L( β)] = 1590.913ρ 2 = 0.380 ρ2 = 0.376 1 t-test against 1 Table 1: Nested logit model: estimated parameters 3.3 Using PythonBiogeme for point elasticities See 03 nestedElasticities .py in Section A.3The calculation of ( 16) involves derivatives.For simple models such as logit, the analytical formula of these derivatives can easily be derived.However, their derivation for advanced models can be tedious.It is common to make mistakes in the derivation itself, and even more common to make mistakes in the implementation.Therefore, PythonBiogeme provides an operator that calculates the derivative of a formula.It is illustrated in the file 03 nestedElasticities .py,reported in Section A.3.The statements that trigger the calculation of the elasticities are: e l a s p t t i m e = D e r i v e ( pr ob pt , 'TimePT ' ) * TimePT / p r o b p t e l a s p t c o s t = D e r i v e ( pr ob pt , 'MarginalCostPT ' ) * MarginalCostPT / p r o b p t e l a s c a r t i m e = D e r i v e ( p r o b c a r , 'TimeCar ' ) * TimeCar / p r o b c a r e l a s c a r c o s t = D e r i v e ( p r o b c a r , 'CostCarCHF ' ) * CostCarCHF / p r o b c a r e l a s s m d i s t = D e r i v e ( prob sm , 'distance_km ' ) * d i s t a n c e k m / prob sm