Skip to content

atfutures-labs/citymodes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

citymodes

The goal of citymodes is to show how to represent how mode split varies with distance and other variables across different settlements.

Univariate

d = seq(0.2, 20, by = 0.2)
a = -3.894
b1 = -0.5872
b2 = 1.832
b3 = 0.007956
logit_pcycle = a + (b1 * d) + (b2 * sqrt(d) ) + (b3 * d^2)
scen_baseline = boot::inv.logit(logit_pcycle) 
scen_dutch = boot::inv.logit(logit_pcycle + 2.499 -0.07384 * d)
txtplot::txtplot(d, scen_baseline, ylim = c(0, 1))
#>   1 +-+------------+-----------+------------+-----------+--+
#>     |                                                      |
#>     |                                                      |
#> 0.8 +                                                      +
#>     |                                                      |
#> 0.6 +                                                      +
#>     |                                                      |
#>     |                                                      |
#> 0.4 +                                                      +
#>     |                                                      |
#> 0.2 +                                                      +
#>     |                                                      |
#>     | ***************************                          |
#>   0 +-+------------+-----------+*************************--+
#>       0            5          10           15          20
txtplot::txtplot(d, scen_dutch, ylim = c(0, 1))
#>   1 +-+------------+-----------+------------+-----------+--+
#>     |                                                      |
#>     |                                                      |
#> 0.8 +                                                      +
#>     |                                                      |
#> 0.6 +                                                      +
#>     |                                                      |
#>     |   **********                                         |
#> 0.4 +  **         *****                                    +
#>     | *               *****                                |
#> 0.2 +                      *****                           +
#>     |                           *******                    |
#>     |                                  ******************  |
#>   0 +-+------------+-----------+------------+-----------*--+
#>       0            5          10           15          20

Multinomial data

Generate fake data on 3 modes.

w = a = b = rep(1, length(d))
b = scen_dutch 
a = 1 - b
w[d < 2] = 1
w[d >= 2] = 0
a[d < 2] = 0
b[d < 2] = 0
txtplot::txtplot(d, w)
#>     +-+------------+-----------+------------+-----------+--+
#>   1 + ******                                               +
#>     |                                                      |
#> 0.8 +                                                      +
#>     |                                                      |
#> 0.6 +                                                      +
#>     |                                                      |
#>     |                                                      |
#> 0.4 +                                                      +
#>     |                                                      |
#> 0.2 +                                                      +
#>     |                                                      |
#>   0 +      **********************************************  +
#>     +-+------------+-----------+------------+-----------+--+
#>       0            5          10           15          20
txtplot::txtplot(d, b)
#> 0.5 +-+------------+-----------+------------+-----------+--+
#>     |      ******                                          |
#>     |           ***                                        |
#> 0.4 +              ***                                     +
#>     |                ***                                   |
#> 0.3 +                   **                                 +
#>     |                     ***                              |
#> 0.2 +                       ****                           +
#>     |                          ****                        |
#>     |                              ****                    |
#> 0.1 +                                  ******              +
#>     |                                        ************  |
#>   0 + ******                                               +
#>     +-+------------+-----------+------------+-----------+--+
#>       0            5          10           15          20
txtplot::txtplot(d, a)
#>   1 +-+------------+-----------+------------+-----------+--+
#>     |                                   *****************  |
#>     |                           ********                   |
#> 0.8 +                     ******                           +
#>     |                 *****                                |
#> 0.6 +            *****                                     +
#>     |      ******                                          |
#>     |                                                      |
#> 0.4 +                                                      +
#>     |                                                      |
#> 0.2 +                                                      +
#>     |                                                      |
#>   0 + ******                                               +
#>     +-+------------+-----------+------------+-----------+--+
#>       0            5          10           15          20

Individual level data

# m = d
# for(i in seq_along(d)) {
#   m[i] = sample(x = 1:3, size = length(d), replace = TRUE, prob = c(a))
# }

About

Code to represent mode split in cities

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published