Title: | Scan Statistics for Railway Network |
---|---|
Description: | Implement the algorithm provided in scan for estimating the transmission route on railway network using passenger volume. It is a generalization of the scan statistic approach for railway network to identify the hot railway route for transmitting infectious diseases. |
Authors: | Shinya Uryu [aut, cre] , Yuta Tanoue [aut], Daisuke Yoneoka [aut] |
Maintainer: | Shinya Uryu <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.0 |
Built: | 2024-11-20 03:04:00 UTC |
Source: | https://github.com/uribo/ssrn |
East Japan Railway's Tokaido Line Data
Includes the names of stations between Tokyo and Yugawara as of June 2020.
st_code
: A unique number to identify the station.
st_name
: Romanization of station names.
jreast_jt a tibble
JR-East Tokaido Line OD Data
Census values made in 2015. The number of passengers between stations on the Tokaido Line. These values are those of commuter pass users.
departure_st_code
: Departing station identification number.
arrive_st_code
: The identification number of the station you are arriving at.
volume
Number of people getting on and off the train.
jreast_jt_od a tibble
https://www.mlit.go.jp/sogoseisaku/transport/sosei_transport_tk_000035.html
Convert station data to adjacency matrix
make_adjacency_matrix(stations, depart, arrive)
make_adjacency_matrix(stations, depart, arrive)
stations |
data.frame which set of stopping points recorded in order of stopping. |
depart |
Column name of a stop. |
arrive |
Give the name of the column indicating the next stop at the target stop. |
make_adjacency_matrix(jreast_jt, st_code, next_st_code)
make_adjacency_matrix(jreast_jt, st_code, next_st_code)
Convert passenger and station data to origin-destination matrix
make_passenger_matrix(passenger, stations, depart, arrive, location, value)
make_passenger_matrix(passenger, stations, depart, arrive, location, value)
passenger |
passenger data |
stations |
data.frame which set of stopping points recorded in order of stopping. |
depart |
Column name of a stop. |
arrive |
Give the name of the column indicating the next stop at the target stop. |
location |
Name of the variable to use for the join, indicating its location. |
value |
origin-destination value name |
jreast_jt_od %>% make_passenger_matrix(jreast_jt, departure_st_code, arrive_st_code, st_code, volume)
jreast_jt_od %>% make_passenger_matrix(jreast_jt, departure_st_code, arrive_st_code, st_code, volume)
Summaries a passenger volume
make_passenger_od( passenger, stations, depart, arrive, location, value, .all = FALSE )
make_passenger_od( passenger, stations, depart, arrive, location, value, .all = FALSE )
passenger |
passenger data |
stations |
data.frame which set of stopping points recorded in order of stopping. |
depart |
Column name of a stop. |
arrive |
Give the name of the column indicating the next stop at the target stop. |
location |
Name of the variable to use for the join, indicating its location. |
value |
origin-destination value name |
.all |
Make a join that contains rows of two datasets. The default value is FALSE. |
jreast_jt_od %>% make_passenger_od(jreast_jt, depart = departure_st_code, arrive_st_code, location = st_code, value = volume) %>% dplyr::left_join(jreast_jt %>% dplyr::select(arrive_st_code = st_code, next_st_name = st_name), by = "arrive_st_code")
jreast_jt_od %>% make_passenger_od(jreast_jt, depart = departure_st_code, arrive_st_code, location = st_code, value = volume) %>% dplyr::left_join(jreast_jt %>% dplyr::select(arrive_st_code = st_code, next_st_name = st_name), by = "arrive_st_code")
Create network window zones
network_window(adjacency_matrix, dist_matrix, type, cluster_max)
network_window(adjacency_matrix, dist_matrix, type, cluster_max)
adjacency_matrix |
A boolean matrix, with element (i,j) set to TRUE if location j is adjacent to location i. |
dist_matrix |
Distance matrix |
type |
Currently, "connected_B" only. |
cluster_max |
Maximum cluster size. Zone If this value is reached, the area will not be expanded any further. It's a good idea to keep it to the number of stops on the line you're dealing with. |
Create transit table
transit_table(stations, ..., reverse = FALSE)
transit_table(stations, ..., reverse = FALSE)
stations |
data.frame which set of stopping points recorded in order of stopping. |
... |
Arguments passed on to
|
reverse |
Option to swap the order of the stopping points. |
# The next stop is stored in the variable of column next_. jreast_jt %>% transit_table() # Switch between inbound and outbound lines. jreast_jt %>% transit_table(reverse = TRUE)
# The next stop is stored in the variable of column next_. jreast_jt %>% transit_table() # Switch between inbound and outbound lines. jreast_jt %>% transit_table(reverse = TRUE)