k_nt_functions {spNetwork} | R Documentation |
Network k and g functions for spatio-temporal data (experimental, NOT READY FOR USE)
Description
Calculate the k and g functions for a set of points on a network and in time (experimental, NOT READY FOR USE).
Usage
k_nt_functions(
lines,
points,
points_time,
start_net,
end_net,
step_net,
width_net,
start_time,
end_time,
step_time,
width_time,
nsim,
conf_int = 0.05,
digits = 2,
tol = 0.1,
resolution = NULL,
agg = NULL,
verbose = TRUE
)
Arguments
lines |
A feature collection of linestrings representing the underlying network. The geometries must be simple Linestrings (may crash if some geometries are invalid) without MultiLineSring |
points |
A feature collection of points representing the points on the network. These points will be snapped on their nearest line |
points_time |
A numeric vector indicating when the point occured |
start_net |
A double, the lowest network distance used to evaluate the k and g functions |
end_net |
A double, the highest network distance used to evaluate the k and g functions |
step_net |
A double, the step between two evaluations of the k and g for the network distance function. start_net, end_net and step_net are used to create a vector of distances with the function seq |
width_net |
The width (network distance) of each donut for the g-function. Half of the width is applied on both sides of the considered distance |
start_time |
A double, the lowest time distance used to evaluate the k and g functions |
end_time |
A double, the highest time distance used to evaluate the k and g functions |
step_time |
A double, the step between two evaluations of the k and g for the time distance function. start_time, end_time and step_time are used to create a vector of distances with the function seq |
width_time |
The width (time distance) of each donut for the g-function. Half of the width is applied on both sides of the considered distance |
nsim |
An integer indicating the number of Monte Carlo simulations to perform for inference |
conf_int |
A double indicating the width confidence interval (default = 0.05) calculated on the Monte Carlo simulations |
digits |
An integer indicating the number of digits to retain from the spatial coordinates |
tol |
When adding the points to the network, specify the minimum distance between these points and the lines' extremities. When points are closer, they are added at the extremity of the lines |
resolution |
When simulating random points on the network, selecting a resolution will reduce greatly the calculation time. When resolution is null the random points can occur everywhere on the graph. If a value is specified, the edges are split according to this value and the random points can only be vertices on the new network |
agg |
A double indicating if the events must be aggregated within a distance. If NULL, the events are aggregated only by rounding the coordinates |
verbose |
A Boolean indicating if progress messages should be displayed |
Details
The k-function is a method to characterize the dispersion of a set of points. For each point, the numbers of other points in subsequent radii are calculated in both space and time. This empirical k-function can be more or less clustered than a k-function obtained if the points were randomly located . In a network, the network distance is used instead of the Euclidean distance. This function uses Monte Carlo simulations to assess if the points are clustered or dispersed. The function also calculates the g-function, a modified version of the k-function using rings instead of disks. The width of the ring must be chosen. The main interest is to avoid the cumulative effect of the classical k-function. This function is maturing, it works as expected (unit tests) but will probably be modified in the future releases (gain speed, advanced features, etc.).
Value
A list with the following values :
obs_k: A matrix with the observed k-values
lower_k: A matrix with the lower bounds of the simulated k-values
upper_k: A matrix with the upper bounds of the simulated k-values
obs_g: A matrix with the observed g-values
lower_g: A matrix with the lower bounds of the simulated g-values
upper_g: A matrix with the upper bounds of the simulated g-values
distances_net: A vector with the used network distances
distances_time: A vector with the used time distances
Examples
data(mtl_network)
data(bike_accidents)
# converting the Date field to a numeric field (counting days)
bike_accidents$Time <- as.POSIXct(bike_accidents$Date, format = "%Y/%m/%d")
start <- as.POSIXct("2016/01/01", format = "%Y/%m/%d")
bike_accidents$Time <- difftime(bike_accidents$Time, start, units = "days")
bike_accidents$Time <- as.numeric(bike_accidents$Time)
values <- k_nt_functions(
lines = mtl_network,
points = bike_accidents,
points_time = bike_accidents$Time,
start_net = 0 ,
end_net = 2000,
step_net = 10,
width_net = 200,
start_time = 0,
end_time = 360,
step_time = 7,
width_time = 14,
nsim = 50,
conf_int = 0.05,
digits = 2,
tol = 0.1,
resolution = NULL,
agg = 15,
verbose = TRUE)