Package 'DRHotNet'

Title: Differential Risk Hotspots in a Linear Network
Description: Performs the identification of differential risk hotspots (Briz-Redon et al. 2019) <doi:10.1016/j.aap.2019.105278> along a linear network. Given a marked point pattern lying on the linear network, the method implemented uses a network-constrained version of kernel density estimation (McSwiggan et al. 2017) <doi:10.1111/sjos.12255> to approximate the probability of occurrence across space for the type of event specified by the user through the marks of the pattern (Kelsall and Diggle 1995) <doi:10.2307/3318678>. The goal is to detect microzones of the linear network where the type of event indicated by the user is overrepresented.
Authors: Alvaro Briz-Redon
Maintainer: Alvaro Briz-Redon <[email protected]>
License: GPL-2
Version: 2.3
Built: 2025-02-18 05:12:06 UTC
Source: https://github.com/cran/DRHotNet

Help Index


Identifies differential risk hotspots along a linear network given a vector of relative probabilities computed over the middle points of the segments of the network

Description

Given a relative probability surface corresponding to the occurrence of a type of event along a linear network, this function filters and groups in hotspots those segments satisfying two conditions: 1) the relative probability in the segment exceeds the average relative probability per segment in k times the standard deviation of the complete set of probabilities estimated across all the segments of the network, and 2) there are n or more events at a distance below h from the middle point of the segment (h is obtained from the object rel_probs computed with the function relpnet). In summary, k and n control the formation of differential risk hotspots along the network, given a set of relative probabilities covering the network. The choice of a higher value for k or n (or both) represents a more strict criterion and leads to a lower number of differential risk hotspots being detected. Users should test several values of k and n (sensitivity analysis on k and n) in order to reach reasonable choices for the research or practical purposes of their data analyses. This sensitivity analysis can be carried out with the drsens function

Usage

drhot(X, rel_probs, k, n, dist = "path", event_distances = NULL)

Arguments

X

- A lpp object representing a marked point pattern lying on a road network (linnet object)

rel_probs

- An object containing the relative probabilities of a specific type of event along the linear network contained in X, generated through the function relpnet

k

- A numeric value that controls the procedure of detecting differential risk hotspots (departure from average relative probability), as described above

n

- A numeric value that controls the procedure of detecting differential risk hotspots (minimum size for the sample of events implicated in the computation of the relative probabilities), as described above

dist

- A character indicating which distance to use. Two values are allowed: path (shortest-path distance) and euclidean (Euclidean distance). By default, the shortest-path distance is used. Change to euclidean to reduce the computation time or skip memory issues

event_distances

- A matrix that contains the distances between the middle points of the segments satisfying the condition on parameter k and the events o X. By default it is set to NULL

Value

Returns a list that contains the differential risk hotspots found for X and the type of event specified by rel_probs

References

Briz-Redon, A., Martinez-Ruiz, F., & Montes, F. (2019). Identification of differential risk hotspots for collision and vehicle type in a directed linear network. Accident Analysis & Prevention, 132, 105278.

Examples

library(DRHotNet)
library(spatstat.geom)
library(spatstat.linnet)
library(spdep)
library(raster)
rel_assault <- relpnet(X = chicago, 
lixel_length = 50, h = 50, mark = "marks", category_mark = "assault")
hotspots_assault <- drhot(X = chicago, rel_probs = rel_assault, 
k = 0.5, n = 4)

Performs a sensitivity analysis on the parameters k and n that are provided to drhot

Description

Given a set of ks and ns parameters, this function allows the user to perform a sensitivity analysis on the parameters k and n by calling drhot for each combination of k and n

Usage

drsens(X, rel_probs, ks, ns)

Arguments

X

- A lpp object representing a marked point pattern lying on a road network (linnet object)

rel_probs

- An object containing the relative probabilities of a specific type of event along the linear network contained in X, generated through the function relpnet

ks

- A numeric vector of possible values for the k parameter that is provided to drhot

ns

- A numeric vector of possible values for the n parameter that is provided to drhot

Value

A matrix providing the type-specific prediction accuracy index that corresponds to the set differential risk hotspots obtained for each value of k or n provided in ks and ns, respectively. A NA value in this matrix indicates that no differential risk hotspots are found for the corresponding combination of k and n

References

Briz-Redon, A., Martinez-Ruiz, F., & Montes, F. (2019). Identification of differential risk hotspots for collision and vehicle type in a directed linear network. Accident Analysis & Prevention, 132, 105278.

Examples

library(DRHotNet)
library(spatstat.geom)
library(spatstat.linnet)
library(spdep)
library(raster)
rel_assault <- relpnet(X = chicago, 
lixel_length = 50, h = 50, mark = "marks", category_mark = "assault")
sensitivity_analysis <- drsens(X = chicago, rel_probs = rel_assault, 
ks = c(1,2), ns = c(30,40))

Performs a summary of a set of differential risk hotspots located along a linear network

Description

This function provides a basic summary of each differential risk hotspot provided in the object hotspots passed to the function. This includes the proportion of the type of event in each hotspot, the total length of the hotspot, a type-specific prediction accuracy index (PAI_t). Furthermore, this summary is also provided for an extension of each of the hotspots

Usage

drsummary(
  X,
  rel_probs,
  hotspots,
  order_extension = NULL,
  compute_p_value = F,
  n_it = 40
)

Arguments

X

- A lpp object representing a marked point pattern lying on a linear network (linnet object)

rel_probs

- An object containing the relative probabilities of a specific type of event along the linear network contained in X, generated through the function relpnet

hotspots

- A set of differential risk hotspots obtained with the function DiffHotspots_n_k

order_extension

- A natural number indicating a neighbourhood order to be used for constructing an extension of the differential risk hotspots. The summary is also given for the segments forming this extension

compute_p_value

- A logical value allowing the user to compute a p-value representing the statistical significance of each differential risk hotspot. It is set to FALSE by default

n_it

- Number of simulations performed for the estimation of the p-value (if compute_p_value = T)

Value

Returns a data.frame providing a summary of a set of differential risk hotspots. Each row of the output corresponds to one hotspot

Examples

library(DRHotNet)
library(spatstat.geom)
library(spatstat.linnet)
library(spdep)
library(raster)
rel_assault <- relpnet(X = chicago, 
lixel_length = 50, h = 50, mark = "marks", category_mark = "assault")
hotspots_assault <- drhot(X = chicago, rel_probs = rel_assault, 
k = 0.5, n = 4)
hotspots_summary <- drsummary(X = chicago, rel_probs = rel_assault, 
hotspots = hotspots_assault)

Creates the neighbourhood structure of a linear network

Description

Given a linear network structure, this function creates the neighbourhood matrix ("queen" criterion) associated to it. Two segments of the network are neighbours if they share a vertex

Usage

NeighbourhoodMatrixNetwork(network)

Arguments

network

- A linnet object representing a linear network structure

Value

Returns a listw object in "W" style

Examples

library(DRHotNet)
library(spatstat.geom)
library(spatstat.linnet)
library(spdep)
library(raster)
chicago_neighbourhood <- NeighbourhoodMatrixNetwork(chicago$domain)
class(chicago_neighbourhood)
chicago_neighbourhood$neighbours[[1]]

Plots an object obtained with DiffHotspots_n_k

Description

This function plots a set of differential risk hotspots located along a linear network. An extension of the hotspots (including the kth order neighbours of the segments of the hotspots) is also plotted

Usage

plothot(X, hotspots, order_extension = NULL, which.plot = NULL, eps_image = F)

Arguments

X

- A lpp object representing a marked point pattern lying on a road network (linnet object)

hotspots

- A set of differential risk hotspots obtained with the function DiffHotspots_n_k

order_extension

- A natural number indicating a neighbourhood order to be used for constructing an extension of the differential risk hotspots. The summary is also given for the segments forming this extension

which.plot

- A numeric vector indicating which differential risk hotspots to plot (according to the way they are ordered in hotspots)

eps_image

- If set to TRUE, an .eps image is generated. By default it is set to FALSE

Examples

library(DRHotNet)
library(spatstat.geom)
library(spatstat.linnet)
library(spdep)
library(raster)
rel_assault <- relpnet(X = chicago, 
lixel_length = 50, h = 50, mark = "marks", category_mark = "assault")
hotspots_assault <- drhot(X = chicago, rel_probs = rel_assault, 
k = 0.5, n = 4)
plothot(X = chicago, hotspots = hotspots_assault)

Plots an object obtained with relpnet

Description

This function plots the relative probability of occurrence of a type of event along a linear network

Usage

plotrelp(X, rel_probs, eps_image = F)

Arguments

X

- A lpp object representing a marked point pattern lying on a road network (linnet object)

rel_probs

- An object containing the relative probabilities of a specific type of event along the linear network contained in X, generated through the function relpnet

eps_image

- If set to TRUE, an .eps image is generated. By default it is set to FALSE

Examples

library(DRHotNet)
library(spatstat.geom)
library(spatstat.linnet)
library(spdep)
rel_assault <- relpnet(X = chicago, 
lixel_length = 50, h = 50, mark = "marks", category_mark = "assault")
plotrelp(X = chicago, rel_probs = rel_assault)

Computes the relative probability of observing a type of event along a linear network

Description

Given a marked point pattern lying on a linear network structure, this function uses kernel density estimation (KDE) to estimate a relative probability of occurrence for a type of event specified by the user through the marks of the pattern. The marks of a point pattern represent additional information of the events that are part of the pattern

Usage

relpnet(X, lixel_length, h, mark, category_mark, finespacing = F)

Arguments

X

- A lpp object representing a marked point pattern lying on a linear network (linnet object)

lixel_length

- A numeric value representing a lixel length that will be used for creating a split version of the network contained in X. Then, the length of all the segments of the split network is below lixel_length

h

- A numeric value representing the bandwidth parameter (in meters)

mark

- Mark of X that is used to characterize the type of event. The algorithm searches microzones of the network where this mark is over- or underrepresented

category_mark

- A numeric/character value from the set allowed in the chosen mark to compute the relative probability in relation to it

finespacing

- A logical value specifying whether to use a finer spatial resolution (with longer computation time but higher accuracy). It is set to FALSE by default

Value

Returns a list that contains the relative probability values estimated along the network for the type of event specified by mark and category_mark

References

Baddeley, A., Rubak, E., & Turner, R. (2015). Spatial point patterns: methodology and applications with R. Chapman and Hall/CRC.

Briz-Redon, A., Martinez-Ruiz, F., & Montes, F. (2019). Identification of differential risk hotspots for collision and vehicle type in a directed linear network. Accident Analysis & Prevention, 132, 105278.

Diggle, P. J. (2013). Statistical analysis of spatial and spatio-temporal point patterns. Chapman and Hall/CRC.

Kelsall, J. E., & Diggle, P. J. (1995). Kernel estimation of relative risk. Bernoulli, 1(1-2), 3-16.

McSwiggan, G., Baddeley, A., & Nair, G. (2017). Kernel density estimation on a linear network. Scandinavian Journal of Statistics, 44(2), 324-345.

Examples

library(DRHotNet)
library(spatstat.geom)
library(spatstat.linnet)
library(spdep)
library(raster)
rel_assault <- relpnet(X = chicago, 
lixel_length = 50, h = 50, mark = "marks", category_mark = "assault")

Marked point pattern on a road network simulating traffic accident locations

Description

A simulated lpp object representing traffic accidents lying on a road structure. The pattern is marked, with the following marks: Collision, Bicycle, Car, Lorry, Motorcycle, Public.bus, Private.bus and Van. The mark Collision is a factor, with the following possible values: Crossing, Fixed-object, Rear-end, Run-off-road, Run-over, Side. The remaining marks are numeric and binary

Usage

SampleMarkedPattern

Format

An object of class lpp (inherits from ppx) of length 3.