Skip to content

Commit

Permalink
Estimate margins of error for the sample mean using a bootstrap (#120)
Browse files Browse the repository at this point in the history
* Estimate margins of error for the sample mean using a bootstrap

returns results through the frontend and adds some fields to the backend response
The unit of observation is the "one hour average" which, while not statistically valid, should be a decent starting point, and demonstrates how margins of error can be calculated from a sample of observations

* add margins of error to sample data

* add sample script for statistical difference testing

* add margins of error to sample plots

* disable MoE output in frontend
  • Loading branch information
Nate-Wessel authored Jul 10, 2024
1 parent a19a761 commit b18a9a8
Show file tree
Hide file tree
Showing 6 changed files with 263 additions and 167 deletions.
46 changes: 31 additions & 15 deletions analysis/plot-comparisons.r
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ read_csv('sample-data/results-monthly.csv') %>%
mutate( fromDate= ymd(fromDate) + days(15) ) %>%
ggplot( aes( x=fromDate, y=ttt, lty=direction ) ) +
geom_line( size = 1.2, color=grey ) +
geom_ribbon(
aes(
ymin = moe_lower_p95 / 60,
ymax = moe_upper_p95 / 60,
fill = direction
),
alpha = 0.25
) +
geom_point( color=grey, size=2 ) +
annotate( # approximate start/end dates of complete-street installation
'rect',
Expand Down Expand Up @@ -58,18 +66,26 @@ read_csv('sample-data/results-ToD.csv') %>%
), levels=c('before','after')),
) %>%
ggplot( aes( x=0.5+hour, y=mean_travel_time_seconds, lty=direction ) ) +
geom_line( aes(color=period,), size = 1 ) +
scale_color_manual(values=c('before'=grey,'after'=purple)) +
labs( title = 'Bloor West travel times between Runnymede & Aberfoyle' ) +
ylab( 'Travel Time (seconds)' ) +
xlab( 'Hour of day' ) +
scale_y_continuous(
breaks = 60 * seq(0,14,1),
minor_breaks = NULL,
limits = c(0, NA)
) +
scale_x_continuous(
breaks = seq(0,24),
minor_breaks = c(),
) +
theme_bw()
geom_line( aes(color=period,), size = 1 ) +
geom_ribbon(
aes(
ymin = moe_lower_p95,
ymax = moe_upper_p95,
fill = period
),
alpha = 0.25
) +
scale_color_manual(values=c('before'=grey,'after'=purple)) +
labs( title = 'Bloor West travel times between Runnymede & Aberfoyle' ) +
ylab( 'Travel Time (seconds)' ) +
xlab( 'Hour of day' ) +
scale_y_continuous(
breaks = 60 * seq(0,14,1),
minor_breaks = NULL,
limits = c(0, NA)
) +
scale_x_continuous(
breaks = seq(0,24),
minor_breaks = c(),
) +
theme_bw()
Loading

0 comments on commit b18a9a8

Please sign in to comment.