From 6ebba0971786c6de684c3492175d04a297584cb9 Mon Sep 17 00:00:00 2001 From: Jeff Newman Date: Wed, 24 Aug 2022 13:16:49 -0500 Subject: [PATCH 1/5] condense parameters --- .../estimation/larch/nonmand_tour_freq.py | 23 ++++++++++++++++--- .../estimation/test/test_larch_estimation.py | 23 +++++++++++++++++++ 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/activitysim/estimation/larch/nonmand_tour_freq.py b/activitysim/estimation/larch/nonmand_tour_freq.py index 22f026d05..97d658c97 100644 --- a/activitysim/estimation/larch/nonmand_tour_freq.py +++ b/activitysim/estimation/larch/nonmand_tour_freq.py @@ -125,7 +125,23 @@ def unavail(model, x_ca): def nonmand_tour_freq_model( edb_directory="output/estimation_data_bundle/{name}/", return_data=False, + condense_parameters=True, ): + """ + Prepare nonmandatory tour frequency models for estimation. + + Parameters + ---------- + edb_directory : str + Location of estimation data bundle for these models. + return_data : bool, default False + Whether to return the data used in preparing this function. + If returned, data is a dict in the second return value. + condense_parameters : bool, default True + Apply a transformation whereby all parameters in each model that + have the same initial value are converted to have the same name + (and thus to be the same parameter, used in various places). + """ data = interaction_simulate_data( name="non_mandatory_tour_frequency", edb_directory=edb_directory, @@ -133,9 +149,10 @@ def nonmand_tour_freq_model( settings = data.settings segment_names = [s["NAME"] for s in settings["SPEC_SEGMENTS"]] - data.relabel_coef = link_same_value_coefficients( - segment_names, data.coefficients, data.spec - ) + if condense_parameters: + data.relabel_coef = link_same_value_coefficients( + segment_names, data.coefficients, data.spec + ) spec = data.spec coefficients = data.coefficients chooser_data = data.chooser_data diff --git a/activitysim/estimation/test/test_larch_estimation.py b/activitysim/estimation/test/test_larch_estimation.py index 624410fd0..5504f467b 100644 --- a/activitysim/estimation/test/test_larch_estimation.py +++ b/activitysim/estimation/test/test_larch_estimation.py @@ -272,10 +272,22 @@ def test_nonmand_tour_freq(est_data, num_regression, dataframe_regression): m = nonmand_tour_freq_model() loglike_prior = {} + expected_n_params = { + "PTYPE_FULL": 72, + "PTYPE_PART": 51, + "PTYPE_UNIVERSITY": 70, + "PTYPE_NONWORK": 77, + "PTYPE_RETIRED": 53, + "PTYPE_DRIVING": 43, + "PTYPE_SCHOOL": 34, + "PTYPE_PRESCHOOL": 25, + } for segment_name in m: m[segment_name].load_data() m[segment_name].doctor(repair_ch_av="-") loglike_prior[segment_name] = m[segment_name].loglike() + assert len(m[segment_name].pf) == expected_n_params[segment_name] + assert len(m[segment_name].utility_ca) == 210 r = {} for segment_name in m: r[segment_name] = m[segment_name].maximize_loglike( @@ -288,3 +300,14 @@ def test_nonmand_tour_freq(est_data, num_regression, dataframe_regression): basename="test_nonmand_tour_freq_loglike", ) _regression_check(dataframe_regression, pd.concat([x.pf for x in m.values()])) + + +def test_nonmand_tour_freq_not_condensed( + est_data, num_regression, dataframe_regression +): + from activitysim.estimation.larch.nonmand_tour_freq import nonmand_tour_freq_model + + m = nonmand_tour_freq_model(condense_parameters=False) + for segment_name in m: + assert len(m[segment_name].pf) == 210 + assert len(m[segment_name].utility_ca) == 210 From fa974440cde0a43e85cf1ab29d2bd4b94f1355a5 Mon Sep 17 00:00:00 2001 From: Jeff Newman Date: Wed, 24 Aug 2022 15:34:30 -0500 Subject: [PATCH 2/5] update notebook for nonmand tour freq --- activitysim/estimation/larch/general.py | 15 +- .../notebooks/15_non_mand_tour_freq.ipynb | 2232 +++++++++-------- 2 files changed, 1199 insertions(+), 1048 deletions(-) diff --git a/activitysim/estimation/larch/general.py b/activitysim/estimation/larch/general.py index 1844d5964..10f28d166 100644 --- a/activitysim/estimation/larch/general.py +++ b/activitysim/estimation/larch/general.py @@ -490,13 +490,22 @@ def clean_values( return values -def update_coefficients(model, data, result_dir=Path("."), output_file=None): +def update_coefficients(model, data, result_dir=Path("."), output_file=None, relabel_coef=None): if isinstance(data, pd.DataFrame): coefficients = data.copy() else: coefficients = data.coefficients.copy() - est_names = [j for j in coefficients.index if j in model.pf.index] - coefficients.loc[est_names, "value"] = model.pf.loc[est_names, "value"] + if relabel_coef is not None and len(relabel_coef): + for j in coefficients.index: + if j in model.pf.index: + coefficients.loc[j, "value"] = model.pf.loc[j, "value"] + else: + j_ = relabel_coef.get(j, None) + if j_ is not None and j_ in model.pf.index: + coefficients.loc[j, "value"] = model.pf.loc[j_, "value"] + else: + est_names = [j for j in coefficients.index if j in model.pf.index] + coefficients.loc[est_names, "value"] = model.pf.loc[est_names, "value"] if output_file is not None: os.makedirs(result_dir, exist_ok=True) coefficients.reset_index().to_csv( diff --git a/activitysim/examples/example_estimation/notebooks/15_non_mand_tour_freq.ipynb b/activitysim/examples/example_estimation/notebooks/15_non_mand_tour_freq.ipynb index f6ce37d14..76e0de5c4 100644 --- a/activitysim/examples/example_estimation/notebooks/15_non_mand_tour_freq.ipynb +++ b/activitysim/examples/example_estimation/notebooks/15_non_mand_tour_freq.ipynb @@ -34,11 +34,24 @@ "id": "s53VwlPwtNnr", "outputId": "d1208b7a-c1f2-4b0b-c439-bf312fe12be0" }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "'1.1.0'" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "import os\n", "import larch # !conda install larch -c conda-forge # for estimation\n", - "import pandas as pd" + "import pandas as pd\n", + "import activitysim\n", + "activitysim.__version__" ] }, { @@ -73,7 +86,7 @@ "modelname = \"nonmand_tour_freq\"\n", "\n", "from activitysim.estimation.larch import component_model\n", - "model, data = component_model(modelname, return_data=True)" + "model, data = component_model(modelname, return_data=True, condense_parameters=True)" ] }, { @@ -712,13 +725,49 @@ "source": [ "# Estimate\n", "\n", - "With the model setup for estimation, the next step is to estimate the model coefficients. Make sure to use a sufficiently large enough household sample and set of zones to avoid an over-specified model, which does not have a numerically stable likelihood maximizing solution. Larch has a built-in estimation methods including BHHH, and also offers access to more advanced general purpose non-linear optimizers in the `scipy` package, including SLSQP, which allows for bounds and constraints on parameters. BHHH is the default and typically runs faster, but does not follow constraints on parameters." + "With the model setup for estimation, the next step is to estimate the model coefficients. Make sure to use a sufficiently large enough household sample and set of zones to avoid an over-specified model, which does not have a numerically stable likelihood maximizing solution. The prototype model spec we are re-estimating has 210 rows for each person type, but the accompanying dataset is not large enough to successfully estimate anywhere near than many parameters, so a short cut is applied by having one parameter only per unique existing parameter value." ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Person type PTYPE_FULL has 210 utility terms and 72 unique parameters.\n", + "Person type PTYPE_PART has 210 utility terms and 51 unique parameters.\n", + "Person type PTYPE_UNIVERSITY has 210 utility terms and 70 unique parameters.\n", + "Person type PTYPE_NONWORK has 210 utility terms and 77 unique parameters.\n", + "Person type PTYPE_RETIRED has 210 utility terms and 53 unique parameters.\n", + "Person type PTYPE_DRIVING has 210 utility terms and 43 unique parameters.\n", + "Person type PTYPE_SCHOOL has 210 utility terms and 34 unique parameters.\n", + "Person type PTYPE_PRESCHOOL has 210 utility terms and 25 unique parameters.\n" + ] + } + ], + "source": [ + "for k, m in model.items():\n", + " print(f\"Person type {k} has {len(m.utility_ca)} utility terms and {len(m.pf)} unique parameters.\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "For future estimation work, parameters can be intelligently named and applied to match the model developer's desired structure (by using the same named parameter for multiple rows of the spec file). If this is done, the \"short cut\" can be disabled by setting `condense_parameters=False` in the loading step above.\n", + "\n", + "Larch has a built-in estimation methods including BHHH, and also offers access to more advanced general purpose non-linear optimizers in the `scipy` package, including SLSQP, which allows for bounds and constraints on parameters. BHHH is the default and typically runs faster, but does not follow constraints on parameters." + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": { + "scrolled": false + }, "outputs": [ { "name": "stderr", @@ -742,7 +791,7 @@ { "data": { "text/html": [ - "

Best LL = -1831.0744991065408

" + "

Best LL = -1831.0744991680774

" ], "text/plain": [ "" @@ -788,8 +837,8 @@ " -2.000000\n", " -2.0000\n", " 0.0\n", - " NaN\n", - " NaN\n", + " -2.0\n", + " -2.0\n", " 1\n", " \n", " -2.000000\n", @@ -829,14 +878,14 @@ " \n", " \n", " coef_1_plus_other_discretionary_tours_constant\n", - " 10.543980\n", + " 10.543979\n", " 0.7412\n", " 0.0\n", " NaN\n", " NaN\n", " 0\n", " \n", - " 10.543980\n", + " 10.543979\n", " \n", " \n", " ...\n", @@ -915,7 +964,7 @@ "coef_1_escort_tour_constant 0.319037 0.0298 \n", "coef_1_plus_eating_out_tours_constant -1.012856 0.0097 \n", "coef_1_plus_maintenance_tours_constant -2.842643 0.1202 \n", - "coef_1_plus_other_discretionary_tours_constant 10.543980 0.7412 \n", + "coef_1_plus_other_discretionary_tours_constant 10.543979 0.7412 \n", "... ... ... \n", "coef_walk_access_to_retail_and_discretionary 0.160520 0.0567 \n", "coef_walk_access_to_retail_and_eating_out 0.211289 0.1450 \n", @@ -924,7 +973,7 @@ "coef_zero_car_ownership_and_tour_frequency_is_5... -0.227492 -0.3486 \n", "\n", " nullvalue minimum \\\n", - "coef_0_auto_household_and_escorting_tour 0.0 NaN \n", + "coef_0_auto_household_and_escorting_tour 0.0 -2.0 \n", "coef_1_escort_tour_constant 0.0 NaN \n", "coef_1_plus_eating_out_tours_constant 0.0 NaN \n", "coef_1_plus_maintenance_tours_constant 0.0 NaN \n", @@ -937,7 +986,7 @@ "coef_zero_car_ownership_and_tour_frequency_is_5... 0.0 NaN \n", "\n", " maximum holdfast note \\\n", - "coef_0_auto_household_and_escorting_tour NaN 1 \n", + "coef_0_auto_household_and_escorting_tour -2.0 1 \n", "coef_1_escort_tour_constant NaN 0 \n", "coef_1_plus_eating_out_tours_constant NaN 0 \n", "coef_1_plus_maintenance_tours_constant NaN 0 \n", @@ -954,7 +1003,7 @@ "coef_1_escort_tour_constant 0.319037 \n", "coef_1_plus_eating_out_tours_constant -1.012856 \n", "coef_1_plus_maintenance_tours_constant -2.842643 \n", - "coef_1_plus_other_discretionary_tours_constant 10.543980 \n", + "coef_1_plus_other_discretionary_tours_constant 10.543979 \n", "... ... \n", "coef_walk_access_to_retail_and_discretionary 0.160520 \n", "coef_walk_access_to_retail_and_eating_out 0.211289 \n", @@ -972,11 +1021,16 @@ "name": "stderr", "output_type": "stream", "text": [ - ":2: PossibleOverspecification: WARNING: Model is possibly over-specified (hessian is nearly singular).\n", + "/var/folders/js/bk_dt9015j79_f6bxnc44dsr0000gp/T/ipykernel_48972/89088409.py:2: PossibleOverspecification: WARNING: Model is possibly over-specified (hessian is nearly singular).\n", " m.estimate(method='SLSQP')\n", - "/Users/jeffnewman/OneDrive - Cambridge Systematics/Git/larch/larch/linalg/__init__.py:18: UserWarning: minimum eig 3.981360340588202e-07 in general_inverse\n", + "/Users/jeffnewman/LocalGit/asim-larch/activitysim-larch/conda-environments/AL-ENV/lib/python3.9/site-packages/larch/linalg/__init__.py:18: UserWarning: minimum eig 5.456681257677148e-07 in general_inverse\n", " warnings.warn(f\"minimum eig {min_eig} in general_inverse\")\n", - ":2: RuntimeWarning: invalid value encountered in sqrt\n", + "/var/folders/js/bk_dt9015j79_f6bxnc44dsr0000gp/T/ipykernel_48972/89088409.py:2: PossibleOverspecification: WARNING: Model seems to have 3 parameter estimators with negative variance\n", + "- coef_1_escort_tour_constant\n", + "- coef_2_plus_escort_tours_constant\n", + "- coef_urban_and_escorting_tour\n", + " m.estimate(method='SLSQP')\n", + "/var/folders/js/bk_dt9015j79_f6bxnc44dsr0000gp/T/ipykernel_48972/89088409.py:2: RuntimeWarning: invalid value encountered in sqrt\n", " m.estimate(method='SLSQP')\n", "req_data does not request avail_ca or avail_co but it is set and being provided\n" ] @@ -996,7 +1050,7 @@ { "data": { "text/html": [ - "

Best LL = -856.8595081575636

" + "

Best LL = -856.8595081667797

" ], "text/plain": [ "" @@ -1042,8 +1096,8 @@ " -2.000000\n", " -2.0000\n", " 0.0\n", - " NaN\n", - " NaN\n", + " -2.0\n", + " -2.0\n", " 1\n", " \n", " -2.000000\n", @@ -1317,8 +1371,8 @@ " -999.000000\n", " -999.0000\n", " 0.0\n", - " NaN\n", - " NaN\n", + " -999.0\n", + " -999.0\n", " 1\n", " \n", " -999.000000\n", @@ -1446,14 +1500,14 @@ " \n", " \n", " coef_presence_of_preschool_kid_in_household_and_tour_frequency_is_1\n", - " 0.308612\n", + " 0.308611\n", " -0.1559\n", " 0.0\n", " NaN\n", " NaN\n", " 0\n", " \n", - " 0.308612\n", + " 0.308611\n", " \n", " \n", " coef_presence_of_preschool_kid_in_household_and_tour_frequency_is_5\n", @@ -1548,8 +1602,8 @@ " 0.000000\n", " 0.0000\n", " 0.0\n", - " NaN\n", - " NaN\n", + " 0.0\n", + " 0.0\n", " 1\n", " \n", " 0.000000\n", @@ -1641,7 +1695,7 @@ "coef_presence_of_part_time_worker_and_maintenan... -1.034909 -0.5621 \n", "coef_presence_of_pre_driving_school_kid_and_esc... 1.808890 1.5795 \n", "coef_presence_of_pre_school_kid_and_escorting_tour 0.291702 0.5414 \n", - "coef_presence_of_preschool_kid_in_household_and... 0.308612 -0.1559 \n", + "coef_presence_of_preschool_kid_in_household_and... 0.308611 -0.1559 \n", "coef_presence_of_preschool_kid_in_household_and... -0.530685 -0.5681 \n", "coef_presence_of_retiree_and_eating_out_tour 0.109209 -1.3890 \n", "coef_presence_of_retiree_and_escorting_tour -0.461150 -0.7516 \n", @@ -1657,7 +1711,7 @@ "coef_walk_access_to_retail_and_tour_frequency_i... 0.050631 0.3479 \n", "\n", " nullvalue minimum \\\n", - "coef_0_auto_household_and_escorting_tour 0.0 NaN \n", + "coef_0_auto_household_and_escorting_tour 0.0 -2.0 \n", "coef_1_escort_tour_constant 0.0 NaN \n", "coef_1_plus_eating_out_tours_constant 0.0 NaN \n", "coef_1_plus_maintenance_tours_constant 0.0 NaN \n", @@ -1682,7 +1736,7 @@ "coef_mediumlow_income_group_and_tour_frequency_... 0.0 NaN \n", "coef_mediumlow_income_group_and_tour_frequency_... 0.0 NaN \n", "coef_number_of_joint_tours_and_tour_frequency_is_4 0.0 NaN \n", - "coef_number_of_joint_tours_and_tour_frequency_i... 0.0 NaN \n", + "coef_number_of_joint_tours_and_tour_frequency_i... 0.0 -999.0 \n", "coef_number_of_mandatory_tours_and_tour_frequen... 0.0 NaN \n", "coef_number_of_mandatory_tours_and_tour_frequen... 0.0 NaN \n", "coef_number_of_mandatory_tours_and_tour_frequen... 0.0 NaN \n", @@ -1703,14 +1757,14 @@ "coef_total_number_of_tours_is_2 0.0 NaN \n", "coef_total_number_of_tours_is_3 0.0 NaN \n", "coef_total_number_of_tours_is_4 0.0 NaN \n", - "coef_urban_and_discretionary_tour 0.0 NaN \n", + "coef_urban_and_discretionary_tour 0.0 0.0 \n", "coef_urban_and_escorting_tour 0.0 NaN \n", "coef_walk_access_to_retail_and_tour_frequency_is_1 0.0 NaN \n", "coef_walk_access_to_retail_and_tour_frequency_is_2 0.0 NaN \n", "coef_walk_access_to_retail_and_tour_frequency_i... 0.0 NaN \n", "\n", " maximum holdfast note \\\n", - "coef_0_auto_household_and_escorting_tour NaN 1 \n", + "coef_0_auto_household_and_escorting_tour -2.0 1 \n", "coef_1_escort_tour_constant NaN 0 \n", "coef_1_plus_eating_out_tours_constant NaN 0 \n", "coef_1_plus_maintenance_tours_constant NaN 0 \n", @@ -1735,7 +1789,7 @@ "coef_mediumlow_income_group_and_tour_frequency_... NaN 0 \n", "coef_mediumlow_income_group_and_tour_frequency_... NaN 0 \n", "coef_number_of_joint_tours_and_tour_frequency_is_4 NaN 0 \n", - "coef_number_of_joint_tours_and_tour_frequency_i... NaN 1 \n", + "coef_number_of_joint_tours_and_tour_frequency_i... -999.0 1 \n", "coef_number_of_mandatory_tours_and_tour_frequen... NaN 0 \n", "coef_number_of_mandatory_tours_and_tour_frequen... NaN 0 \n", "coef_number_of_mandatory_tours_and_tour_frequen... NaN 0 \n", @@ -1756,7 +1810,7 @@ "coef_total_number_of_tours_is_2 NaN 0 \n", "coef_total_number_of_tours_is_3 NaN 0 \n", "coef_total_number_of_tours_is_4 NaN 0 \n", - "coef_urban_and_discretionary_tour NaN 1 \n", + "coef_urban_and_discretionary_tour 0.0 1 \n", "coef_urban_and_escorting_tour NaN 0 \n", "coef_walk_access_to_retail_and_tour_frequency_is_1 NaN 0 \n", "coef_walk_access_to_retail_and_tour_frequency_is_2 NaN 0 \n", @@ -1800,7 +1854,7 @@ "coef_presence_of_part_time_worker_and_maintenan... -1.034909 \n", "coef_presence_of_pre_driving_school_kid_and_esc... 1.808890 \n", "coef_presence_of_pre_school_kid_and_escorting_tour 0.291702 \n", - "coef_presence_of_preschool_kid_in_household_and... 0.308612 \n", + "coef_presence_of_preschool_kid_in_household_and... 0.308611 \n", "coef_presence_of_preschool_kid_in_household_and... -0.530685 \n", "coef_presence_of_retiree_and_eating_out_tour 0.109209 \n", "coef_presence_of_retiree_and_escorting_tour -0.461150 \n", @@ -1823,11 +1877,15 @@ "name": "stderr", "output_type": "stream", "text": [ - ":2: PossibleOverspecification: WARNING: Model is possibly over-specified (hessian is nearly singular).\n", + "/var/folders/js/bk_dt9015j79_f6bxnc44dsr0000gp/T/ipykernel_48972/89088409.py:2: PossibleOverspecification: WARNING: Model is possibly over-specified (hessian is nearly singular).\n", " m.estimate(method='SLSQP')\n", - "/Users/jeffnewman/OneDrive - Cambridge Systematics/Git/larch/larch/linalg/__init__.py:18: UserWarning: minimum eig 5.859529741365759e-08 in general_inverse\n", + "/Users/jeffnewman/LocalGit/asim-larch/activitysim-larch/conda-environments/AL-ENV/lib/python3.9/site-packages/larch/linalg/__init__.py:18: UserWarning: minimum eig 3.818666298527715e-07 in general_inverse\n", " warnings.warn(f\"minimum eig {min_eig} in general_inverse\")\n", - ":2: RuntimeWarning: invalid value encountered in sqrt\n", + "/var/folders/js/bk_dt9015j79_f6bxnc44dsr0000gp/T/ipykernel_48972/89088409.py:2: PossibleOverspecification: WARNING: Model seems to have 2 parameter estimators with negative variance\n", + "- coef_1_escort_tour_constant\n", + "- coef_2_plus_escort_tours_constant\n", + " m.estimate(method='SLSQP')\n", + "/var/folders/js/bk_dt9015j79_f6bxnc44dsr0000gp/T/ipykernel_48972/89088409.py:2: RuntimeWarning: invalid value encountered in sqrt\n", " m.estimate(method='SLSQP')\n", "req_data does not request avail_ca or avail_co but it is set and being provided\n" ] @@ -1847,7 +1905,7 @@ { "data": { "text/html": [ - "

Best LL = -324.85841724064665

" + "

Best LL = -324.8584172756779

" ], "text/plain": [ "" @@ -1893,8 +1951,8 @@ " -2.000000\n", " -2.0000\n", " 0.0\n", - " NaN\n", - " NaN\n", + " -2.0\n", + " -2.0\n", " 1\n", " \n", " -2.000000\n", @@ -2029,7 +2087,7 @@ "coef_walk_access_to_retail_and_shopping 0.102379 0.0972 \n", "\n", " nullvalue minimum maximum \\\n", - "coef_0_auto_household_and_escorting_tour 0.0 NaN NaN \n", + "coef_0_auto_household_and_escorting_tour 0.0 -2.0 -2.0 \n", "coef_1_escort_tour_constant 0.0 NaN NaN \n", "coef_1_plus_eating_out_tours_constant 0.0 NaN NaN \n", "coef_1_plus_maintenance_tours_constant 0.0 NaN NaN \n", @@ -2064,11 +2122,18 @@ "name": "stderr", "output_type": "stream", "text": [ - ":2: PossibleOverspecification: WARNING: Model is possibly over-specified (hessian is nearly singular).\n", + "/var/folders/js/bk_dt9015j79_f6bxnc44dsr0000gp/T/ipykernel_48972/89088409.py:2: PossibleOverspecification: WARNING: Model is possibly over-specified (hessian is nearly singular).\n", " m.estimate(method='SLSQP')\n", - "/Users/jeffnewman/OneDrive - Cambridge Systematics/Git/larch/larch/linalg/__init__.py:18: UserWarning: minimum eig 3.866421268239863e-13 in general_inverse\n", + "/Users/jeffnewman/LocalGit/asim-larch/activitysim-larch/conda-environments/AL-ENV/lib/python3.9/site-packages/larch/linalg/__init__.py:18: UserWarning: minimum eig 3.8717456834857003e-13 in general_inverse\n", " warnings.warn(f\"minimum eig {min_eig} in general_inverse\")\n", - ":2: RuntimeWarning: invalid value encountered in sqrt\n", + "/var/folders/js/bk_dt9015j79_f6bxnc44dsr0000gp/T/ipykernel_48972/89088409.py:2: PossibleOverspecification: WARNING: Model seems to have 13 parameter estimators with negative variance\n", + "- coef_1_plus_eating_out_tours_constant\n", + "- coef_1_plus_shopping_tours_constant\n", + "- coef_1_plus_visting_tours_constant\n", + "- coef_logged_maximum_residual_window_tour_frequency_is_0\n", + "- and 9 more\n", + " m.estimate(method='SLSQP')\n", + "/var/folders/js/bk_dt9015j79_f6bxnc44dsr0000gp/T/ipykernel_48972/89088409.py:2: RuntimeWarning: invalid value encountered in sqrt\n", " m.estimate(method='SLSQP')\n", "req_data does not request avail_ca or avail_co but it is set and being provided\n" ] @@ -2088,7 +2153,7 @@ { "data": { "text/html": [ - "

Best LL = -1038.960565924978

" + "

Best LL = -1038.9605658891858

" ], "text/plain": [ "" @@ -2134,55 +2199,55 @@ " -2.000000\n", " -2.0000\n", " 0.0\n", - " NaN\n", - " NaN\n", + " -2.0\n", + " -2.0\n", " 1\n", " \n", " -2.000000\n", " \n", " \n", " coef_1_escort_tour_constant\n", - " -4.317861\n", + " -4.317862\n", " -0.0629\n", " 0.0\n", " NaN\n", " NaN\n", " 0\n", " \n", - " -4.317861\n", + " -4.317862\n", " \n", " \n", " coef_1_plus_eating_out_tours_constant\n", - " -4.459266\n", + " -4.459267\n", " -0.1429\n", " 0.0\n", " NaN\n", " NaN\n", " 0\n", " \n", - " -4.459266\n", + " -4.459267\n", " \n", " \n", " coef_1_plus_maintenance_tours_constant\n", - " -9.609589\n", + " -9.609591\n", " -0.0653\n", " 0.0\n", " NaN\n", " NaN\n", " 0\n", " \n", - " -9.609589\n", + " -9.609591\n", " \n", " \n", " coef_1_plus_other_discretionary_tours_constant\n", - " -4.488177\n", + " -4.488178\n", " 0.3334\n", " 0.0\n", " NaN\n", " NaN\n", " 0\n", " \n", - " -4.488177\n", + " -4.488178\n", " \n", " \n", " ...\n", @@ -2258,10 +2323,10 @@ "text/plain": [ " value initvalue \\\n", "coef_0_auto_household_and_escorting_tour -2.000000 -2.0000 \n", - "coef_1_escort_tour_constant -4.317861 -0.0629 \n", - "coef_1_plus_eating_out_tours_constant -4.459266 -0.1429 \n", - "coef_1_plus_maintenance_tours_constant -9.609589 -0.0653 \n", - "coef_1_plus_other_discretionary_tours_constant -4.488177 0.3334 \n", + "coef_1_escort_tour_constant -4.317862 -0.0629 \n", + "coef_1_plus_eating_out_tours_constant -4.459267 -0.1429 \n", + "coef_1_plus_maintenance_tours_constant -9.609591 -0.0653 \n", + "coef_1_plus_other_discretionary_tours_constant -4.488178 0.3334 \n", "... ... ... \n", "coef_walk_access_to_retail_and_discretionary 0.214072 0.0772 \n", "coef_walk_access_to_retail_and_shopping 0.039849 0.0598 \n", @@ -2270,7 +2335,7 @@ "coef_walk_access_to_retail_and_tour_frequency_i... -0.260693 0.1508 \n", "\n", " nullvalue minimum \\\n", - "coef_0_auto_household_and_escorting_tour 0.0 NaN \n", + "coef_0_auto_household_and_escorting_tour 0.0 -2.0 \n", "coef_1_escort_tour_constant 0.0 NaN \n", "coef_1_plus_eating_out_tours_constant 0.0 NaN \n", "coef_1_plus_maintenance_tours_constant 0.0 NaN \n", @@ -2283,7 +2348,7 @@ "coef_walk_access_to_retail_and_tour_frequency_i... 0.0 NaN \n", "\n", " maximum holdfast note \\\n", - "coef_0_auto_household_and_escorting_tour NaN 1 \n", + "coef_0_auto_household_and_escorting_tour -2.0 1 \n", "coef_1_escort_tour_constant NaN 0 \n", "coef_1_plus_eating_out_tours_constant NaN 0 \n", "coef_1_plus_maintenance_tours_constant NaN 0 \n", @@ -2297,10 +2362,10 @@ "\n", " best \n", "coef_0_auto_household_and_escorting_tour -2.000000 \n", - "coef_1_escort_tour_constant -4.317861 \n", - "coef_1_plus_eating_out_tours_constant -4.459266 \n", - "coef_1_plus_maintenance_tours_constant -9.609589 \n", - "coef_1_plus_other_discretionary_tours_constant -4.488177 \n", + "coef_1_escort_tour_constant -4.317862 \n", + "coef_1_plus_eating_out_tours_constant -4.459267 \n", + "coef_1_plus_maintenance_tours_constant -9.609591 \n", + "coef_1_plus_other_discretionary_tours_constant -4.488178 \n", "... ... \n", "coef_walk_access_to_retail_and_discretionary 0.214072 \n", "coef_walk_access_to_retail_and_shopping 0.039849 \n", @@ -2318,11 +2383,18 @@ "name": "stderr", "output_type": "stream", "text": [ - ":2: PossibleOverspecification: WARNING: Model is possibly over-specified (hessian is nearly singular).\n", + "/var/folders/js/bk_dt9015j79_f6bxnc44dsr0000gp/T/ipykernel_48972/89088409.py:2: PossibleOverspecification: WARNING: Model is possibly over-specified (hessian is nearly singular).\n", " m.estimate(method='SLSQP')\n", - "/Users/jeffnewman/OneDrive - Cambridge Systematics/Git/larch/larch/linalg/__init__.py:18: UserWarning: minimum eig 1.6153105979883785e-16 in general_inverse\n", + "/Users/jeffnewman/LocalGit/asim-larch/activitysim-larch/conda-environments/AL-ENV/lib/python3.9/site-packages/larch/linalg/__init__.py:18: UserWarning: minimum eig 2.673077519570165e-16 in general_inverse\n", " warnings.warn(f\"minimum eig {min_eig} in general_inverse\")\n", - ":2: RuntimeWarning: invalid value encountered in sqrt\n", + "/var/folders/js/bk_dt9015j79_f6bxnc44dsr0000gp/T/ipykernel_48972/89088409.py:2: PossibleOverspecification: WARNING: Model seems to have 21 parameter estimators with negative variance\n", + "- coef_1_escort_tour_constant\n", + "- coef_1_plus_eating_out_tours_constant\n", + "- coef_1_plus_maintenance_tours_constant\n", + "- coef_1_plus_other_discretionary_tours_constant\n", + "- and 17 more\n", + " m.estimate(method='SLSQP')\n", + "/var/folders/js/bk_dt9015j79_f6bxnc44dsr0000gp/T/ipykernel_48972/89088409.py:2: RuntimeWarning: invalid value encountered in sqrt\n", " m.estimate(method='SLSQP')\n", "req_data does not request avail_ca or avail_co but it is set and being provided\n" ] @@ -2342,7 +2414,7 @@ { "data": { "text/html": [ - "

Best LL = -787.4000431643133

" + "

Best LL = -787.4000431560225

" ], "text/plain": [ "" @@ -2388,8 +2460,8 @@ " -2.000000\n", " -2.0000\n", " 0.0\n", - " NaN\n", - " NaN\n", + " -2.0\n", + " -2.0\n", " 1\n", " \n", " -2.000000\n", @@ -2462,14 +2534,14 @@ " \n", " \n", " coef_2_plus_escort_tours_constant\n", - " -4.935936\n", + " -4.935937\n", " 0.5175\n", " 0.0\n", " NaN\n", " NaN\n", " 0\n", " \n", - " -4.935936\n", + " -4.935937\n", " \n", " \n", " coef_car_surplus_vs_workers_and_tour_frequency_is_1\n", @@ -2729,8 +2801,8 @@ " -999.000000\n", " -999.0000\n", " 0.0\n", - " NaN\n", - " NaN\n", + " -999.0\n", + " -999.0\n", " 1\n", " \n", " -999.000000\n", @@ -2949,8 +3021,8 @@ " 0.000000\n", " 0.0000\n", " 0.0\n", - " NaN\n", - " NaN\n", + " 0.0\n", + " 0.0\n", " 1\n", " \n", " 0.000000\n", @@ -2979,7 +3051,7 @@ "coef_1_plus_other_discretionary_tours_constant -2.243196 0.4282 \n", "coef_1_plus_shopping_tours_constant -1.916643 0.5947 \n", "coef_1_plus_visting_tours_constant -2.344018 0.2789 \n", - "coef_2_plus_escort_tours_constant -4.935936 0.5175 \n", + "coef_2_plus_escort_tours_constant -4.935937 0.5175 \n", "coef_car_surplus_vs_workers_and_tour_frequency_... 3.094754 0.7965 \n", "coef_car_surplus_vs_workers_and_tour_frequency_... 3.475854 2.1302 \n", "coef_female_and_discretionary_tour 0.541528 0.4954 \n", @@ -3027,7 +3099,7 @@ "coef_walk_access_to_retail_and_tour_frequency_i... 0.691082 0.0616 \n", "\n", " nullvalue minimum \\\n", - "coef_0_auto_household_and_escorting_tour 0.0 NaN \n", + "coef_0_auto_household_and_escorting_tour 0.0 -2.0 \n", "coef_1_escort_tour_constant 0.0 NaN \n", "coef_1_plus_eating_out_tours_constant 0.0 NaN \n", "coef_1_plus_maintenance_tours_constant 0.0 NaN \n", @@ -3058,7 +3130,7 @@ "coef_number_of_joint_shopping_tours 0.0 NaN \n", "coef_number_of_joint_tours_and_tour_frequency_is_2 0.0 NaN \n", "coef_number_of_joint_tours_and_tour_frequency_is_3 0.0 NaN \n", - "coef_number_of_joint_tours_and_tour_frequency_i... 0.0 NaN \n", + "coef_number_of_joint_tours_and_tour_frequency_i... 0.0 -999.0 \n", "coef_number_of_mandatory_tours_and_tour_frequen... 0.0 NaN \n", "coef_presence_of_full_time_worker_and_discretio... 0.0 NaN \n", "coef_presence_of_full_time_worker_and_shopping_... 0.0 NaN \n", @@ -3078,11 +3150,11 @@ "coef_total_number_of_tours_is_3 0.0 NaN \n", "coef_total_number_of_tours_is_4 0.0 NaN \n", "coef_total_number_of_tours_is_5 0.0 NaN \n", - "coef_urban_and_discretionary_tour 0.0 NaN \n", + "coef_urban_and_discretionary_tour 0.0 0.0 \n", "coef_walk_access_to_retail_and_tour_frequency_i... 0.0 NaN \n", "\n", " maximum holdfast note \\\n", - "coef_0_auto_household_and_escorting_tour NaN 1 \n", + "coef_0_auto_household_and_escorting_tour -2.0 1 \n", "coef_1_escort_tour_constant NaN 0 \n", "coef_1_plus_eating_out_tours_constant NaN 0 \n", "coef_1_plus_maintenance_tours_constant NaN 0 \n", @@ -3113,7 +3185,7 @@ "coef_number_of_joint_shopping_tours NaN 0 \n", "coef_number_of_joint_tours_and_tour_frequency_is_2 NaN 0 \n", "coef_number_of_joint_tours_and_tour_frequency_is_3 NaN 0 \n", - "coef_number_of_joint_tours_and_tour_frequency_i... NaN 1 \n", + "coef_number_of_joint_tours_and_tour_frequency_i... -999.0 1 \n", "coef_number_of_mandatory_tours_and_tour_frequen... NaN 0 \n", "coef_presence_of_full_time_worker_and_discretio... NaN 0 \n", "coef_presence_of_full_time_worker_and_shopping_... NaN 0 \n", @@ -3133,7 +3205,7 @@ "coef_total_number_of_tours_is_3 NaN 0 \n", "coef_total_number_of_tours_is_4 NaN 0 \n", "coef_total_number_of_tours_is_5 NaN 0 \n", - "coef_urban_and_discretionary_tour NaN 1 \n", + "coef_urban_and_discretionary_tour 0.0 1 \n", "coef_walk_access_to_retail_and_tour_frequency_i... NaN 0 \n", "\n", " best \n", @@ -3144,7 +3216,7 @@ "coef_1_plus_other_discretionary_tours_constant -2.243196 \n", "coef_1_plus_shopping_tours_constant -1.916643 \n", "coef_1_plus_visting_tours_constant -2.344018 \n", - "coef_2_plus_escort_tours_constant -4.935936 \n", + "coef_2_plus_escort_tours_constant -4.935937 \n", "coef_car_surplus_vs_workers_and_tour_frequency_... 3.094754 \n", "coef_car_surplus_vs_workers_and_tour_frequency_... 3.475854 \n", "coef_female_and_discretionary_tour 0.541528 \n", @@ -3199,10 +3271,19 @@ "name": "stderr", "output_type": "stream", "text": [ - ":2: PossibleOverspecification: WARNING: Model is possibly over-specified (hessian is nearly singular).\n", + "/var/folders/js/bk_dt9015j79_f6bxnc44dsr0000gp/T/ipykernel_48972/89088409.py:2: PossibleOverspecification: WARNING: Model is possibly over-specified (hessian is nearly singular).\n", " m.estimate(method='SLSQP')\n", - "/Users/jeffnewman/OneDrive - Cambridge Systematics/Git/larch/larch/linalg/__init__.py:18: UserWarning: minimum eig 9.97417709684196e-16 in general_inverse\n", + "/Users/jeffnewman/LocalGit/asim-larch/activitysim-larch/conda-environments/AL-ENV/lib/python3.9/site-packages/larch/linalg/__init__.py:18: UserWarning: minimum eig 1.7375419460797773e-15 in general_inverse\n", " warnings.warn(f\"minimum eig {min_eig} in general_inverse\")\n", + "/var/folders/js/bk_dt9015j79_f6bxnc44dsr0000gp/T/ipykernel_48972/89088409.py:2: PossibleOverspecification: WARNING: Model seems to have 11 parameter estimators with negative variance\n", + "- coef_1_escort_tour_constant\n", + "- coef_1_plus_eating_out_tours_constant\n", + "- coef_1_plus_maintenance_tours_constant\n", + "- coef_1_plus_other_discretionary_tours_constant\n", + "- and 7 more\n", + " m.estimate(method='SLSQP')\n", + "/var/folders/js/bk_dt9015j79_f6bxnc44dsr0000gp/T/ipykernel_48972/89088409.py:2: RuntimeWarning: invalid value encountered in sqrt\n", + " m.estimate(method='SLSQP')\n", "req_data does not request avail_ca or avail_co but it is set and being provided\n" ] }, @@ -3221,7 +3302,7 @@ { "data": { "text/html": [ - "

Best LL = -13.427352349597697

" + "

Best LL = -13.427352167831913

" ], "text/plain": [ "" @@ -3264,476 +3345,476 @@ " \n", " \n", " coef_0_auto_household_and_escorting_tour\n", - " -289.822903\n", + " -289.819438\n", " -2.0000\n", " 0.0\n", " NaN\n", " NaN\n", " 0\n", " \n", - " -289.822903\n", + " -289.819438\n", " \n", " \n", " coef_1_escort_tour_constant\n", - " -6435.039018\n", + " -6434.961317\n", " -0.4934\n", " 0.0\n", " NaN\n", " NaN\n", " 0\n", " \n", - " -6435.039018\n", + " -6434.961317\n", " \n", " \n", " coef_1_plus_eating_out_tours_constant\n", - " -3885.458878\n", + " -3885.411913\n", " -0.0242\n", " 0.0\n", " NaN\n", " NaN\n", " 0\n", " \n", - " -3885.458878\n", + " -3885.411913\n", " \n", " \n", " coef_1_plus_maintenance_tours_constant\n", - " -1195.820538\n", + " -1195.807014\n", " -0.4344\n", " 0.0\n", " NaN\n", " NaN\n", " 0\n", " \n", - " -1195.820538\n", + " -1195.807014\n", " \n", " \n", " coef_1_plus_other_discretionary_tours_constant\n", - " -2406.835103\n", + " -2406.806121\n", " -0.2602\n", " 0.0\n", " NaN\n", " NaN\n", " 0\n", " \n", - " -2406.835103\n", + " -2406.806121\n", " \n", " \n", " coef_1_plus_shopping_tours_constant\n", - " -2389.332994\n", + " -2389.305945\n", " 0.5320\n", " 0.0\n", " NaN\n", " NaN\n", " 0\n", " \n", - " -2389.332994\n", + " -2389.305945\n", " \n", " \n", " coef_1_plus_visting_tours_constant\n", - " -2389.333045\n", + " -2389.305996\n", " 0.2367\n", " 0.0\n", " NaN\n", " NaN\n", " 0\n", " \n", - " -2389.333045\n", + " -2389.305996\n", " \n", " \n", " coef_2_plus_escort_tours_constant\n", - " -5667.753696\n", + " -5667.685401\n", " 1.4155\n", " 0.0\n", " NaN\n", " NaN\n", " 0\n", " \n", - " -5667.753696\n", + " -5667.685401\n", " \n", " \n", " coef_auto_access_to_retail_and_tour_frequency_is_5_plus\n", - " -44.188317\n", + " -44.188373\n", " 0.1004\n", " 0.0\n", " NaN\n", " NaN\n", " 0\n", " \n", - " -44.188317\n", + " -44.188373\n", " \n", " \n", " coef_car_shortage_vs_workers_and_tour_frequency_is_5_plus\n", - " -17233.038190\n", + " -17232.832071\n", " -0.6369\n", " 0.0\n", " NaN\n", " NaN\n", " 0\n", " \n", - " -17233.038190\n", + " -17232.832071\n", " \n", " \n", " coef_car_surplus_vs_workers_and_tour_frequency_is_1\n", - " -4035.668234\n", + " -4035.619542\n", " 0.2902\n", " 0.0\n", " NaN\n", " NaN\n", " 0\n", " \n", - " -4035.668234\n", + " -4035.619542\n", " \n", " \n", " coef_car_surplus_vs_workers_and_tour_frequency_is_5_plus\n", - " 15226.177337\n", + " 15225.992542\n", " 2.0352\n", " 0.0\n", " NaN\n", " NaN\n", " 0\n", " \n", - " 15226.177337\n", + " 15225.992542\n", " \n", " \n", " coef_high_income_group_and_discretionary_tour\n", - " 4481.138425\n", + " 4481.084393\n", " 2.3270\n", " 0.0\n", " NaN\n", " NaN\n", " 0\n", " \n", - " 4481.138425\n", + " 4481.084393\n", " \n", " \n", " coef_high_income_group_and_eating_out_tour\n", - " -3157.311928\n", + " -3157.273834\n", " 0.4916\n", " 0.0\n", " NaN\n", " NaN\n", " 0\n", " \n", - " -3157.311928\n", + " -3157.273834\n", " \n", " \n", " coef_high_income_group_and_maintenance_tour\n", - " 4461.536961\n", + " 4461.484862\n", " 0.3982\n", " 0.0\n", " NaN\n", " NaN\n", " 0\n", " \n", - " 4461.536961\n", + " 4461.484862\n", " \n", " \n", " coef_high_income_group_and_shopping_tour\n", - " 4461.442902\n", + " 4461.390803\n", " 0.2443\n", " 0.0\n", " NaN\n", " NaN\n", " 0\n", " \n", - " 4461.442902\n", + " 4461.390803\n", " \n", " \n", " coef_high_income_group_and_visiting_tour\n", - " 4461.442950\n", + " 4461.390852\n", " 0.2858\n", " 0.0\n", " NaN\n", " NaN\n", " 0\n", " \n", - " 4461.442950\n", + " 4461.390852\n", " \n", " \n", " coef_logged_maximum_residual_window_tour_frequency_is_1\n", - " 16.594317\n", + " 16.594329\n", " 1.3298\n", " 0.0\n", " NaN\n", " NaN\n", " 0\n", " \n", - " 16.594317\n", + " 16.594329\n", " \n", " \n", " coef_logged_maximum_residual_window_tour_frequency_is_2\n", - " -19743.176298\n", + " -19742.937757\n", " 1.3759\n", " 0.0\n", " NaN\n", " NaN\n", " 0\n", " \n", - " -19743.176298\n", + " -19742.937757\n", " \n", " \n", " coef_logged_maximum_residual_window_tour_frequency_is_5_plus\n", - " -11491.799030\n", + " -11491.665678\n", " 3.2808\n", " 0.0\n", " NaN\n", " NaN\n", " 0\n", " \n", - " -11491.799030\n", + " -11491.665678\n", " \n", " \n", " coef_mediumhigh_income_group_and_discretionary_tour\n", - " 572.853274\n", + " 572.847509\n", " 1.4050\n", " 0.0\n", " NaN\n", " NaN\n", " 0\n", " \n", - " 572.853274\n", + " 572.847509\n", " \n", " \n", " coef_mediumlow_income_group_and_discretionary_tour\n", - " -4429.995709\n", + " -4429.942211\n", " 0.9169\n", " 0.0\n", " NaN\n", " NaN\n", " 0\n", " \n", - " -4429.995709\n", + " -4429.942211\n", " \n", " \n", " coef_number_of_joint_tours_and_tour_frequency_is_1\n", - " -4180.405770\n", + " -4180.353968\n", " -0.2162\n", " 0.0\n", " NaN\n", " NaN\n", " 0\n", " \n", - " -4180.405770\n", + " -4180.353968\n", " \n", " \n", " coef_number_of_joint_tours_and_tour_frequency_is_2\n", - " -1606.522520\n", + " -1606.502880\n", " -0.3587\n", " 0.0\n", " NaN\n", " NaN\n", " 0\n", " \n", - " -1606.522520\n", + " -1606.502880\n", " \n", " \n", " coef_number_of_joint_tours_and_tour_frequency_is_3\n", - " -109.820520\n", + " -109.819329\n", " -4.2701\n", " 0.0\n", " NaN\n", " NaN\n", " 0\n", " \n", - " -109.820520\n", + " -109.819329\n", " \n", " \n", " coef_number_of_joint_tours_and_tour_frequency_is_5_plus\n", " -999.000000\n", " -999.0000\n", " 0.0\n", - " NaN\n", - " NaN\n", + " -999.0\n", + " -999.0\n", " 1\n", " \n", " -999.000000\n", " \n", " \n", " coef_number_of_mandatory_tours_and_tour_frequency_is_1\n", - " -16877.228974\n", + " -16877.023970\n", " -0.2340\n", " 0.0\n", " NaN\n", " NaN\n", " 0\n", " \n", - " -16877.228974\n", + " -16877.023970\n", " \n", " \n", " coef_number_of_mandatory_tours_and_tour_frequency_is_2\n", - " 12620.915951\n", + " 12620.764595\n", " -0.9231\n", " 0.0\n", " NaN\n", " NaN\n", " 0\n", " \n", - " 12620.915951\n", + " 12620.764595\n", " \n", " \n", " coef_number_of_mandatory_tours_and_tour_frequency_is_3\n", - " -4862.054249\n", + " -4861.997912\n", " -6.5835\n", " 0.0\n", " NaN\n", " NaN\n", " 0\n", " \n", - " -4862.054249\n", + " -4861.997912\n", " \n", " \n", " coef_presence_of_driving_school_kid_and_discretionary_tour\n", - " -578.879026\n", + " -578.872073\n", " -0.9202\n", " 0.0\n", " NaN\n", " NaN\n", " 0\n", " \n", - " -578.879026\n", + " -578.872073\n", " \n", " \n", " coef_presence_of_driving_school_kid_and_eating_out_tour\n", - " 6.381808\n", + " 6.381728\n", " -0.6377\n", " 0.0\n", " NaN\n", " NaN\n", " 0\n", " \n", - " 6.381808\n", + " 6.381728\n", " \n", " \n", " coef_presence_of_non_worker_and_tour_frequency_is_2\n", - " 878.020904\n", + " 878.008827\n", " -0.6571\n", " 0.0\n", " NaN\n", " NaN\n", " 0\n", " \n", - " 878.020904\n", + " 878.008827\n", " \n", " \n", " coef_presence_of_non_worker_and_tour_frequency_is_5\n", - " -1944.945175\n", + " -1944.922644\n", " -1.4044\n", " 0.0\n", " NaN\n", " NaN\n", " 0\n", " \n", - " -1944.945175\n", + " -1944.922644\n", " \n", " \n", " coef_presence_of_pre_driving_school_kid_and_eating_out_tour\n", - " -164.908265\n", + " -164.906255\n", " -1.5698\n", " 0.0\n", " NaN\n", " NaN\n", " 0\n", " \n", - " -164.908265\n", + " -164.906255\n", " \n", " \n", " coef_presence_of_pre_school_kid_and_eating_out_tour\n", - " 313.480011\n", + " 313.476309\n", " -0.2987\n", " 0.0\n", " NaN\n", " NaN\n", " 0\n", " \n", - " 313.480011\n", + " 313.476309\n", " \n", " \n", " coef_presence_of_predriving_school_kid_in_household_and_tour_frequency_is_1\n", - " 4033.615564\n", + " 4033.566871\n", " -0.3219\n", " 0.0\n", " NaN\n", " NaN\n", " 0\n", " \n", - " 4033.615564\n", + " 4033.566871\n", " \n", " \n", " coef_presence_of_predriving_school_kid_in_household_and_tour_frequency_is_5\n", - " 10149.453410\n", + " 10149.331976\n", " -1.0874\n", " 0.0\n", " NaN\n", " NaN\n", " 0\n", " \n", - " 10149.453410\n", + " 10149.331976\n", " \n", " \n", " coef_presence_of_university_student_and_discretionary_tour\n", - " 3906.426671\n", + " 3906.378403\n", " -1.2834\n", " 0.0\n", " NaN\n", " NaN\n", " 0\n", " \n", - " 3906.426671\n", + " 3906.378403\n", " \n", " \n", " coef_total_number_of_tours_is_1\n", - " 15200.841768\n", + " 15200.662337\n", " -7.1506\n", " 0.0\n", " NaN\n", " NaN\n", " 0\n", " \n", - " 15200.841768\n", + " 15200.662337\n", " \n", " \n", " coef_total_number_of_tours_is_2\n", - " -1638.576969\n", + " -1638.556186\n", " -11.1214\n", " 0.0\n", " NaN\n", " NaN\n", " 0\n", " \n", - " -1638.576969\n", + " -1638.556186\n", " \n", " \n", " coef_total_number_of_tours_is_3\n", - " -14010.773566\n", + " -14010.608324\n", " -13.1750\n", " 0.0\n", " NaN\n", " NaN\n", " 0\n", " \n", - " -14010.773566\n", + " -14010.608324\n", " \n", " \n", " coef_urban_and_discretionary_tour\n", " 0.000000\n", " 0.0000\n", " 0.0\n", - " NaN\n", - " NaN\n", + " 0.0\n", + " 0.0\n", " 1\n", " \n", " 0.000000\n", " \n", " \n", " coef_urban_and_maintenance_tour\n", - " -1194.346738\n", + " -1194.333214\n", " 1.0394\n", " 0.0\n", " NaN\n", " NaN\n", " 0\n", " \n", - " -1194.346738\n", + " -1194.333214\n", " \n", " \n", "\n", @@ -3741,49 +3822,49 @@ ], "text/plain": [ " value initvalue \\\n", - "coef_0_auto_household_and_escorting_tour -289.822903 -2.0000 \n", - "coef_1_escort_tour_constant -6435.039018 -0.4934 \n", - "coef_1_plus_eating_out_tours_constant -3885.458878 -0.0242 \n", - "coef_1_plus_maintenance_tours_constant -1195.820538 -0.4344 \n", - "coef_1_plus_other_discretionary_tours_constant -2406.835103 -0.2602 \n", - "coef_1_plus_shopping_tours_constant -2389.332994 0.5320 \n", - "coef_1_plus_visting_tours_constant -2389.333045 0.2367 \n", - "coef_2_plus_escort_tours_constant -5667.753696 1.4155 \n", - "coef_auto_access_to_retail_and_tour_frequency_i... -44.188317 0.1004 \n", - "coef_car_shortage_vs_workers_and_tour_frequency... -17233.038190 -0.6369 \n", - "coef_car_surplus_vs_workers_and_tour_frequency_... -4035.668234 0.2902 \n", - "coef_car_surplus_vs_workers_and_tour_frequency_... 15226.177337 2.0352 \n", - "coef_high_income_group_and_discretionary_tour 4481.138425 2.3270 \n", - "coef_high_income_group_and_eating_out_tour -3157.311928 0.4916 \n", - "coef_high_income_group_and_maintenance_tour 4461.536961 0.3982 \n", - "coef_high_income_group_and_shopping_tour 4461.442902 0.2443 \n", - "coef_high_income_group_and_visiting_tour 4461.442950 0.2858 \n", - "coef_logged_maximum_residual_window_tour_freque... 16.594317 1.3298 \n", - "coef_logged_maximum_residual_window_tour_freque... -19743.176298 1.3759 \n", - "coef_logged_maximum_residual_window_tour_freque... -11491.799030 3.2808 \n", - "coef_mediumhigh_income_group_and_discretionary_... 572.853274 1.4050 \n", - "coef_mediumlow_income_group_and_discretionary_tour -4429.995709 0.9169 \n", - "coef_number_of_joint_tours_and_tour_frequency_is_1 -4180.405770 -0.2162 \n", - "coef_number_of_joint_tours_and_tour_frequency_is_2 -1606.522520 -0.3587 \n", - "coef_number_of_joint_tours_and_tour_frequency_is_3 -109.820520 -4.2701 \n", + "coef_0_auto_household_and_escorting_tour -289.819438 -2.0000 \n", + "coef_1_escort_tour_constant -6434.961317 -0.4934 \n", + "coef_1_plus_eating_out_tours_constant -3885.411913 -0.0242 \n", + "coef_1_plus_maintenance_tours_constant -1195.807014 -0.4344 \n", + "coef_1_plus_other_discretionary_tours_constant -2406.806121 -0.2602 \n", + "coef_1_plus_shopping_tours_constant -2389.305945 0.5320 \n", + "coef_1_plus_visting_tours_constant -2389.305996 0.2367 \n", + "coef_2_plus_escort_tours_constant -5667.685401 1.4155 \n", + "coef_auto_access_to_retail_and_tour_frequency_i... -44.188373 0.1004 \n", + "coef_car_shortage_vs_workers_and_tour_frequency... -17232.832071 -0.6369 \n", + "coef_car_surplus_vs_workers_and_tour_frequency_... -4035.619542 0.2902 \n", + "coef_car_surplus_vs_workers_and_tour_frequency_... 15225.992542 2.0352 \n", + "coef_high_income_group_and_discretionary_tour 4481.084393 2.3270 \n", + "coef_high_income_group_and_eating_out_tour -3157.273834 0.4916 \n", + "coef_high_income_group_and_maintenance_tour 4461.484862 0.3982 \n", + "coef_high_income_group_and_shopping_tour 4461.390803 0.2443 \n", + "coef_high_income_group_and_visiting_tour 4461.390852 0.2858 \n", + "coef_logged_maximum_residual_window_tour_freque... 16.594329 1.3298 \n", + "coef_logged_maximum_residual_window_tour_freque... -19742.937757 1.3759 \n", + "coef_logged_maximum_residual_window_tour_freque... -11491.665678 3.2808 \n", + "coef_mediumhigh_income_group_and_discretionary_... 572.847509 1.4050 \n", + "coef_mediumlow_income_group_and_discretionary_tour -4429.942211 0.9169 \n", + "coef_number_of_joint_tours_and_tour_frequency_is_1 -4180.353968 -0.2162 \n", + "coef_number_of_joint_tours_and_tour_frequency_is_2 -1606.502880 -0.3587 \n", + "coef_number_of_joint_tours_and_tour_frequency_is_3 -109.819329 -4.2701 \n", "coef_number_of_joint_tours_and_tour_frequency_i... -999.000000 -999.0000 \n", - "coef_number_of_mandatory_tours_and_tour_frequen... -16877.228974 -0.2340 \n", - "coef_number_of_mandatory_tours_and_tour_frequen... 12620.915951 -0.9231 \n", - "coef_number_of_mandatory_tours_and_tour_frequen... -4862.054249 -6.5835 \n", - "coef_presence_of_driving_school_kid_and_discret... -578.879026 -0.9202 \n", - "coef_presence_of_driving_school_kid_and_eating_... 6.381808 -0.6377 \n", - "coef_presence_of_non_worker_and_tour_frequency_... 878.020904 -0.6571 \n", - "coef_presence_of_non_worker_and_tour_frequency_... -1944.945175 -1.4044 \n", - "coef_presence_of_pre_driving_school_kid_and_eat... -164.908265 -1.5698 \n", - "coef_presence_of_pre_school_kid_and_eating_out_... 313.480011 -0.2987 \n", - "coef_presence_of_predriving_school_kid_in_house... 4033.615564 -0.3219 \n", - "coef_presence_of_predriving_school_kid_in_house... 10149.453410 -1.0874 \n", - "coef_presence_of_university_student_and_discret... 3906.426671 -1.2834 \n", - "coef_total_number_of_tours_is_1 15200.841768 -7.1506 \n", - "coef_total_number_of_tours_is_2 -1638.576969 -11.1214 \n", - "coef_total_number_of_tours_is_3 -14010.773566 -13.1750 \n", + "coef_number_of_mandatory_tours_and_tour_frequen... -16877.023970 -0.2340 \n", + "coef_number_of_mandatory_tours_and_tour_frequen... 12620.764595 -0.9231 \n", + "coef_number_of_mandatory_tours_and_tour_frequen... -4861.997912 -6.5835 \n", + "coef_presence_of_driving_school_kid_and_discret... -578.872073 -0.9202 \n", + "coef_presence_of_driving_school_kid_and_eating_... 6.381728 -0.6377 \n", + "coef_presence_of_non_worker_and_tour_frequency_... 878.008827 -0.6571 \n", + "coef_presence_of_non_worker_and_tour_frequency_... -1944.922644 -1.4044 \n", + "coef_presence_of_pre_driving_school_kid_and_eat... -164.906255 -1.5698 \n", + "coef_presence_of_pre_school_kid_and_eating_out_... 313.476309 -0.2987 \n", + "coef_presence_of_predriving_school_kid_in_house... 4033.566871 -0.3219 \n", + "coef_presence_of_predriving_school_kid_in_house... 10149.331976 -1.0874 \n", + "coef_presence_of_university_student_and_discret... 3906.378403 -1.2834 \n", + "coef_total_number_of_tours_is_1 15200.662337 -7.1506 \n", + "coef_total_number_of_tours_is_2 -1638.556186 -11.1214 \n", + "coef_total_number_of_tours_is_3 -14010.608324 -13.1750 \n", "coef_urban_and_discretionary_tour 0.000000 0.0000 \n", - "coef_urban_and_maintenance_tour -1194.346738 1.0394 \n", + "coef_urban_and_maintenance_tour -1194.333214 1.0394 \n", "\n", " nullvalue minimum \\\n", "coef_0_auto_household_and_escorting_tour 0.0 NaN \n", @@ -3811,7 +3892,7 @@ "coef_number_of_joint_tours_and_tour_frequency_is_1 0.0 NaN \n", "coef_number_of_joint_tours_and_tour_frequency_is_2 0.0 NaN \n", "coef_number_of_joint_tours_and_tour_frequency_is_3 0.0 NaN \n", - "coef_number_of_joint_tours_and_tour_frequency_i... 0.0 NaN \n", + "coef_number_of_joint_tours_and_tour_frequency_i... 0.0 -999.0 \n", "coef_number_of_mandatory_tours_and_tour_frequen... 0.0 NaN \n", "coef_number_of_mandatory_tours_and_tour_frequen... 0.0 NaN \n", "coef_number_of_mandatory_tours_and_tour_frequen... 0.0 NaN \n", @@ -3827,7 +3908,7 @@ "coef_total_number_of_tours_is_1 0.0 NaN \n", "coef_total_number_of_tours_is_2 0.0 NaN \n", "coef_total_number_of_tours_is_3 0.0 NaN \n", - "coef_urban_and_discretionary_tour 0.0 NaN \n", + "coef_urban_and_discretionary_tour 0.0 0.0 \n", "coef_urban_and_maintenance_tour 0.0 NaN \n", "\n", " maximum holdfast note \\\n", @@ -3856,7 +3937,7 @@ "coef_number_of_joint_tours_and_tour_frequency_is_1 NaN 0 \n", "coef_number_of_joint_tours_and_tour_frequency_is_2 NaN 0 \n", "coef_number_of_joint_tours_and_tour_frequency_is_3 NaN 0 \n", - "coef_number_of_joint_tours_and_tour_frequency_i... NaN 1 \n", + "coef_number_of_joint_tours_and_tour_frequency_i... -999.0 1 \n", "coef_number_of_mandatory_tours_and_tour_frequen... NaN 0 \n", "coef_number_of_mandatory_tours_and_tour_frequen... NaN 0 \n", "coef_number_of_mandatory_tours_and_tour_frequen... NaN 0 \n", @@ -3872,53 +3953,53 @@ "coef_total_number_of_tours_is_1 NaN 0 \n", "coef_total_number_of_tours_is_2 NaN 0 \n", "coef_total_number_of_tours_is_3 NaN 0 \n", - "coef_urban_and_discretionary_tour NaN 1 \n", + "coef_urban_and_discretionary_tour 0.0 1 \n", "coef_urban_and_maintenance_tour NaN 0 \n", "\n", " best \n", - "coef_0_auto_household_and_escorting_tour -289.822903 \n", - "coef_1_escort_tour_constant -6435.039018 \n", - "coef_1_plus_eating_out_tours_constant -3885.458878 \n", - "coef_1_plus_maintenance_tours_constant -1195.820538 \n", - "coef_1_plus_other_discretionary_tours_constant -2406.835103 \n", - "coef_1_plus_shopping_tours_constant -2389.332994 \n", - "coef_1_plus_visting_tours_constant -2389.333045 \n", - "coef_2_plus_escort_tours_constant -5667.753696 \n", - "coef_auto_access_to_retail_and_tour_frequency_i... -44.188317 \n", - "coef_car_shortage_vs_workers_and_tour_frequency... -17233.038190 \n", - "coef_car_surplus_vs_workers_and_tour_frequency_... -4035.668234 \n", - "coef_car_surplus_vs_workers_and_tour_frequency_... 15226.177337 \n", - "coef_high_income_group_and_discretionary_tour 4481.138425 \n", - "coef_high_income_group_and_eating_out_tour -3157.311928 \n", - "coef_high_income_group_and_maintenance_tour 4461.536961 \n", - "coef_high_income_group_and_shopping_tour 4461.442902 \n", - "coef_high_income_group_and_visiting_tour 4461.442950 \n", - "coef_logged_maximum_residual_window_tour_freque... 16.594317 \n", - "coef_logged_maximum_residual_window_tour_freque... -19743.176298 \n", - "coef_logged_maximum_residual_window_tour_freque... -11491.799030 \n", - "coef_mediumhigh_income_group_and_discretionary_... 572.853274 \n", - "coef_mediumlow_income_group_and_discretionary_tour -4429.995709 \n", - "coef_number_of_joint_tours_and_tour_frequency_is_1 -4180.405770 \n", - "coef_number_of_joint_tours_and_tour_frequency_is_2 -1606.522520 \n", - "coef_number_of_joint_tours_and_tour_frequency_is_3 -109.820520 \n", + "coef_0_auto_household_and_escorting_tour -289.819438 \n", + "coef_1_escort_tour_constant -6434.961317 \n", + "coef_1_plus_eating_out_tours_constant -3885.411913 \n", + "coef_1_plus_maintenance_tours_constant -1195.807014 \n", + "coef_1_plus_other_discretionary_tours_constant -2406.806121 \n", + "coef_1_plus_shopping_tours_constant -2389.305945 \n", + "coef_1_plus_visting_tours_constant -2389.305996 \n", + "coef_2_plus_escort_tours_constant -5667.685401 \n", + "coef_auto_access_to_retail_and_tour_frequency_i... -44.188373 \n", + "coef_car_shortage_vs_workers_and_tour_frequency... -17232.832071 \n", + "coef_car_surplus_vs_workers_and_tour_frequency_... -4035.619542 \n", + "coef_car_surplus_vs_workers_and_tour_frequency_... 15225.992542 \n", + "coef_high_income_group_and_discretionary_tour 4481.084393 \n", + "coef_high_income_group_and_eating_out_tour -3157.273834 \n", + "coef_high_income_group_and_maintenance_tour 4461.484862 \n", + "coef_high_income_group_and_shopping_tour 4461.390803 \n", + "coef_high_income_group_and_visiting_tour 4461.390852 \n", + "coef_logged_maximum_residual_window_tour_freque... 16.594329 \n", + "coef_logged_maximum_residual_window_tour_freque... -19742.937757 \n", + "coef_logged_maximum_residual_window_tour_freque... -11491.665678 \n", + "coef_mediumhigh_income_group_and_discretionary_... 572.847509 \n", + "coef_mediumlow_income_group_and_discretionary_tour -4429.942211 \n", + "coef_number_of_joint_tours_and_tour_frequency_is_1 -4180.353968 \n", + "coef_number_of_joint_tours_and_tour_frequency_is_2 -1606.502880 \n", + "coef_number_of_joint_tours_and_tour_frequency_is_3 -109.819329 \n", "coef_number_of_joint_tours_and_tour_frequency_i... -999.000000 \n", - "coef_number_of_mandatory_tours_and_tour_frequen... -16877.228974 \n", - "coef_number_of_mandatory_tours_and_tour_frequen... 12620.915951 \n", - "coef_number_of_mandatory_tours_and_tour_frequen... -4862.054249 \n", - "coef_presence_of_driving_school_kid_and_discret... -578.879026 \n", - "coef_presence_of_driving_school_kid_and_eating_... 6.381808 \n", - "coef_presence_of_non_worker_and_tour_frequency_... 878.020904 \n", - "coef_presence_of_non_worker_and_tour_frequency_... -1944.945175 \n", - "coef_presence_of_pre_driving_school_kid_and_eat... -164.908265 \n", - "coef_presence_of_pre_school_kid_and_eating_out_... 313.480011 \n", - "coef_presence_of_predriving_school_kid_in_house... 4033.615564 \n", - "coef_presence_of_predriving_school_kid_in_house... 10149.453410 \n", - "coef_presence_of_university_student_and_discret... 3906.426671 \n", - "coef_total_number_of_tours_is_1 15200.841768 \n", - "coef_total_number_of_tours_is_2 -1638.576969 \n", - "coef_total_number_of_tours_is_3 -14010.773566 \n", + "coef_number_of_mandatory_tours_and_tour_frequen... -16877.023970 \n", + "coef_number_of_mandatory_tours_and_tour_frequen... 12620.764595 \n", + "coef_number_of_mandatory_tours_and_tour_frequen... -4861.997912 \n", + "coef_presence_of_driving_school_kid_and_discret... -578.872073 \n", + "coef_presence_of_driving_school_kid_and_eating_... 6.381728 \n", + "coef_presence_of_non_worker_and_tour_frequency_... 878.008827 \n", + "coef_presence_of_non_worker_and_tour_frequency_... -1944.922644 \n", + "coef_presence_of_pre_driving_school_kid_and_eat... -164.906255 \n", + "coef_presence_of_pre_school_kid_and_eating_out_... 313.476309 \n", + "coef_presence_of_predriving_school_kid_in_house... 4033.566871 \n", + "coef_presence_of_predriving_school_kid_in_house... 10149.331976 \n", + "coef_presence_of_university_student_and_discret... 3906.378403 \n", + "coef_total_number_of_tours_is_1 15200.662337 \n", + "coef_total_number_of_tours_is_2 -1638.556186 \n", + "coef_total_number_of_tours_is_3 -14010.608324 \n", "coef_urban_and_discretionary_tour 0.000000 \n", - "coef_urban_and_maintenance_tour -1194.346738 " + "coef_urban_and_maintenance_tour -1194.333214 " ] }, "metadata": {}, @@ -3928,11 +4009,18 @@ "name": "stderr", "output_type": "stream", "text": [ - ":2: PossibleOverspecification: WARNING: Model is possibly over-specified (hessian is nearly singular).\n", + "/var/folders/js/bk_dt9015j79_f6bxnc44dsr0000gp/T/ipykernel_48972/89088409.py:2: PossibleOverspecification: WARNING: Model is possibly over-specified (hessian is nearly singular).\n", " m.estimate(method='SLSQP')\n", - "/Users/jeffnewman/OneDrive - Cambridge Systematics/Git/larch/larch/linalg/__init__.py:18: UserWarning: minimum eig 0.0 in general_inverse\n", + "/Users/jeffnewman/LocalGit/asim-larch/activitysim-larch/conda-environments/AL-ENV/lib/python3.9/site-packages/larch/linalg/__init__.py:18: UserWarning: minimum eig 0.0 in general_inverse\n", " warnings.warn(f\"minimum eig {min_eig} in general_inverse\")\n", - ":2: RuntimeWarning: invalid value encountered in sqrt\n", + "/var/folders/js/bk_dt9015j79_f6bxnc44dsr0000gp/T/ipykernel_48972/89088409.py:2: PossibleOverspecification: WARNING: Model seems to have 14 parameter estimators with negative variance\n", + "- coef_1_plus_maintenance_tours_constant\n", + "- coef_1_plus_other_discretionary_tours_constant\n", + "- coef_1_plus_shopping_tours_constant\n", + "- coef_1_plus_visting_tours_constant\n", + "- and 10 more\n", + " m.estimate(method='SLSQP')\n", + "/var/folders/js/bk_dt9015j79_f6bxnc44dsr0000gp/T/ipykernel_48972/89088409.py:2: RuntimeWarning: invalid value encountered in sqrt\n", " m.estimate(method='SLSQP')\n", "req_data does not request avail_ca or avail_co but it is set and being provided\n" ] @@ -3952,7 +4040,7 @@ { "data": { "text/html": [ - "

Best LL = -256.78783280769073

" + "

Best LL = -256.78783276592117

" ], "text/plain": [ "" @@ -3998,8 +4086,8 @@ " -2.000000\n", " -2.0000\n", " 0.0\n", - " NaN\n", - " NaN\n", + " -2.0\n", + " -2.0\n", " 1\n", " \n", " -2.000000\n", @@ -4116,14 +4204,14 @@ " \n", " \n", " coef_high_income_group_and_tour_frequency_is_5_plus\n", - " 16.017263\n", + " 16.017262\n", " 2.0175\n", " 0.0\n", " NaN\n", " NaN\n", " 0\n", " \n", - " 16.017263\n", + " 16.017262\n", " \n", " \n", " coef_logged_maximum_residual_window_tour_frequency_is_5_plus\n", @@ -4185,22 +4273,22 @@ " -999.000000\n", " -999.0000\n", " 0.0\n", - " NaN\n", - " NaN\n", + " -999.0\n", + " -999.0\n", " 1\n", " \n", " -999.000000\n", " \n", " \n", " coef_number_of_mandatory_tours_and_tour_frequency_is_1\n", - " -9.889680\n", + " -9.889679\n", " -1.0331\n", " 0.0\n", " NaN\n", " NaN\n", " 0\n", " \n", - " -9.889680\n", + " -9.889679\n", " \n", " \n", " coef_number_of_mandatory_tours_and_tour_frequency_is_3\n", @@ -4339,8 +4427,8 @@ " 0.000000\n", " 0.0000\n", " 0.0\n", - " NaN\n", - " NaN\n", + " 0.0\n", + " 0.0\n", " 1\n", " \n", " 0.000000\n", @@ -4384,14 +4472,14 @@ "coef_auto_access_to_retail_and_escorting 0.555108 0.0629 \n", "coef_high_income_group_and_eating_out_tour -1.361980 -0.7010 \n", "coef_high_income_group_and_shopping_tour -3.736670 -0.6506 \n", - "coef_high_income_group_and_tour_frequency_is_5_... 16.017263 2.0175 \n", + "coef_high_income_group_and_tour_frequency_is_5_... 16.017262 2.0175 \n", "coef_logged_maximum_residual_window_tour_freque... 1.526025 1.5603 \n", "coef_mediumhigh_income_group_and_tour_frequency... 15.096814 1.5197 \n", "coef_mediumlow_income_group_and_tour_frequency_... 14.227759 1.0873 \n", "coef_number_of_joint_maintenance_tours -1.347600 -1.3476 \n", "coef_number_of_joint_tours_and_tour_frequency_is_2 -1.197115 -0.6149 \n", "coef_number_of_joint_tours_and_tour_frequency_i... -999.000000 -999.0000 \n", - "coef_number_of_mandatory_tours_and_tour_frequen... -9.889680 -1.0331 \n", + "coef_number_of_mandatory_tours_and_tour_frequen... -9.889679 -1.0331 \n", "coef_number_of_mandatory_tours_and_tour_frequen... -10.675107 -2.7445 \n", "coef_presence_of_full_time_worker_and_discretio... 0.167217 0.7526 \n", "coef_presence_of_non_worker_and_eating_out_tour -1.295662 -1.3074 \n", @@ -4409,7 +4497,7 @@ "coef_walk_access_to_retail_and_eating_out 0.400103 0.0738 \n", "\n", " nullvalue minimum \\\n", - "coef_0_auto_household_and_escorting_tour 0.0 NaN \n", + "coef_0_auto_household_and_escorting_tour 0.0 -2.0 \n", "coef_1_escort_tour_constant 0.0 NaN \n", "coef_1_plus_eating_out_tours_constant 0.0 NaN \n", "coef_1_plus_maintenance_tours_constant 0.0 NaN \n", @@ -4426,7 +4514,7 @@ "coef_mediumlow_income_group_and_tour_frequency_... 0.0 NaN \n", "coef_number_of_joint_maintenance_tours 0.0 NaN \n", "coef_number_of_joint_tours_and_tour_frequency_is_2 0.0 NaN \n", - "coef_number_of_joint_tours_and_tour_frequency_i... 0.0 NaN \n", + "coef_number_of_joint_tours_and_tour_frequency_i... 0.0 -999.0 \n", "coef_number_of_mandatory_tours_and_tour_frequen... 0.0 NaN \n", "coef_number_of_mandatory_tours_and_tour_frequen... 0.0 NaN \n", "coef_presence_of_full_time_worker_and_discretio... 0.0 NaN \n", @@ -4440,12 +4528,12 @@ "coef_total_number_of_tours_is_1 0.0 NaN \n", "coef_total_number_of_tours_is_2 0.0 NaN \n", "coef_total_number_of_tours_is_3 0.0 NaN \n", - "coef_urban_and_discretionary_tour 0.0 NaN \n", + "coef_urban_and_discretionary_tour 0.0 0.0 \n", "coef_urban_and_escorting_tour 0.0 NaN \n", "coef_walk_access_to_retail_and_eating_out 0.0 NaN \n", "\n", " maximum holdfast note \\\n", - "coef_0_auto_household_and_escorting_tour NaN 1 \n", + "coef_0_auto_household_and_escorting_tour -2.0 1 \n", "coef_1_escort_tour_constant NaN 0 \n", "coef_1_plus_eating_out_tours_constant NaN 0 \n", "coef_1_plus_maintenance_tours_constant NaN 0 \n", @@ -4462,7 +4550,7 @@ "coef_mediumlow_income_group_and_tour_frequency_... NaN 0 \n", "coef_number_of_joint_maintenance_tours NaN 0 \n", "coef_number_of_joint_tours_and_tour_frequency_is_2 NaN 0 \n", - "coef_number_of_joint_tours_and_tour_frequency_i... NaN 1 \n", + "coef_number_of_joint_tours_and_tour_frequency_i... -999.0 1 \n", "coef_number_of_mandatory_tours_and_tour_frequen... NaN 0 \n", "coef_number_of_mandatory_tours_and_tour_frequen... NaN 0 \n", "coef_presence_of_full_time_worker_and_discretio... NaN 0 \n", @@ -4476,7 +4564,7 @@ "coef_total_number_of_tours_is_1 NaN 0 \n", "coef_total_number_of_tours_is_2 NaN 0 \n", "coef_total_number_of_tours_is_3 NaN 0 \n", - "coef_urban_and_discretionary_tour NaN 1 \n", + "coef_urban_and_discretionary_tour 0.0 1 \n", "coef_urban_and_escorting_tour NaN 0 \n", "coef_walk_access_to_retail_and_eating_out NaN 0 \n", "\n", @@ -4492,14 +4580,14 @@ "coef_auto_access_to_retail_and_escorting 0.555108 \n", "coef_high_income_group_and_eating_out_tour -1.361980 \n", "coef_high_income_group_and_shopping_tour -3.736670 \n", - "coef_high_income_group_and_tour_frequency_is_5_... 16.017263 \n", + "coef_high_income_group_and_tour_frequency_is_5_... 16.017262 \n", "coef_logged_maximum_residual_window_tour_freque... 1.526025 \n", "coef_mediumhigh_income_group_and_tour_frequency... 15.096814 \n", "coef_mediumlow_income_group_and_tour_frequency_... 14.227759 \n", "coef_number_of_joint_maintenance_tours -1.347600 \n", "coef_number_of_joint_tours_and_tour_frequency_is_2 -1.197115 \n", "coef_number_of_joint_tours_and_tour_frequency_i... -999.000000 \n", - "coef_number_of_mandatory_tours_and_tour_frequen... -9.889680 \n", + "coef_number_of_mandatory_tours_and_tour_frequen... -9.889679 \n", "coef_number_of_mandatory_tours_and_tour_frequen... -10.675107 \n", "coef_presence_of_full_time_worker_and_discretio... 0.167217 \n", "coef_presence_of_non_worker_and_eating_out_tour -1.295662 \n", @@ -4524,11 +4612,16 @@ "name": "stderr", "output_type": "stream", "text": [ - ":2: PossibleOverspecification: WARNING: Model is possibly over-specified (hessian is nearly singular).\n", + "/var/folders/js/bk_dt9015j79_f6bxnc44dsr0000gp/T/ipykernel_48972/89088409.py:2: PossibleOverspecification: WARNING: Model is possibly over-specified (hessian is nearly singular).\n", " m.estimate(method='SLSQP')\n", - "/Users/jeffnewman/OneDrive - Cambridge Systematics/Git/larch/larch/linalg/__init__.py:18: UserWarning: minimum eig 2.618193006591901e-16 in general_inverse\n", + "/Users/jeffnewman/LocalGit/asim-larch/activitysim-larch/conda-environments/AL-ENV/lib/python3.9/site-packages/larch/linalg/__init__.py:18: UserWarning: minimum eig 3.064162929131762e-17 in general_inverse\n", " warnings.warn(f\"minimum eig {min_eig} in general_inverse\")\n", - ":2: RuntimeWarning: invalid value encountered in sqrt\n", + "/var/folders/js/bk_dt9015j79_f6bxnc44dsr0000gp/T/ipykernel_48972/89088409.py:2: PossibleOverspecification: WARNING: Model seems to have 3 parameter estimators with negative variance\n", + "- coef_1_escort_tour_constant\n", + "- coef_2_plus_escort_tours_constant\n", + "- coef_urban_and_escorting_tour\n", + " m.estimate(method='SLSQP')\n", + "/var/folders/js/bk_dt9015j79_f6bxnc44dsr0000gp/T/ipykernel_48972/89088409.py:2: RuntimeWarning: invalid value encountered in sqrt\n", " m.estimate(method='SLSQP')\n", "req_data does not request avail_ca or avail_co but it is set and being provided\n" ] @@ -4548,7 +4641,7 @@ { "data": { "text/html": [ - "

Best LL = -225.00971520122775

" + "

Best LL = -225.00971520122772

" ], "text/plain": [ "" @@ -4594,8 +4687,8 @@ " -2.000000\n", " -2.0000\n", " 0.0\n", - " NaN\n", - " NaN\n", + " -2.0\n", + " -2.0\n", " 1\n", " \n", " -2.000000\n", @@ -4836,8 +4929,8 @@ " -999.000000\n", " -999.0000\n", " 0.0\n", - " NaN\n", - " NaN\n", + " -999.0\n", + " -999.0\n", " 1\n", " \n", " -999.000000\n", @@ -4847,8 +4940,8 @@ " 0.000000\n", " 0.0000\n", " 0.0\n", - " NaN\n", - " NaN\n", + " 0.0\n", + " 0.0\n", " 1\n", " \n", " 0.000000\n", @@ -4897,7 +4990,7 @@ "coef_visiting_or_social_tour 0.315314 0.7690 \n", "\n", " nullvalue minimum \\\n", - "coef_0_auto_household_and_escorting_tour 0.0 NaN \n", + "coef_0_auto_household_and_escorting_tour 0.0 -2.0 \n", "coef_1_escort_tour_constant 0.0 NaN \n", "coef_1_plus_eating_out_tours_constant 0.0 NaN \n", "coef_1_plus_maintenance_tours_constant 0.0 NaN \n", @@ -4919,12 +5012,12 @@ "coef_total_number_of_tours_is_2 0.0 NaN \n", "coef_total_number_of_tours_is_3 0.0 NaN \n", "coef_total_number_of_tours_is_4 0.0 NaN \n", - "coef_total_number_of_tours_is_6_plus 0.0 NaN \n", - "coef_urban_and_discretionary_tour 0.0 NaN \n", + "coef_total_number_of_tours_is_6_plus 0.0 -999.0 \n", + "coef_urban_and_discretionary_tour 0.0 0.0 \n", "coef_visiting_or_social_tour 0.0 NaN \n", "\n", " maximum holdfast note \\\n", - "coef_0_auto_household_and_escorting_tour NaN 1 \n", + "coef_0_auto_household_and_escorting_tour -2.0 1 \n", "coef_1_escort_tour_constant NaN 0 \n", "coef_1_plus_eating_out_tours_constant NaN 0 \n", "coef_1_plus_maintenance_tours_constant NaN 0 \n", @@ -4946,8 +5039,8 @@ "coef_total_number_of_tours_is_2 NaN 0 \n", "coef_total_number_of_tours_is_3 NaN 0 \n", "coef_total_number_of_tours_is_4 NaN 0 \n", - "coef_total_number_of_tours_is_6_plus NaN 1 \n", - "coef_urban_and_discretionary_tour NaN 1 \n", + "coef_total_number_of_tours_is_6_plus -999.0 1 \n", + "coef_urban_and_discretionary_tour 0.0 1 \n", "coef_visiting_or_social_tour NaN 0 \n", "\n", " best \n", @@ -4985,11 +5078,18 @@ "name": "stderr", "output_type": "stream", "text": [ - ":2: PossibleOverspecification: WARNING: Model is possibly over-specified (hessian is nearly singular).\n", + "/var/folders/js/bk_dt9015j79_f6bxnc44dsr0000gp/T/ipykernel_48972/89088409.py:2: PossibleOverspecification: WARNING: Model is possibly over-specified (hessian is nearly singular).\n", " m.estimate(method='SLSQP')\n", - "/Users/jeffnewman/OneDrive - Cambridge Systematics/Git/larch/larch/linalg/__init__.py:18: UserWarning: minimum eig 1.954982550090504e-08 in general_inverse\n", + "/Users/jeffnewman/LocalGit/asim-larch/activitysim-larch/conda-environments/AL-ENV/lib/python3.9/site-packages/larch/linalg/__init__.py:18: UserWarning: minimum eig 2.8528068249273466e-08 in general_inverse\n", " warnings.warn(f\"minimum eig {min_eig} in general_inverse\")\n", - ":2: RuntimeWarning: invalid value encountered in sqrt\n", + "/var/folders/js/bk_dt9015j79_f6bxnc44dsr0000gp/T/ipykernel_48972/89088409.py:2: PossibleOverspecification: WARNING: Model seems to have 14 parameter estimators with negative variance\n", + "- coef_1_escort_tour_constant\n", + "- coef_1_plus_eating_out_tours_constant\n", + "- coef_1_plus_maintenance_tours_constant\n", + "- coef_1_plus_shopping_tours_constant\n", + "- and 10 more\n", + " m.estimate(method='SLSQP')\n", + "/var/folders/js/bk_dt9015j79_f6bxnc44dsr0000gp/T/ipykernel_48972/89088409.py:2: RuntimeWarning: invalid value encountered in sqrt\n", " m.estimate(method='SLSQP')\n" ] } @@ -5008,749 +5108,767 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/html": [ - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
Value Std Err t Stat Signif Like Ratio Null Value Constrained
coef_0_auto_household_and_escorting_tour-2.00 NA NA NA 0.00fixed value
coef_1_escort_tour_constant 0.319 362. 0.00 NA 0.00
coef_1_plus_eating_out_tours_constant-1.01 143.-0.01 NA 0.00
coef_1_plus_maintenance_tours_constant-2.84 143.-0.02 NA 0.00
coef_1_plus_other_discretionary_tours_constant 10.5 144. 0.07 NA 0.00
coef_1_plus_shopping_tours_constant 7.18 143. 0.05 NA 0.00
coef_1_plus_visting_tours_constant-0.321 143.-0.00 NA 0.00
coef_2_plus_escort_tours_constant 0.607 725. 0.00 NA 0.00
coef_at_home_pre_driving_school_kid_and_escorting_tour-0.926 1.05-0.89 NA 0.00
coef_at_home_pre_school_kid_and_discretionary_tour-0.656 0.743-0.88 NA 0.00
coef_at_home_pre_school_kid_and_escorting_tour-0.793 0.821-0.97 NA 0.00
coef_auto_access_to_retail_and_discretionary-1.05 0.955-1.10 NA 0.00
coef_auto_access_to_retail_and_maintenance 0.279 0.886 0.31 NA 0.00
coef_auto_access_to_retail_and_shopping-0.631 0.855-0.74 NA 0.00
coef_car_surplus_vs_workers_and_tour_frequency_is_5_plus 0.168 0.233 0.72 NA 0.00
coef_female_and_escorting_tour 0.601 0.266 2.26* NA 0.00
coef_female_and_tour_frequency_is_1-0.316 0.137-2.31* NA 0.00
coef_female_and_tour_frequency_is_2-0.583 0.277-2.11* NA 0.00
coef_female_and_tour_frequency_is_5 0.0227 0.671 0.03 NA 0.00
coef_high_income_group_and_discretionary_tour-0.0604 0.241-0.25 NA 0.00
coef_high_income_group_and_eating_out_tour 0.726 0.282 2.58** NA 0.00
coef_high_income_group_and_tour_frequency_is_1 1.14 0.408 2.79** NA 0.00
coef_high_income_group_and_tour_frequency_is_2 2.22 0.869 2.55* NA 0.00
coef_high_income_group_and_tour_frequency_is_5_plus 0.105 1.42 0.07 NA 0.00
coef_high_income_group_and_visiting_tour-0.863 0.350-2.46* NA 0.00
coef_logged_maximum_residual_window_tour_frequency_is_1 1.34 0.232 5.76*** NA 0.00
coef_logged_maximum_residual_window_tour_frequency_is_2 1.43 0.289 4.94*** NA 0.00
coef_logged_maximum_residual_window_tour_frequency_is_5_plus 0.640 1.09 0.59 NA 0.00
coef_mediumhigh_income_group_and_tour_frequency_is_1 1.09 0.394 2.77** NA 0.00
coef_mediumhigh_income_group_and_tour_frequency_is_2 1.81 0.850 2.13* NA 0.00
coef_mediumhigh_income_group_and_tour_frequency_is_5_plus 1.04 1.25 0.83 NA 0.00
coef_number_of_joint_eating_out_tours-9.98 147.-0.07 NA 0.00
coef_number_of_mandatory_tours_and_tour_frequency_is_2-1.43 0.489-2.93** NA 0.00
coef_number_of_mandatory_tours_and_tour_frequency_is_5_plus-1.64 2.28-0.72 NA 0.00
coef_presence_of_driving_school_kid_and_discretionary_tour 0.384 0.452 0.85 NA 0.00
coef_presence_of_driving_school_kid_and_escorting_tour-0.211 0.529-0.40 NA 0.00
coef_presence_of_full_time_worker_and_discretionary_tour-0.783 0.222-3.53*** NA 0.00
coef_presence_of_full_time_worker_and_eating_out_tour-0.748 0.221-3.38*** NA 0.00
coef_presence_of_full_time_worker_and_maintenance_tour-0.342 0.271-1.27 NA 0.00
coef_presence_of_full_time_worker_and_shopping_tour-0.631 0.190-3.32*** NA 0.00
coef_presence_of_non_worker_and_discretionary_tour-1.27 0.384-3.30*** NA 0.00
coef_presence_of_non_worker_and_eating_out_tour-0.445 0.327-1.36 NA 0.00
coef_presence_of_non_worker_and_escorting_tour-0.854 0.404-2.11* NA 0.00
coef_presence_of_non_worker_and_maintenance_tour-0.209 0.364-0.58 NA 0.00
coef_presence_of_non_worker_and_shopping_tour-0.844 0.301-2.80** NA 0.00
coef_presence_of_part_time_worker_and_discretionary_tour-0.0412 0.265-0.16 NA 0.00
coef_presence_of_part_time_worker_and_maintenance_tour-0.183 0.328-0.56 NA 0.00
coef_presence_of_part_time_worker_and_shopping_tour-0.149 0.224-0.66 NA 0.00
coef_presence_of_pre_driving_school_kid_and_discretionary_tour-0.126 0.314-0.40 NA 0.00
coef_presence_of_pre_driving_school_kid_and_escorting_tour 1.40 0.268 5.23*** NA 0.00
coef_presence_of_pre_school_kid_and_discretionary_tour-0.0171 0.349-0.05 NA 0.00
coef_presence_of_pre_school_kid_and_eating_out_tour-0.845 0.421-2.01* NA 0.00
coef_presence_of_pre_school_kid_and_escorting_tour 0.748 0.309 2.42* NA 0.00
coef_presence_of_pre_school_kid_and_shopping_tour-0.00614 0.294-0.02 NA 0.00
coef_presence_of_retiree_and_discretionary_tour-0.597 0.461-1.29 NA 0.00
coef_presence_of_retiree_and_eating_out_tour-1.29 0.618-2.08* NA 0.00
coef_presence_of_retiree_and_escorting_tour-12.9 250.-0.05 NA 0.00
coef_presence_of_university_student_and_discretionary_tour-0.407 0.376-1.08 NA 0.00
coef_total_number_of_tours_is_1-7.52 143.-0.05 NA 0.00
coef_total_number_of_tours_is_2-10.1 286.-0.04 NA 0.00
coef_total_number_of_tours_is_3-11.1 429.-0.03 NA 0.00
coef_total_number_of_tours_is_4-12.8 573.-0.02 NA 0.00
coef_total_number_of_tours_is_5-21.8 717.-0.03 NA 0.00
coef_total_number_of_tours_is_6_plus-999. NA NA NA 0.00fixed value
coef_transit_access_to_retail_and_tour_frequency_is_5_plus 0.0745 0.114 0.65 NA 0.00
coef_urban_and_discretionary_tour 0.00 NA NA NA 0.00fixed value
coef_urban_and_escorting_tour-0.409 NA NA[***] 6.54 0.00
coef_walk_access_to_retail_and_discretionary 0.161 0.169 0.95 NA 0.00
coef_walk_access_to_retail_and_eating_out 0.211 0.128 1.65 NA 0.00
coef_walk_access_to_retail_and_escorting-0.105 0.147-0.72 NA 0.00
coef_walk_access_to_retail_and_shopping 0.0302 0.146 0.21 NA 0.00
coef_zero_car_ownership_and_tour_frequency_is_5_plus-0.227 0.175-1.30 NA 0.00
" + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
 ValueStd Errt StatSignifLike RatioNull ValueConstrained
coef_0_auto_household_and_escorting_tour-2.00 NA NA NA 0.00fixed value
coef_1_escort_tour_constant 0.319 NA NA[*] 2.36 0.00
coef_1_plus_eating_out_tours_constant-1.01 124.-0.01 NA 0.00
coef_1_plus_maintenance_tours_constant-2.84 124.-0.02 NA 0.00
coef_1_plus_other_discretionary_tours_constant 10.5 123. 0.09 NA 0.00
coef_1_plus_shopping_tours_constant 7.18 124. 0.06 NA 0.00
coef_1_plus_visting_tours_constant-0.321 124.-0.00 NA 0.00
coef_2_plus_escort_tours_constant 0.607 NA NA[] 0.97 0.00
coef_at_home_pre_driving_school_kid_and_escorting_tour-0.926 1.05-0.89 NA 0.00
coef_at_home_pre_school_kid_and_discretionary_tour-0.656 0.743-0.88 NA 0.00
coef_at_home_pre_school_kid_and_escorting_tour-0.793 0.821-0.97 NA 0.00
coef_auto_access_to_retail_and_discretionary-1.05 0.957-1.10 NA 0.00
coef_auto_access_to_retail_and_maintenance 0.279 0.886 0.31 NA 0.00
coef_auto_access_to_retail_and_shopping-0.631 0.855-0.74 NA 0.00
coef_car_surplus_vs_workers_and_tour_frequency_is_5_plus 0.168 0.233 0.72 NA 0.00
coef_female_and_escorting_tour 0.601 0.266 2.26* NA 0.00
coef_female_and_tour_frequency_is_1-0.316 0.137-2.31* NA 0.00
coef_female_and_tour_frequency_is_2-0.583 0.277-2.11* NA 0.00
coef_female_and_tour_frequency_is_5 0.0227 0.671 0.03 NA 0.00
coef_high_income_group_and_discretionary_tour-0.0604 0.241-0.25 NA 0.00
coef_high_income_group_and_eating_out_tour 0.726 0.282 2.58** NA 0.00
coef_high_income_group_and_tour_frequency_is_1 1.14 0.408 2.79** NA 0.00
coef_high_income_group_and_tour_frequency_is_2 2.22 0.869 2.55* NA 0.00
coef_high_income_group_and_tour_frequency_is_5_plus 0.105 1.42 0.07 NA 0.00
coef_high_income_group_and_visiting_tour-0.863 0.350-2.46* NA 0.00
coef_logged_maximum_residual_window_tour_frequency_is_1 1.34 0.232 5.76*** NA 0.00
coef_logged_maximum_residual_window_tour_frequency_is_2 1.43 0.289 4.94*** NA 0.00
coef_logged_maximum_residual_window_tour_frequency_is_5_plus 0.640 1.09 0.59 NA 0.00
coef_mediumhigh_income_group_and_tour_frequency_is_1 1.09 0.394 2.77** NA 0.00
coef_mediumhigh_income_group_and_tour_frequency_is_2 1.81 0.850 2.13* NA 0.00
coef_mediumhigh_income_group_and_tour_frequency_is_5_plus 1.04 1.25 0.83 NA 0.00
coef_number_of_joint_eating_out_tours-9.98 147.-0.07 NA 0.00
coef_number_of_mandatory_tours_and_tour_frequency_is_2-1.43 0.489-2.93** NA 0.00
coef_number_of_mandatory_tours_and_tour_frequency_is_5_plus-1.64 2.28-0.72 NA 0.00
coef_presence_of_driving_school_kid_and_discretionary_tour 0.384 0.452 0.85 NA 0.00
coef_presence_of_driving_school_kid_and_escorting_tour-0.211 0.529-0.40 NA 0.00
coef_presence_of_full_time_worker_and_discretionary_tour-0.783 0.222-3.53*** NA 0.00
coef_presence_of_full_time_worker_and_eating_out_tour-0.748 0.221-3.38*** NA 0.00
coef_presence_of_full_time_worker_and_maintenance_tour-0.342 0.271-1.27 NA 0.00
coef_presence_of_full_time_worker_and_shopping_tour-0.631 0.190-3.32*** NA 0.00
coef_presence_of_non_worker_and_discretionary_tour-1.27 0.384-3.30*** NA 0.00
coef_presence_of_non_worker_and_eating_out_tour-0.445 0.327-1.36 NA 0.00
coef_presence_of_non_worker_and_escorting_tour-0.854 0.404-2.11* NA 0.00
coef_presence_of_non_worker_and_maintenance_tour-0.209 0.364-0.58 NA 0.00
coef_presence_of_non_worker_and_shopping_tour-0.844 0.301-2.80** NA 0.00
coef_presence_of_part_time_worker_and_discretionary_tour-0.0412 0.265-0.16 NA 0.00
coef_presence_of_part_time_worker_and_maintenance_tour-0.183 0.328-0.56 NA 0.00
coef_presence_of_part_time_worker_and_shopping_tour-0.149 0.224-0.66 NA 0.00
coef_presence_of_pre_driving_school_kid_and_discretionary_tour-0.126 0.314-0.40 NA 0.00
coef_presence_of_pre_driving_school_kid_and_escorting_tour 1.40 0.268 5.23*** NA 0.00
coef_presence_of_pre_school_kid_and_discretionary_tour-0.0171 0.349-0.05 NA 0.00
coef_presence_of_pre_school_kid_and_eating_out_tour-0.845 0.421-2.01* NA 0.00
coef_presence_of_pre_school_kid_and_escorting_tour 0.748 0.309 2.42* NA 0.00
coef_presence_of_pre_school_kid_and_shopping_tour-0.00614 0.294-0.02 NA 0.00
coef_presence_of_retiree_and_discretionary_tour-0.597 0.461-1.29 NA 0.00
coef_presence_of_retiree_and_eating_out_tour-1.29 0.618-2.08* NA 0.00
coef_presence_of_retiree_and_escorting_tour-12.9 250.-0.05 NA 0.00
coef_presence_of_university_student_and_discretionary_tour-0.407 0.376-1.08 NA 0.00
coef_total_number_of_tours_is_1-7.52 124.-0.06 NA 0.00
coef_total_number_of_tours_is_2-10.1 247.-0.04 NA 0.00
coef_total_number_of_tours_is_3-11.1 371.-0.03 NA 0.00
coef_total_number_of_tours_is_4-12.8 494.-0.03 NA 0.00
coef_total_number_of_tours_is_5-21.8 623.-0.03 NA 0.00
coef_total_number_of_tours_is_6_plus-999. NA NA NA 0.00fixed value
coef_transit_access_to_retail_and_tour_frequency_is_5_plus 0.0745 0.114 0.65 NA 0.00
coef_urban_and_discretionary_tour 0.00 NA NA NA 0.00fixed value
coef_urban_and_escorting_tour-0.409 NA NA[***] 6.54 0.00
coef_walk_access_to_retail_and_discretionary 0.161 0.169 0.95 NA 0.00
coef_walk_access_to_retail_and_eating_out 0.211 0.128 1.65 NA 0.00
coef_walk_access_to_retail_and_escorting-0.105 0.147-0.72 NA 0.00
coef_walk_access_to_retail_and_shopping 0.0302 0.146 0.21 NA 0.00
coef_zero_car_ownership_and_tour_frequency_is_5_plus-0.227 0.175-1.30 NA 0.00
\n" ], "text/plain": [ - "" + "" ] }, - "execution_count": 10, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } @@ -5771,7 +5889,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 12, "metadata": {}, "outputs": [], "source": [ @@ -5781,6 +5899,7 @@ " update_coefficients(\n", " m, data.coefficients[k], result_dir,\n", " output_file=f\"{modelname}_{k}_coefficients_revised.csv\",\n", + " relabel_coef=data.relabel_coef.get(k),\n", " );" ] }, @@ -5793,9 +5912,32 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 13, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/jeffnewman/LocalGit/asim-larch/activitysim-larch/conda-environments/AL-ENV/lib/python3.9/site-packages/larch/util/excel.py:523: FutureWarning: Use of **kwargs is deprecated, use engine_kwargs instead.\n", + " xl = ExcelWriter(filename, engine='xlsxwriter_larch', model=model, **kwargs)\n", + "/Users/jeffnewman/LocalGit/asim-larch/activitysim-larch/conda-environments/AL-ENV/lib/python3.9/site-packages/larch/util/excel.py:523: FutureWarning: Use of **kwargs is deprecated, use engine_kwargs instead.\n", + " xl = ExcelWriter(filename, engine='xlsxwriter_larch', model=model, **kwargs)\n", + "/Users/jeffnewman/LocalGit/asim-larch/activitysim-larch/conda-environments/AL-ENV/lib/python3.9/site-packages/larch/util/excel.py:523: FutureWarning: Use of **kwargs is deprecated, use engine_kwargs instead.\n", + " xl = ExcelWriter(filename, engine='xlsxwriter_larch', model=model, **kwargs)\n", + "/Users/jeffnewman/LocalGit/asim-larch/activitysim-larch/conda-environments/AL-ENV/lib/python3.9/site-packages/larch/util/excel.py:523: FutureWarning: Use of **kwargs is deprecated, use engine_kwargs instead.\n", + " xl = ExcelWriter(filename, engine='xlsxwriter_larch', model=model, **kwargs)\n", + "/Users/jeffnewman/LocalGit/asim-larch/activitysim-larch/conda-environments/AL-ENV/lib/python3.9/site-packages/larch/util/excel.py:523: FutureWarning: Use of **kwargs is deprecated, use engine_kwargs instead.\n", + " xl = ExcelWriter(filename, engine='xlsxwriter_larch', model=model, **kwargs)\n", + "/Users/jeffnewman/LocalGit/asim-larch/activitysim-larch/conda-environments/AL-ENV/lib/python3.9/site-packages/larch/util/excel.py:523: FutureWarning: Use of **kwargs is deprecated, use engine_kwargs instead.\n", + " xl = ExcelWriter(filename, engine='xlsxwriter_larch', model=model, **kwargs)\n", + "/Users/jeffnewman/LocalGit/asim-larch/activitysim-larch/conda-environments/AL-ENV/lib/python3.9/site-packages/larch/util/excel.py:523: FutureWarning: Use of **kwargs is deprecated, use engine_kwargs instead.\n", + " xl = ExcelWriter(filename, engine='xlsxwriter_larch', model=model, **kwargs)\n", + "/Users/jeffnewman/LocalGit/asim-larch/activitysim-larch/conda-environments/AL-ENV/lib/python3.9/site-packages/larch/util/excel.py:523: FutureWarning: Use of **kwargs is deprecated, use engine_kwargs instead.\n", + " xl = ExcelWriter(filename, engine='xlsxwriter_larch', model=model, **kwargs)\n" + ] + } + ], "source": [ "for k, m in model.items():\n", " result_dir = data.edb_directory/k/\"estimated\"\n", @@ -5816,7 +5958,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 14, "metadata": {}, "outputs": [ { @@ -5903,7 +6045,7 @@ " \n", " 208\n", " coef_1_plus_other_discretionary_tours_constant\n", - " 10.543980\n", + " 10.543979\n", " F\n", " \n", " \n", @@ -5928,13 +6070,13 @@ "205 coef_1_plus_maintenance_tours_constant -2.842643 F\n", "206 coef_1_plus_eating_out_tours_constant -1.012856 F\n", "207 coef_1_plus_visting_tours_constant -0.320820 F\n", - "208 coef_1_plus_other_discretionary_tours_constant 10.543980 F\n", + "208 coef_1_plus_other_discretionary_tours_constant 10.543979 F\n", "209 coef_0_auto_household_and_escorting_tour -2.000000 T\n", "\n", "[210 rows x 3 columns]" ] }, - "execution_count": 15, + "execution_count": 14, "metadata": {}, "output_type": "execute_result" } @@ -5952,7 +6094,7 @@ "toc_visible": true }, "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -5966,7 +6108,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.6" + "version": "3.9.13" }, "toc": { "base_numbering": 1, From 586cf454c3d4ca1a9227783389a717e958fec6bc Mon Sep 17 00:00:00 2001 From: Jeff Newman Date: Wed, 24 Aug 2022 15:41:31 -0500 Subject: [PATCH 3/5] blacken --- activitysim/estimation/larch/general.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/activitysim/estimation/larch/general.py b/activitysim/estimation/larch/general.py index 10f28d166..4e4fc3adf 100644 --- a/activitysim/estimation/larch/general.py +++ b/activitysim/estimation/larch/general.py @@ -1,18 +1,15 @@ -import itertools import logging import os -import re from pathlib import Path from typing import Mapping import numpy as np import pandas as pd -import yaml -from larch import DataFrames, Model, P, X +from larch import DataFrames, Model, P, X # noqa: F401 from larch.log import logger_name from larch.model.abstract_model import AbstractChoiceModel from larch.model.tree import NestingTree -from larch.util import Dict +from larch.util import Dict # noqa: F401 _logger = logging.getLogger(logger_name) @@ -490,7 +487,9 @@ def clean_values( return values -def update_coefficients(model, data, result_dir=Path("."), output_file=None, relabel_coef=None): +def update_coefficients( + model, data, result_dir=Path("."), output_file=None, relabel_coef=None +): if isinstance(data, pd.DataFrame): coefficients = data.copy() else: From 36280d8ee5a756d603b2ffc58dea6489a20d2da6 Mon Sep 17 00:00:00 2001 From: Jeff Newman Date: Fri, 30 Dec 2022 14:44:40 -0600 Subject: [PATCH 4/5] add note about `condense_parameters` --- .../notebooks/15_non_mand_tour_freq.ipynb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/activitysim/examples/example_estimation/notebooks/15_non_mand_tour_freq.ipynb b/activitysim/examples/example_estimation/notebooks/15_non_mand_tour_freq.ipynb index 76e0de5c4..f79eaccef 100644 --- a/activitysim/examples/example_estimation/notebooks/15_non_mand_tour_freq.ipynb +++ b/activitysim/examples/example_estimation/notebooks/15_non_mand_tour_freq.ipynb @@ -93,6 +93,15 @@ "cell_type": "markdown", "metadata": {}, "source": [ + "The prototype model spec we are re-estimating has 210 rows for each person type, but the\n", + "accompanying dataset is not large enough to successfully estimate anywhere near than many\n", + "parameters. The `condense_parameters` option is activated here as a short cut to making\n", + "a model that can be estimated with stable parameter results. When activated, it merges\n", + "parameters not only by name (i.e. when the same name appears twice it is the same parameter)\n", + "but also by value, so that if the initial value of any two parameters is identical\n", + "then they are treated as the same parameter. Using \"condense_parameters\" in actual model\n", + "estimation efforts is ill advised and may generate confusing or unexpected results.\n", + "\n", "This component actually has a distinct choice model for each person type, so\n", "instead of a single model there's a `dict` of models." ] @@ -757,7 +766,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "For future estimation work, parameters can be intelligently named and applied to match the model developer's desired structure (by using the same named parameter for multiple rows of the spec file). If this is done, the \"short cut\" can be disabled by setting `condense_parameters=False` in the loading step above.\n", + "For future estimation work, parameters can be intelligently named and applied to match the model developer's desired structure (by using the same named parameter for multiple rows of the spec file). If this is done, the \"short cut\" should be disabled by setting `condense_parameters=False` in the loading step above.\n", "\n", "Larch has a built-in estimation methods including BHHH, and also offers access to more advanced general purpose non-linear optimizers in the `scipy` package, including SLSQP, which allows for bounds and constraints on parameters. BHHH is the default and typically runs faster, but does not follow constraints on parameters." ] From 88e1bd516ca0956220a8d83fd80a8b3554e8ddc0 Mon Sep 17 00:00:00 2001 From: Jeff Newman Date: Fri, 30 Dec 2022 14:48:39 -0600 Subject: [PATCH 5/5] change default condense_parameters to False --- activitysim/estimation/larch/nonmand_tour_freq.py | 10 +++------- activitysim/estimation/test/test_larch_estimation.py | 2 +- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/activitysim/estimation/larch/nonmand_tour_freq.py b/activitysim/estimation/larch/nonmand_tour_freq.py index 97d658c97..9dfdac73a 100644 --- a/activitysim/estimation/larch/nonmand_tour_freq.py +++ b/activitysim/estimation/larch/nonmand_tour_freq.py @@ -1,14 +1,10 @@ -import itertools import logging import os -import re from pathlib import Path -from typing import Mapping -import numpy as np import pandas as pd import yaml -from larch import DataFrames, Model, P, X +from larch import DataFrames, Model from larch.log import logger_name from larch.util import Dict @@ -125,7 +121,7 @@ def unavail(model, x_ca): def nonmand_tour_freq_model( edb_directory="output/estimation_data_bundle/{name}/", return_data=False, - condense_parameters=True, + condense_parameters=False, ): """ Prepare nonmandatory tour frequency models for estimation. @@ -137,7 +133,7 @@ def nonmand_tour_freq_model( return_data : bool, default False Whether to return the data used in preparing this function. If returned, data is a dict in the second return value. - condense_parameters : bool, default True + condense_parameters : bool, default False Apply a transformation whereby all parameters in each model that have the same initial value are converted to have the same name (and thus to be the same parameter, used in various places). diff --git a/activitysim/estimation/test/test_larch_estimation.py b/activitysim/estimation/test/test_larch_estimation.py index cd175937e..b148009f3 100644 --- a/activitysim/estimation/test/test_larch_estimation.py +++ b/activitysim/estimation/test/test_larch_estimation.py @@ -279,7 +279,7 @@ def test_tour_and_subtour_mode_choice(est_data, num_regression, dataframe_regres def test_nonmand_tour_freq(est_data, num_regression, dataframe_regression): from activitysim.estimation.larch.nonmand_tour_freq import nonmand_tour_freq_model - m = nonmand_tour_freq_model() + m = nonmand_tour_freq_model(condense_parameters=True) loglike_prior = {} expected_n_params = { "PTYPE_FULL": 72,