# NOT RUN {
distance = 15
gradient = 2
logit_pcycle = -3.959 + # alpha
(-0.5963 * distance) + # d1
(1.866 * sqrt(distance)) + # d2
(0.008050 * distance^2) + # d3
(-0.2710 * gradient) + # h1
(0.009394 * distance * gradient) + # i1
(-0.05135 * sqrt(distance) * gradient) # i2
boot::inv.logit(logit_pcycle)
uptake_pct_govtarget(15, 2)
l = routes_fast_leeds
pcycle_scenario = uptake_pct_govtarget(l$length, l$av_incline)
pcycle_scenario_2020 = uptake_pct_govtarget_2020(l$length, l$av_incline)
plot(l$length, pcycle_scenario, ylim = c(0, 0.2))
points(l$length, pcycle_scenario_2020, col = "blue")
# compare with published PCT data:
l_pct_2020 = get_pct_lines(region = "isle-of-wight")
# test for another region:
# l_pct_2020 = get_pct_lines(region = "west-yorkshire")
l_pct_2020$rf_avslope_perc[1:5]
l_pct_2020$rf_dist_km[1:5]
govtarget_slc = uptake_pct_govtarget(
distance = l_pct_2020$rf_dist_km,
gradient = l_pct_2020$rf_avslope_perc
) * l_pct_2020$all + l_pct_2020$bicycle
govtarget_slc_2020 = uptake_pct_govtarget_2020(
distance = l_pct_2020$rf_dist_km,
gradient = l_pct_2020$rf_avslope_perc
) * l_pct_2020$all + l_pct_2020$bicycle
mean(l_pct_2020$govtarget_slc)
mean(govtarget_slc)
mean(govtarget_slc_2020)
godutch_slc = uptake_pct_godutch(
distance = l_pct_2020$rf_dist_km,
gradient = l_pct_2020$rf_avslope_perc
) * l_pct_2020$all + l_pct_2020$bicycle
godutch_slc_2020 = uptake_pct_godutch_2020(
distance = l_pct_2020$rf_dist_km,
gradient = l_pct_2020$rf_avslope_perc
) * l_pct_2020$all + l_pct_2020$bicycle
mean(l_pct_2020$dutch_slc)
mean(godutch_slc)
mean(godutch_slc_2020)
# Take an origin destination (OD) pair between an LSOA centroid and a
# secondary school. In this OD pair, 30 secondary school children travel, of
# whom 3 currently cycle. The fastest route distance is 3.51 km and the
# gradient is 1.11%. The
# gradient as centred on Dutch hilliness levels is 1.11 <U+2013> 0.63 = 0.48%.
# The observed number of cyclists is 2. ... Modelled baseline= 30 * .0558 = 1.8.
uptake_pct_govtarget_school2(3.51, 1.11)
# pcycle = exp ([logit (pcycle)])/(1 + (exp([logit(pcycle)]))).
# pcycle = exp(1.953)/(1 + exp(1.953)) = .8758, or 87.58%.
uptake_pct_godutch_school2(3.51, 1.11)
# }
Run the code above in your browser using DataLab