The intensitynet package provides tools to analyze point patterns in
space over planar network structures derived from graph-related
intensity measures for undirected, directed, and mixed networks. This
package is based on the research done by Eckardt, M., Mateu, J.
presented in the following papers:
Eckardt, M., Mateu, J.
Point Patterns Occurring on Complex Structures in Space and Space-Time:
An Alternative Network Approach. Journal of Computational and Graphical
Statistics 27. 312-322 (2017).
10.1080/10618600.2017.1391695
Eckardt, M., Mateu, J. Second-order and local characteristics
of network intensity functions. TEST 30, 318-340 (2021).
10.1007/s11749-020-00720-4
You can install the released version of intensitynet from CRAN with:
install.packages("intensitynet")
And the development version from GitHub with:
# install.packages("devtools")
::install_github("LlagosteraPol/intensitynet") devtools
This is an example that shows you how to set up intensitynet and calculate and plot the Geary-c correlation:
library(intensitynet)
library(spatstat)
#> Loading required package: spatstat.data
#> Loading required package: spatstat.geom
#> spatstat.geom 2.3-1
#> Loading required package: spatstat.core
#> Loading required package: nlme
#> Loading required package: rpart
#> spatstat.core 2.3-2
#> Loading required package: spatstat.linnet
#> spatstat.linnet 2.3-1
#>
#> spatstat 2.3-0 (nickname: 'That's not important right now')
#> For an introduction to spatstat, type 'beginner'
data(chicago)
<- as.data.frame(chicago[["data"]]) # Get as dataframe the data from Chicago
chicago_df
# Get the adjacency matrix. One way is to create an igraph object from the edge coordinates.
<- cbind(chicago[["domain"]][["from"]], chicago[["domain"]][["to"]])
edges <- igraph::graph_from_edgelist(edges)
chicago_net
# And then use the igraph function 'as_adjacency_matrix'
<- as.matrix(igraph::as_adjacency_matrix(chicago_net))
chicago_adj_mtx <- data.frame(xcoord = chicago[["domain"]][["vertices"]][["x"]],
chicago_node_coords ycoord = chicago[["domain"]][["vertices"]][["y"]])
# Create the intensitynet object, in this case will be undirected
<- intensitynet(chicago_adj_mtx,
intnet_chicago node_coords = chicago_node_coords,
event_data = chicago_df)
<- RelateEventsToNetwork(intnet_chicago)
intnet_chicago #> Calculating edge intensities...
#> ================================================================================
#> Calculating node intensities...
#> ================================================================================
<- NodeLocalCorrelation(intnet_chicago, dep_type = 'geary', intensity = igraph::vertex_attr(intnet_chicago$graph)$intensity)
data_geary <- data_geary$correlation
geary_c <- data_geary$intnet
intnet_chicago
PlotHeatmap(intnet_chicago, heattype='geary')