diff --git a/input/v6.3/params/baseline_v4.yaml b/input/v6.3/params/baseline_v4.yaml new file mode 100644 index 00000000..bf30c8ec --- /dev/null +++ b/input/v6.3/params/baseline_v4.yaml @@ -0,0 +1,39 @@ +#Modes: ['walk', 'pt', 'car', 'bike', 'ride'] +#Number of choices: 27235 +#Varying: ['km', 'hours', 'walking_km', 'switches', 'valid'] +# Results for model trip_choice_performing_exp_income_util_money_fixed_price_perception +#Nbr of parameters: 8 +#Sample size: 27235 +#Excluded data: 0 +#Null log likelihood: -40155.25 +#Final log likelihood: -31522.25 +#Likelihood ratio test (null): 17266 +#Rho square (null): 0.215 +#Rho bar square (null): 0.215 +#Akaike Information Criterion: 63060.49 +#Bayesian Information Criterion: 63126.19 +# Value Rob. Std err Rob. t-test Rob. p-value +# ASC_bike -1.689491 0.032510 -51.968167 0.000000e+00 +# ASC_car -1.920529 0.046183 -41.584864 0.000000e+00 +# ASC_pt -0.866749 0.029893 -28.995219 0.000000e+00 +# ASC_ride -2.401215 0.033845 -70.946824 0.000000e+00 +# BETA_PERFORMING 5.677002 0.166151 34.167734 0.000000e+00 +# BETA_PRICE_PERCEPTION 0.216186 0.027424 7.883173 3.108624e-15 +# EXP_INCOME 0.197429 0.036124 5.465322 4.620660e-08 +# UTIL_MONEY 0.534645 0.028387 18.834091 0.000000e+00 + +scoring: + scoringParameters: + - performing: 5.677002 + marginalUtilityOfMoney: 0.534645 + modeParams: + - mode: walk + constant: 0 + - mode: car + constant: 0 + dailyMonetaryConstant: -3.0914598 + - mode: pt + constant: 0 + dailyMonetaryConstant: -0.648558 +advancedScoring: + incomeExponent: 0.197429 \ No newline at end of file diff --git a/src/main/python/choicemodels/estimate_biogeme_trip_choice.py b/src/main/python/choicemodels/estimate_biogeme_trip_choice.py index 306127de..8a7211bc 100644 --- a/src/main/python/choicemodels/estimate_biogeme_trip_choice.py +++ b/src/main/python/choicemodels/estimate_biogeme_trip_choice.py @@ -2,14 +2,12 @@ # -*- coding: utf-8 -*- import argparse -from collections import defaultdict - import biogeme.biogeme as bio import biogeme.database as db import biogeme.models as models from biogeme.expressions import Beta, bioDraws, PanelLikelihoodTrajectory, log, MonteCarlo -from prepare import read_trip_choices +from prepare import read_trip_choices, daily_costs, km_costs ESTIMATE = 0 FIXED = 1 @@ -22,6 +20,9 @@ parser.add_argument("--est-performing", help="Estimate the beta for performing", action="store_true") parser.add_argument("--est-exp-income", help="Estimate exponent for income", action="store_true") parser.add_argument("--est-util-money", help="Estimate utility of money", action="store_true") + parser.add_argument("--est-fixed-price-perception", help="Estimate price perception of daily costs", + action="store_true") + parser.add_argument("--no-income", help="Don't consider the income", action="store_true") args = parser.parse_args() @@ -34,8 +35,6 @@ database = db.Database("data/choices", df) v = database.variables - km_costs = defaultdict(lambda: 0.0, car=-0.149, ride=-0.149) - ASC = {} for mode in ds.modes: # Base asc @@ -51,11 +50,14 @@ EXP_INCOME = Beta('EXP_INCOME', 1, 0, 1.5, ESTIMATE if args.est_exp_income else FIXED) UTIL_MONEY = Beta('UTIL_MONEY', 1, 0, 2, ESTIMATE if args.est_util_money else FIXED) BETA_PERFORMING = Beta('BETA_PERFORMING', 6.88, 1, 15, ESTIMATE if args.est_performing else FIXED) + BETA_PRICE_PERCEPTION = Beta('BETA_PRICE_PERCEPTION', 0, 0, 1, + ESTIMATE if args.est_fixed_price_perception else FIXED) for i, mode in enumerate(ds.modes, 1): u = ASC[mode] - BETA_PERFORMING * v[f"{mode}_hours"] * (2 if mode == "ride" else 1) price = km_costs[mode] * v[f"{mode}_km"] + price += daily_costs[mode] * v["dist_weight"] * BETA_PRICE_PERCEPTION u += price * UTIL_MONEY * (1 if args.no_income else (ds.global_income / v["income"]) ** EXP_INCOME) if mode == "pt": @@ -83,6 +85,8 @@ modelName += "_exp_income" if args.est_util_money: modelName += "_util_money" + if args.est_fixed_price_perception: + modelName += "_fixed_price_perception" biogeme.modelName = modelName biogeme.weight = v["weight"] diff --git a/src/main/python/choicemodels/prepare.py b/src/main/python/choicemodels/prepare.py index 8bb261b6..b545687d 100644 --- a/src/main/python/choicemodels/prepare.py +++ b/src/main/python/choicemodels/prepare.py @@ -142,4 +142,10 @@ def read_trip_choices(input_file: str) -> TripChoice: print("Varying:", varying) + dists = df.groupby("person").agg(dist=("beelineDist", "sum")) + + # Trips weighted by distance during the whole day + dist_weight = df.beelineDist / dists.loc[df.person].dist.to_numpy() + df["dist_weight"] = dist_weight + return TripChoice(df, modes, varying, read_global_income(input_file))