{'fraction_non_alphanumeric': 0.03590995898688206, 'fraction_numerical': 0.0147459378228609, 'mean_word_length': 4.873850680397205, 'pattern_counts': {'":': 1, '<': 14, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
DRHotNet: An R package for detecting differential risk hotspots on a linear network

One of the most common applications of spatial data analysis is detecting zones, at a certain investigation level, where a point-referenced event under study is especially concentrated. The detection of this kind of zones, which are usually referred to as hotspots, is essential in certain fields such as criminology, epidemiology or traffic safety. Traditionally, hotspot detection procedures have been developed over areal units of analysis. Although working at this spatial scale can be suitable enough for many research or practical purposes, detecting hotspots at a more accurate level (for instance, at the road segment level) may be more convenient sometimes. Furthermore, it is typical that hotspot detection procedures are entirely focused on the determination of zones where an event is (overall) highly concentrated. It is less common, by far, that such procedures prioritize the location of zones where a specific type of event is overrepresented in relation to the other types observed, which have been denoted as differential risk hotspots. The R package DRHotNet provides several functionalities to facilitate the detection of differential risk hotspots along a linear network. In this paper, DRHotNet is depicted and its usage in the R console is shown through a detailed analysis of a crime dataset.


Introduction
Hotspot detection basically consists in finding zones of a space where certain event is highly concentrated. There exists a wide variety of methods in literature that allow researchers to identify hotspots at a certain level of accuracy or spatial aggregation. Some of them have been massively used in the last decades, including certain local indicators of spatial association such as LISA (Anselin, 1995) or the Getis-Ord statistic (Getis and Ord, 1992), and the spatial scan statistic (Kulldorff, 1997). The first two of these methods are implemented in the R package spdep (Bivand et al., 2013), whereas the scan statistic is implemented in DCluster (Gómez-Rubio et al., 2005) (although there are other R packages that also provide an implementation of these methods). Furthermore, many new R packages focused on hotspot detection have been released in the last years, most of them being model-based and oriented to disease mapping studies that are carried out over administrative (areal) units (Allévius, 2018;Gómez-Rubio et al., 2019;Meyer et al., 2017).
However, the analysis of certain types of events requires detecting hotspots at a level of spatial accuracy greater than that provided by administrative or regular areal units. Indeed, many research studies of the fields of criminology (Andresen et al., 2017;Weisburd, 2015) and traffic safety (Briz-Redón et al., 2019b;Nie et al., 2015;Xie and Yan, 2013) that have been published in recent years were entirely carried out on road network structures rather than on administrative units. More specifically, some quantitative criminologists have estimated that around 60% of the total variability in crime incidence occurs at the street segment level (Schnell et al., 2017;Steenbeek and Weisburd, 2016), a fact that shows the essentiality of using road segments instead of areal structures to capture the spatial concentration of certain events more properly.
Fortunately, road network structures were introduced in the context of spatial statistics some years ago, providing the basis for analyzing events lying on such structures, which are usually referred to as linear networks. Indeed, a planar linear network, L, is defined as a finite collection of line segments, L = ∪ n i=1 li, in which each segment contains the points li = [ui, vi] = {tui +(1−t)vi : t ∈ [0, 1]} (Ang et al., 2012;Baddeley et al., 2015Baddeley et al., , 2017. Following graph theory nomenclature, these segments are sometimes referred to as the edges of the linear network, whereas the points that determine the extremes of such segments are known as the vertices of the network.
Hence, a point process X on L is a finite point process in the plane such that all points of X lie on the network L (Ang et al., 2012;Baddeley et al., 2015Baddeley et al., , 2017. Similarly, a collection of events that is observed on L is known as a point pattern, x, in L. In addition, when every event of a point pattern has one or several attributes, the point pattern is referred to as a marked point pattern. Each of the attributes, which can be in the form of either a numerical or a categorical variable, is known as a mark of the pattern. The investigation of spatial patterns lying on linear networks is gaining attention in the last years. The design of new and more accurate/efficient kernel density estimators Moradi et al., 2018Moradi et al., , 2019Rakshit et al., 2019b), the introduction of graph-related intensity measures (Eckardt and Mateu, 2018), the construction of local indicators of spatial association (Eckardt and Mateu, 2017), or the estimation of relative risks (McSwiggan et al., 2019) are some topics that have recently started developing for linear networks.
Besides the theoretical advances, it is worth noting that using linear networks for carrying out a spatial or spatio-temporal analysis entails certain technical difficulties. In this regard, the R package spatstat (Baddeley et al., 2015) provides multiple specific functions that allow R users to carry out statistical analyses on linear networks. Furthermore, efforts are constantly being made to reduce the computational cost of adapting certain classical spatial techniques to the singular case of linear networks (Rakshit et al., 2019a).
Despite the existing necessity of analyzing point-referenced data coming from certain fields of research at the street level, there are not many software tools fully designed for hotspot detection on road networks. One relevant contribution in this regard is the KDE+ software (Bíl et al., 2016), but this is not integrated in R. The package DRHotNet is specifically prepared for allowing R users to detect differential risk hotspots (zones where a type of event is overrepresented) along a linear network.
2 A procedure for detecting differential risk hotspots The procedure for differential risk hotspot detection available in DRHotNet was introduced by Briz- Redón et al. (2019a), who also show an application of the method considering a traffic accident dataset. Overall, hotspot detection methods can be classified into partition-, hierarchy-and density-based methods (Deng et al., 2019). The one implemented in DRHotNet belongs to the last of these three groups. Furthermore, from a statistical point of view, the method can be considered to be nonparametric, as no statistical model (with parameters) is involved.
Hence, the following subsections provide a description of each of the steps that are carried out by the DRHotNet package. The specification and exemplification of the functions required for each of them is given in following sections.

Estimating a relative probability surface
The first step consists in using kernel density estimation to infer the relative probability of occurrence for a certain type of event along a linear network. Assuming a marked point pattern {x1, ..., xn}, where a binary mark yi indicates if xi corresponds, or not, to the type of event of interest, the following expression (Kelsall and Diggle, 1998) is used to estimate this relative probability (which depends on kernel's bandwidth parameter, σ): where λσ(x) is computed according to the network-constrained equal-continuous kernel density estimation provided by McSwiggan et al. (2017). This version of kernel density is implemented in the function density.lpp of spatstat, which computes kernel density values rapidly by solving the classical heat equation defined on the linear network, as demonstrated by McSwiggan et al. (2017). Hence, pσ(x) approximates the relative probability of occurrence, at location x, of the type of event being represented by yi = 1. In simpler terms, Equation 1 allows establishing a relative probability surface that varies along the linear network. To this end, given a location, x, of the linear network, the events which mainly contribute to the estimation of λσ(x) are those situated within a linear radius (following the linear network structure) of σ meters from x. Thus, increasing the value of σ leads to smoother representations of the probability surface, whereas smaller values of the bandwidth parameter produce the opposite effect. On the choice of an optimal bandwidth parameter, the method described by McSwiggan et al. (2019) could be followed, which modifies previous proposals made for planar patterns (Kelsall and Diggle, 1995a,b).
Estimating a relative probability surface implies, in practice, estimating a relative probability value at the middle points of the segments forming the road network. In this regard, it is necessary to split the original road network structure into shorter line segments called lixels (Xie and Yan, 2008), which are basically the analogous to pixels for an areal space. This step provides accuracy and homogeneity to the process of hotspot formation. Then, the segments satisfying certain conditions (details are provided in the next section) are selected and joined together forming the differential risk hotspots.

Determining differential risk hotspots
Once a relative probability surface has been estimated along the linear network, it is time to detect differential risk hotspots. The procedure for their detection relies on two parameters k and n. Parameter k is used together with the standard deviation of all the relative probabilities estimated to define a threshold that needs to be exceeded to consider a segment as a candidate to be part of a differential risk hotspot. Then, parameter n is employed to select those segments, from the ones satisfying the threshold condition, that have n or more events at a distance lower than σ. More precisely, a segment, i, of the linear network is considered to be part of a differential risk hotspot if:p #{x ∈ {x1, ..., xn} : dL(x, mi) < σ} ≥ n where S is the number of segments of the linear network,pi is the relative probability of occurrence for the type of event of interest estimated at the middle point of segment i, # denotes the cardinality of a set, mi is the middle point of segment i and dL(x, mi) represents the shortest-path distance (distance along the network) between x and mi. The segments that fulfil the two conditions indicated above are then joined, forming differential risk hotspots. More precisely, two segments satisfying the aforementioned conditions belong to the same differential risk hotspot if they are neighbours. Given two segments of a linear network, a neighbouring relationship exists between them if they share a vertex of the network, which is equivalent to the queen criterion used for defining polygon neighbourhoods (Lloyd, 2010). This relationship between segments is referred to as a first-order one. Similarly, higher-order neighbouring relationships are defined recursively (for instance, for a second-order relationship): i and j are second-order neighbours if one neighbour of i and one neighbour of j are first-order neighbours.
3 Measuring differential risk hotspots importance and significance

The prediction accuracy index
Given a collection of hotspots identified in a planar space, Chainey et al. (2008) defined the prediction accuracy index (PAI) as follows: where n is the total number of events that lie on the hotspots, N is the total number of events observed, a is the area formed by all the hotspots together, and A is the total area of the space. Hence, a higher value of PAI is convenient from the perspective of hotspot detection, as it represents a higher concentration of the events in relation to the extension of the physical space that they occupy. This formula can be easily adapted to the case of linear networks using segment lengths in the place of areas.
In the context of detecting hotspots where the relative probability of one type of event is particularly high, the PAI needs to be modified. A type-specific version of the PAI (denoted by PAItype) was proposed in Briz-Redón et al. (2019a) (for linear networks): where ntype is the number of events of the type of interest that lie on the hotspots, Ntype is the total number of events of that type that are observed, l is the length of all the hotspots together, and L is the total length of the network. The interpretation of the PAItype is analogous to the one for the PAI, that is, a higher PAItype value indicates a higher proportion of the type of interest in relation to certain proportion of road network length. Some researchers have recently explored the possibility of using the number of segments (in total and within the hotspots) instead of segment length (Drawve and Wooditch, 2019) in the denominator of this formula, but we opted for segment length proportions. It is also worth noting that the PAItype can be computed for the whole set of differential risk hotspots detected, as indicated above, or for each differential risk hotspot, individually. The first option is useful for comparing the level of spatial concentration that two or more types of events show along the network, or for assessing the efficiency of different hotspot detection procedures. The second option is suitable to determine which differential risk hotspot maximizes the quotient between the proportion of the type and the proportion of road length spanned, which may be a representative value of the importance of the hotspot.

Estimating a p-value
Finally, assigning a statistical significance value to each differential risk hotspot is vital to reduce the possibility of focusing on certain microzones of the network that do not deserve such attention. Thus, a Monte Carlo approach was used to estimate an empirical p-value for each differential risk hotspot yielded by the previous step of the procedure. This approach is similar in spirit to the one proposed by Bíl et al. (2013), which is applied in the KDE+ software mentioned before. Getting back to previous notation, if {x1, ..., xn} is a marked point pattern and yi a binary mark that indicates if xi corresponds, or not, to the type of event under analysis, the Monte Carlo approach implemented consists in generating K simulated datasets where the locations are left fixed and the marks permutated. Concretely, this means to keep the locations {x1, ..., xn} and to obtain a new collection of marks defined by y k i = y ρ(i) , where k indicates the iteration number (k = 1, ..., K) and ρ is a permutation of the first n natural numbers. For each simulation, the average relative probability presented by each differential risk hotspot (a weighted average per segment length of the relative probabilities estimated at the middle points of the segments composing the hotspot) is computed. At the end of the K simulations, the average relative probability shown by the hotspots considering the real dataset (r) is compared with the simulated ones (ŝ k , k = 1, ..., K). The position of the real value in a numerically ordered vector formed by the simulated values and itself allows estimating an empirical p-value as follows: 4 Dealing with linear networks in R

Classes and functions
Linear networks can be represented in R by the class SpatialLines of package sp (Pebesma and Bivand, 2005;Bivand et al., 2013) or by simple features with package sf (Pebesma, 2018). However, the class linnet from the spatstat package is the optimal for doing spatial analysis and modelling on linear networks.
There are several functions in R that facilitate the conversion between SpatialLines and linnet objects. Specifically, as.linnet.SpatialLines from the maptools (Bivand and Lewin-Koh, 2017) R package converts SpatialLines into linnet objects, whereas the double application (in this order) of the as.psp and as.SpatialLines.psp functions of the spatstat and maptools packages, respectively, enable the conversion from a linnet object into a SpatialLines one.
Other useful functions available in spatstat for the use of linear networks are, for example, connected.linnet (computes the connected components of a linear network), diameter.linnet (computes the diameter and bounding radius of a linear network), insertVertices (inserts new vertices in a linear network) and thinNetwork (removes vertices or segments from a linear network).

Preprocessing the linear network
Despite not being strictly necessary, it can be convenient to preprocess the linear network in order to facilitate the subsequent statistical analysis. The SpNetPrep package (Briz-Redón, 2019) can be used for this purpose. The manual edition of the network, the addition of directionality and the curation of a point pattern lying on a network can be performed through a Shiny-based application implemented in this package if the linear network represents a road network (which is the most common scenario and the one we assume for the example shown in this paper). Furthermore, SpNetPrep contains a function, SimplifyLinearNetwork, that allows users to reduce network's complexity by merging some pairs of edges of the network that fulfil certain conditions with regard to length and angle between them. In this regard, another option is to use the gSimplify function of rgeos, which provides an implementation of the Douglas-Peuker algorithm for curve simplification (Douglas and Peucker, 1973).

Creating a point pattern on a linear network
Function lpp of package spatstat can be used to create an R object that represents a point pattern lying on a linear network. The lpp function only requires the coordinates of the events and a linnet object corresponding to a linear network. For instance, the following commands can be typed to create a point pattern of 100 points over the simplenet network provided by spatstat, which lies within the [0, 1] × [0, 1] window: > x <-runif(100, 0, 1) > y <-runif(100, 0, 1) > simplenet.lpp <-lpp(data.frame(x, y), simplenet) Marks can be attached to the points forming the pattern by introducing several more columns next to the x and y coordinates. For example, one can introduce a continuous random mark following a standard normal distribution, or a categorical random mark.

Using DRHotNet
This section shows the complete use of the DRHotNet package with a dataset of crime events recorded in Chicago (Illinois, US). First of all, the following R libraries have to be loaded to reproduce the example: > library(DRHotNet) > library(lubridate) > library(maptools) > library(raster) > library(rgeos) > library(sp) > library(SpNetPrep) > library(spatstat) > library(tigris)

Downloading and preparing the linear network
The examples provided in this section fully employs open data available for Chicago. First, geographic data from Chicago was downloaded from the United States Census Bureau through package tigris (Walker, 2016). Specifically, census tracts and the road network of the state of Massachusetts were loaded into the R console. The function intersect from the package raster (Hijmans, 2019) can be used. > cook.tracts <-tracts(state = "Illinois", county = "031") > class(cook.tracts) [1] "SpatialPolygonsDataFrame" attr(,"package") [1] "sp" > cook.network <-roads(state = "Illinois", county = "031") > class(cook.network) [1] "SpatialLinesDataFrame" attr(,"package") [1] "sp" The objects cook.tracts and cook.network are composed of 1319 polygons and 77698 lines, respectively (as of the end of September 2019). Now, both objects are used to construct a smaller road network that corresponds to the Near West Side Community Area of Chicago.
It is required that the network is fully connected in order to allow the computation of a distance between any pair of points. This can be checked with the function connected.   At this point, it is worth considering the possibility of reducing network's complexity. The function SimplifyLinearNetwork of SpNetPrep can be used for this purpose. A reasonable choice of the parameters is Angle = 20 and Length = 50 (Briz-Redón, 2019). This choice of the parameters means that a pair of segments meeting at a second-degree vertex is merged into one single segment if the angle they form (measured from 0 • to 90 • ) is lower than 20 • and if the length of each of them is lower than 50 m. Hence, network's complexity is reduced (in terms of number of segments and lines) while its geometry is preserved. The following lines of code execute SimplifyLinearNetwork and redefine chicago.SpLine according to the structure of the final linnet object. Thus, the final road network from Chicago that we use for the analysis has 3693 lines and 2564 vertices. An example of how SimplifyLinearNetwork reduces network's complexity is shown in Figure 2, which corresponds to a squared zone of Chicago's network with a diameter of 600 m.  The year, month and hour of occurrence of each crime can be extracted with the corresponding functions of the package lubridate (Grolemund and Wickham, 2011).

Downloading and preparing crime data
> chicago.crimes$year <-year(chicago.crimes$date_single) > chicago.crimes$month <-month(chicago.crimes$date_single) > chicago.crimes$hour <-hour(chicago.crimes$date_single) Then, a marked point pattern lying on chicago.linnet can be created with function lpp to provide the framework required by the DRHotNet package. A data.frame is passed to lpp including the coordinates of the events (in UTM), the type of event according to the receiver of the offense (offense_against), and the year, month and hour of occurrence that have been just computed.

Estimating a relative probability surface
The function RelativeProbabilityNetwork of DRHotNet has to be used at first to estimate a relative probability surface over the linear network. As it has been explained, this implies estimating a relative probability in the middle point of each segment of the network.
> rel_probs_persons <-RelativeProbabilityNetwork(X = X.chicago, lixel_length = 50, sigma = 250, mark = "offense_against", category_mark = "persons") In this example, an upper bound of 50 m is chosen for lixel's length. This means that segments shorter than 50 m are not split, whereas those longer than 50 m are split into several of no more than 50 m length. This operation is performed internally by RelativeProbabilityNetwork with the function lixellate from spatstat. The bandwidth parameter, σ, is set to 250 m. The mark and category_mark parameters are used to specify the type of event that is under analysis.
The exploration of the object rel_probs_persons with function str allows the user to check that the choice of a 50 m threshold for lixel's length produces 7614 segments along the network. Thus, a relative probability is estimated in the middle point of each of these segments, which can be accessed typing $probs: : chr "offense_against" $ category_mark: chr "persons" The function PlotRelativeProbabilities can then be used to obtain a map of the relative probability surface as the one shown in Figure 3b. Figure 3 also contains the relative probability surfaces corresponding to the choices of σ = 125 (Figure 3a), σ = 500 ( Figure 3c) and σ = 1000 (Figure 3d). It can be observed that the choice of a larger value for σ smooths the relative probability surface, which in the case of σ = 500 or σ = 1000 leads to the configuration of a small number of clearly distinguishable zones of the network in terms of the relative probability of offenses against persons. Indeed, whereas the use of σ = 125 allows the user to obtain quite extreme relative probability values at some segments of the network (the values vary from 0 to 0.99), choosing σ = 1000 causes that all the relative probabilities lie in the interval [0.07, 0.32].
In view of Figure 3, we consider that σ = 250 is a reasonable choice (although some procedures for bandwidth selection could be explored for taking this decision). Therefore, this selection of the bandwidth parameter is maintained to display now how the DRHotspots_k_n function of the package performs.

Detecting differential risk hotspots
The function DRHotspots_k_n needs four parameters to be specified: X (a point pattern on a linear network), rel_probs (an object like the one obtained in the previous step), k and n. Parameters k and n control the differential risk hotspot procedure, as it has been explained before. For example, we can try with k = 1 and n = 30: > hotspots_persons <-DRHotspots_k_n(X = X.chicago, rel_probs = rel_probs_persons, k = 1, n = 30) The output of the function DRHotspots_k_n presents the following structure: : chr "offense_against" $ category_mark: chr "persons" $ PAI_type : num 7.82 The first component of hotspots_persons contains the differential risk hotspots that have been detected for the values of k and n provided to DRHotspots_k_n. In this case, five differential risk hotspots are found, which are formed by 12, 12, 8, 1 and 2 road segments, respectively. The object hotspots_persons also contains the values of the parameters involved in the computation of the hotspots and a final component that includes the global PAItype for the set, which is 7.82 in this example.
The function SummaryDRHotspots can be used to provide a summary of each of the differential risk hotspots determined by DRHotspots_k_n: > summary_persons <-SummaryDRHotspots(X = X.chicago, rel_prob = rel_probs_persons, hotspots = hotspots_persons) The output of SummaryDRHotspots includes a count of the number of events located within each differential risk hotspot and how many of these correspond to the category "persons": The summary also contains the length (in meters) of each differential risk hotspot and the PAItype that corresponds to each of them: Furthermore, the output of SummaryDRHotspots also provides the same statistics for an extension of each of the hotspots. The reason to include this information is because if there are not many events available in the dataset (as it happens in this example), the method can determine differential risk hotspots where very few events, if any, have taken place. Indeed, in the output of SummaryDRHotspots shown above, there are two hotspots including zero events, one including only one, and two more containing a very reduced number of crimes. The fact of employing kernel density estimation to infer a relative probability surface makes more convenient to think of each differential risk hotspot as the union of a center or core (what DRHotspots_k_n returns, the hotspot itself) and an extension of it. Hence, by considering an extension of the differential risk hotspot one can better appreciate the zone of the network that has been accounted for in the estimation of the relative probability values corresponding to the segments of the hotspot.
By default, the extension computed by SummaryDRHotspots coincides with a neighbourhood of the segments forming each differential risk hotspot of order o = σ Lixel length (rounded to the nearest integer), although a different order can be specified through the parameter order_extension. In this example, we have o = 250 50 = 5, which is used by SummaryDRHotspots if no other order is indicated: > summary_persons[,c("Events type (ext)", "All events (ext)", "Prop. (ext)")] Events type ( It can be observed that all extensions of the differential risk hotspots include a reasonable number of events and that the corresponding proportions of offenses against persons are clearly above the global proportion for the dataset, which is 268/1326 ≈ 0.20. Therefore, the five differential risk hotspots detected with k = 1 and n = 30 are statistically significant (p < 0.05). It is worth noting, however, that the usual significance level of 0.05 should be reduced (corrected) if many differential risk hotspots are detected to avoid the presence of multiple comparison problems.

Choosing k and n
Remember that a higher value of either k or n represents using a more stringent criterion regarding hotspot detection. This is illustrated through the four maps available in Figure 4, which can be generated with the function PlotHotspots of DRHotNet. For instance, as in the following example for the object hotspots created previously (which corresponds to Figure 4d): > PlotHotspots(X = X.chicago, hotspots = hotspots) Indeed, Figure 4 shows the differential risk hotspots that DRHotspots_k_n detects for the choices of k = 0.5 and n = 20 (Figure 4a), k = 1.5 and n = 20 (Figure 4b), k = 1 and n = 10 (Figure 4c), and k = 1 and n = 30 (Figure 4d). Two of these combinations of conditions on k and n are implicitly represented by the other two. Consequently, the differential risk hotspots shown in Figure 4b are contained in Figure 4a, and those in Figure 4d are contained in Figure 4c. The choice of k = 1 and n = 30 leads to the highest global PAItype among the four combinations of parameters indicated, with the value of 15.6 mentioned before. In this regard, we recommend performing a sensitivity analysis on the values of k and n to decide which combination is more convenient. The sensitivity analysis carried out by Briz-Redón et al. (2019a) yielded that a choice around k = 1.5 and n = 45 was optimal in terms of the PAItype for the traffic accident dataset that was investigated. However, each dataset should require a specific analysis.
Thus, a sensitivity analysis on k and n can be carried out with the function Sensitivity_k_n. The user has to provide a point pattern (X), an object containing the relative probabilities of a type of event along the network (rel_probs) and a set of values for k and n (ks and ns, respectively): > sensitivity_analysis <-Sensitivity_k_n(X = X.chicago, rel_prob = rel_probs_persons, ks = seq(0,3,0.5), ns = seq(10,30,5)) > sensitivity_analysis n = 10 n = 15 n = 20 n = 25 n = 30 k = 0 The output from Sensitivity_k_n is a matrix that contains the PAItype values that correspond to each combination of k and n indicated by ks and ns. A NA value represents that no differential risk hotspots can be found for such combination of parameters. According to this matrix, the highest PAItype value is achieved for k = 2 and n = 15.
Therefore, one can choose the values of k and n that maximize the PAItype (considering the parameters provided in ks and ns) to determine the final set of differential risk hotspots. However, this criteria may lead sometimes to detect a very low number of differential risks hotspots and hence to miss zones of the network that may also deserve some attention. Hence, a more conservative approach could be considering several combinations of k and n that yield some of the highest values of PAItype and explore each set of differential risk hotspots associated. Then, one could investigate the output of SummaryDRHotspots for each combination of parameters (including the computation of p-values) to better decide which zones of the network are relevant for the type of event of interest.

Summary
The R package DRHotNet for detecting differential risk hotspots on linear networks has been described. The use of linear networks in the context of hotspot detection is becoming more important over the years, particularly in the fields of criminology and traffic safety. In addition, it is also of great interest sometimes to detect zones of a linear network where certain type of event is especially overrepresented. Hence, DRHotNet consists of an easy-to-use tool implemented in R to accurately locate the microzones of a linear network where the incidence of a type of event is considerably higher than in the rest of it.   Figure 5: Outputs from the function PlotHotspots for the marks year_after_2012, month_winter and hour_21_3 and the categorical value Yes for the three, considering the combinations of k and n that maximize the PAI type (for the values of k and n tested).