Skip to content

Commit

Permalink
Merge pull request #130 from Caliper-Corporation/dev_kyle
Browse files Browse the repository at this point in the history
Last commit of dev_kyle
  • Loading branch information
dkyleward committed Jan 13, 2022
2 parents 18fee58 + e6f93ff commit 5405f8f
Show file tree
Hide file tree
Showing 139 changed files with 2,041 additions and 3,330 deletions.
32 changes: 32 additions & 0 deletions docs/R/create_dc_est_tables.R
Expand Up @@ -4,6 +4,38 @@ hh_raw <- read_csv("data/output/_PRIVATE/survey_processing/hh_processed.csv")
trips_raw <- read_csv("data/output/_PRIVATE/survey_processing/trips_processed.csv")
cluster <- read_csv("data/input/dc/cluster_def.csv")

# W_HB_W
df_w_hbw <- trips_raw %>%
filter(trip_type == "W_HB_W_All") %>%
left_join(
hh_raw %>%
select(hhid, hh_income_midpt, num_adults),
by = "hhid"
) %>%
group_by(personid, tour_num, a_taz) %>%
slice(1) %>%
mutate(
HomeTAZ = ifelse(pa_flag == 1, o_taz, d_taz),
AvgIncPerWorker = hh_income_midpt / num_workers,
LowIncome = ifelse(AvgIncPerWorker < 75000, 1, 0)
) %>%
left_join(cluster, by = c("HomeTAZ" = "TAZ")) %>%
rename(Home_Cluster = Cluster) %>%
left_join(cluster, by = c("o_taz" = "TAZ")) %>%
rename(O_Cluster = Cluster) %>%
left_join(cluster, by = c("d_taz" = "TAZ")) %>%
rename(D_Cluster = Cluster) %>%
mutate(ZeroAutoHH = ifelse(num_vehicles == 0, 1, 0)) %>%
ungroup() %>%
select(
EstDataID = seqtripid, personid, hhid, HomeTAZ, o_taz, d_taz, a_taz,
HHIncomeMP = hh_income_midpt, AvgIncPerWorker,
LowIncome, Home_Cluster, O_Cluster, D_Cluster, Segment = choice_segment,
tod,
ZeroAutoHH, trip_weight = trip_weight_combined, hh_weight = hh_weight_combined
)
write_csv(df_w_hbw, "w_hbw_est_tbl.csv")

# W_HB_O
df_w_hbo <- trips_raw %>%
filter(trip_type == "W_HB_O_All") %>%
Expand Down
56 changes: 55 additions & 1 deletion docs/auto_ownership.Rmd
Expand Up @@ -104,4 +104,58 @@ intuitive. Large numbers of workers in a household has a small positive impact o
utility of owning 1 auto, but a large impact on owning 2 or more. High income
households are more likely to own more vehicles. Children make it less likely to
own 3 or more cars, because there are fewer drivers. Finally, the model's Rho^2
shows strong predictive power.
shows strong predictive power.

## Calibration

Even before calibration, the estimated coefficients produced results that
closely matched the survey as shown in the table below.

```{r, include=FALSE}
# These should come from an application of the model before any calibration
# has been done.
model <- read_csv("data/input/auto_ownership/uncalibrated_auto_results.csv")
```

```{r}
survey <- est_tbl %>%
group_by(autos = num_vehicles) %>%
summarize(weight = sum(hh_weight_combined)) %>%
mutate(pct = weight / sum(weight))
survey %>%
select(autos, survey = pct) %>%
left_join(model, by = "autos") %>%
select(-hh) %>%
rename(model = pct) %>%
mutate(
survey = round(survey * 100, 1),
model = round(model * 100, 1)
) %>%
rename(Autos = autos, `Survey %` = survey, `Model %` = model) %>%
kable() %>%
kable_styling(full_width = FALSE)
```

Caliper created an auto-calibration tool for the auto ownership model and used
it to ensure the model matched the observed shares more closely. Importantly,
the calibration constants required to do this were small as shown below.

```{r, include=FALSE}
calib_coeffs_df <- read_csv("../master/resident/auto_ownership/ao_coefficients.csv")
```

```{r}
calib_coeffs_df %>%
filter(grepl("Added by", Description)) %>%
select(Alternative, `Calibration Constant` = Coefficient) %>%
kable() %>%
kable_styling(full_width = FALSE)
```


```{r, eval=FALSE}
write_csv(survey, "data/output/auto_ownership/ao_calib_targets.csv")
```

189 changes: 183 additions & 6 deletions docs/auto_ownership.html
Expand Up @@ -372,38 +372,73 @@
<li>
<a href="survey_processing.html">Household Survey</a>
</li>
<li>
<a href="obs_processing.html">On-Board Survey</a>
</li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
Models
Resident Models

<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="accessibility.html">Accessibility</a>
</li>
<li>
<a href="population_synthesis.html">Synthesis</a>
</li>
<li>
<a href="auto_ownership.html">Auto Ownership</a>
</li>
<li>
<a href="resident_production.html">Production</a>
</li>
<li>
<a href="time_of_day.html">Time of Day</a>
</li>
<li>
<a href="nhb.html">Non-home-based</a>
<a href="resident_nonmotorized.html">Non-motorized</a>
</li>
<li>
<a href="parking.html">Parking</a>
</li>
<li>
<a href="resident_dest_choice.html">Destination Choice</a>
</li>
<li>
<a href="nhb.html">Non-homebased</a>
</li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
Other Models

<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="accessibility.html">Accessibility</a>
</li>
<li>
<a href="airport.html">Airport</a>
</li>
<li>
<a href="ieei.html">Internal/External</a>
</li>
<li>
<a href="commercial_vehicles.html">Commercial Vehicles</a>
</li>
<li>
<a href="assignment_roadway.html">Roadway Assignment</a>
</li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">

<li>
<a href="https://github.com/Caliper-Corporation/TRMG2">Github</a>
</li>
</ul>
</div><!--/.nav-collapse -->
</div><!--/.container -->
Expand Down Expand Up @@ -592,6 +627,25 @@ <h2>Coefficients</h2>
</tr>
<tr>
<td style="text-align:left;">
ASC
</td>
<td style="text-align:left;">
</td>
<td style="text-align:left;">
-0.441
</td>
<td style="text-align:left;">
-5.751
</td>
<td style="text-align:left;">
-8.939
</td>
<td style="text-align:left;">
-12.61
</td>
</tr>
<tr>
<td style="text-align:left;">
</td>
<td style="text-align:left;">
</td>
Expand Down Expand Up @@ -625,6 +679,129 @@ <h2>Coefficients</h2>
<p>The coefficients all have the right sign and the relative sizes are intuitive. One particularly encouraging result of this model is that households with strong walk and transit accessibility are less likely to own a vehicle and even less likely to own multiple vehicles. This adds another dimension of model sensitivity to transit investments. New transit routes will affect long-term household decisions about auto ownership, which further influence their daily decisions about mode choice.</p>
<p>Looking in more detail, the trend for coefficients across alternatives is also intuitive. Large numbers of workers in a household has a small positive impact on the utility of owning 1 auto, but a large impact on owning 2 or more. High income households are more likely to own more vehicles. Children make it less likely to own 3 or more cars, because there are fewer drivers. Finally, the model’s Rho^2 shows strong predictive power.</p>
</div>
<div id="calibration" class="section level2">
<h2>Calibration</h2>
<p>Even before calibration, the estimated coefficients produced results that closely matched the survey as shown in the table below.</p>
<table class="table" style="width: auto !important; margin-left: auto; margin-right: auto;">
<thead>
<tr>
<th style="text-align:right;">
Autos
</th>
<th style="text-align:right;">
Survey %
</th>
<th style="text-align:right;">
Model %
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:right;">
0
</td>
<td style="text-align:right;">
5.1
</td>
<td style="text-align:right;">
5.3
</td>
</tr>
<tr>
<td style="text-align:right;">
1
</td>
<td style="text-align:right;">
31.5
</td>
<td style="text-align:right;">
33.5
</td>
</tr>
<tr>
<td style="text-align:right;">
2
</td>
<td style="text-align:right;">
41.7
</td>
<td style="text-align:right;">
37.9
</td>
</tr>
<tr>
<td style="text-align:right;">
3
</td>
<td style="text-align:right;">
15.3
</td>
<td style="text-align:right;">
13.4
</td>
</tr>
<tr>
<td style="text-align:right;">
4
</td>
<td style="text-align:right;">
6.5
</td>
<td style="text-align:right;">
9.9
</td>
</tr>
</tbody>
</table>
<p>Caliper created an auto-calibration tool for the auto ownership model and used it to ensure the model matched the observed shares more closely. Importantly, the calibration constants required to do this were small as shown below.</p>
<table class="table" style="width: auto !important; margin-left: auto; margin-right: auto;">
<thead>
<tr>
<th style="text-align:left;">
Alternative
</th>
<th style="text-align:right;">
Calibration Constant
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left;">
v1
</td>
<td style="text-align:right;">
-0.0706
</td>
</tr>
<tr>
<td style="text-align:left;">
v2
</td>
<td style="text-align:right;">
0.1128
</td>
</tr>
<tr>
<td style="text-align:left;">
v3
</td>
<td style="text-align:right;">
0.1454
</td>
</tr>
<tr>
<td style="text-align:left;">
v4
</td>
<td style="text-align:right;">
-0.4734
</td>
</tr>
</tbody>
</table>
</div>

<br>
<br>
Expand Down
3 changes: 2 additions & 1 deletion docs/data/input/_PRIVATE/.gitignore
Expand Up @@ -2,4 +2,5 @@
# be pushed to GitHub. Contact Leta Huntsinger to request access to these files.

*
!.gitignore
!.gitignore
!note.txt
4 changes: 4 additions & 0 deletions docs/data/input/_PRIVATE/note.txt
@@ -0,0 +1,4 @@
This folder holds survey and other sensitive information used to estimate
TRMG2 that cannot be shared publicly on GitHub. This info is not required
for model application, but if needed for model re-estimation or calibration,
reach out to ITRE staff.
1 change: 1 addition & 0 deletions docs/data/input/auto_ownership/ao_final_coefficients.csv
Expand Up @@ -6,5 +6,6 @@ Seniors,,0.143987,0.143987,,
Income,,1.68663,2.53124,2.72387,2.95781
Walk Accessibility,,,-0.395344,-0.60468,-1.0608
Transit Accessibility,,-0.369765,-0.42533,-0.535768,-0.535768
ASC,,-0.441283,-5.7512,-8.93905,-12.6101
,,,,,
Adjusted Rho^2,0.41,,,,
6 changes: 6 additions & 0 deletions docs/data/input/auto_ownership/uncalibrated_auto_results.csv
@@ -0,0 +1,6 @@
autos,hh,pct
0,39155,0.053466699
1,245236,0.334873178
2,277527,0.378966989
3,97839,0.133600519
4,72568,0.099092616
@@ -1,9 +1,9 @@
trip_type,model_trips
N_HB_K12_All,568912.71
N_HB_OD_Long,921200.82
N_HB_OD_Short,717463.98
N_HB_OMED_All,99865.14
N_HB_OME_All,999918.56
W_HB_EK12_All,58643.39
W_HB_O_All,292151.12
W_HB_W_All,789297.83
N_HB_K12_All,567062.95
N_HB_OD_Long,916289.03
N_HB_OD_Short,558955.28
N_HB_OMED_All,102739.29
N_HB_OME_All,997883.18
W_HB_EK12_All,58640.2
W_HB_O_All,288692.04
W_HB_W_All,789296.46
3 changes: 2 additions & 1 deletion docs/data/output/_PRIVATE/.gitignore
Expand Up @@ -2,4 +2,5 @@
# be pushed to GitHub. Contact Leta Huntsinger to request access to these files.

*
!.gitignore
!.gitignore
!note.txt
4 changes: 4 additions & 0 deletions docs/data/output/_PRIVATE/note.txt
@@ -0,0 +1,4 @@
This folder holds survey and other sensitive information used to estimate
TRMG2 that cannot be shared publicly on GitHub. This info is not required
for model application, but if needed for model re-estimation or calibration,
reach out to ITRE staff.

0 comments on commit 5405f8f

Please sign in to comment.