The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.

A correlation indicator based on spatial patterns

Install and load R packages

if (!requireNamespace("devtools")) {
    install.packages("devtools")
}
devtools::install_github("stscl/cisp",
                         build_vignettes = TRUE,
                         dep = TRUE)
library(cisp)

Spatial pattern correlation

Using the same data as the gdverse idsa vignette:

depression = system.file('extdata/Depression.csv',package = 'gdverse') |>
  readr::read_csv() |>
  sf::st_as_sf(coords = c('X','Y'), crs = 4326)
## Rows: 1072 Columns: 13
## ── Column specification ───────────────────────────────────────────────────────────────────────────
## Delimiter: ","
## dbl (13): X, Y, Depression_prevelence, PopulationDensity, Population65, NoHealthInsurance, Neig...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
depression
## Simple feature collection with 1072 features and 11 fields
## Geometry type: POINT
## Dimension:     XY
## Bounding box:  xmin: -83.1795 ymin: 32.11464 xmax: -78.6023 ymax: 35.17354
## Geodetic CRS:  WGS 84
## # A tibble: 1,072 × 12
##    Depression_prevelence PopulationDensity Population65 NoHealthInsurance Neighbor_Disadvantage
##  *                 <dbl>             <dbl>        <dbl>             <dbl>                 <dbl>
##  1                  23.1              61.5         22.5              7.98               -0.0525
##  2                  22.8              58.3         16.8             11.0                -0.254 
##  3                  23.2              35.9         24.5              9.31               -0.0540
##  4                  21.8              76.1         21.8             13.2                 0.0731
##  5                  20.7              47.3         22.0             11                   0.763 
##  6                  21.3              32.5         19.2             13.0                 0.422 
##  7                  22                36.9         19.2             10.8                 0.113 
##  8                  21.2              61.5         15.9              8.57               -0.154 
##  9                  22.7              67.2         15.7             17.8                -0.320 
## 10                  20.6             254.          11.3             12.7                 0.457 
## # ℹ 1,062 more rows
## # ℹ 7 more variables: Beer <dbl>, MentalHealthPati <dbl>, NatureParks <dbl>, Casinos <dbl>,
## #   DrinkingPlaces <dbl>, X.HouseRent <dbl>, geometry <POINT [°]>
system.time({
  g = cisp::spc(depression,cores = 12)
})
##    user  system elapsed 
##    5.54    1.00 2024.50
g
## ***   Spatial Pattern Correlation    
## 
## |          xv           |          yv           | correlation |
## |:---------------------:|:---------------------:|:-----------:|
## |   PopulationDensity   | Depression_prevelence |   0.04614   |
## |     Population65      | Depression_prevelence |   0.04150   |
## | Neighbor_Disadvantage | Depression_prevelence |   0.03924   |
## |    DrinkingPlaces     | Depression_prevelence |   0.01485   |
## |   NoHealthInsurance   | Depression_prevelence |   0.01384   |
## |      NatureParks      | Depression_prevelence |   0.01239   |
## |   MentalHealthPati    | Depression_prevelence |   0.01042   |
## |      X.HouseRent      | Depression_prevelence |   0.00777   |
## |         Beer          | Depression_prevelence |   0.00191   |
## |        Casinos        | Depression_prevelence |  -0.00708   |
## |      X.HouseRent      |   PopulationDensity   |   0.07832   |
## |   MentalHealthPati    |   PopulationDensity   |   0.01587   |
## |    DrinkingPlaces     |   PopulationDensity   |   0.01484   |
## |     Population65      |   PopulationDensity   |   0.01037   |
## |   NoHealthInsurance   |   PopulationDensity   |   0.00619   |
## |      NatureParks      |   PopulationDensity   |   0.00528   |
## |         Beer          |   PopulationDensity   |   0.00115   |
## |        Casinos        |   PopulationDensity   |   0.00108   |
## | Neighbor_Disadvantage |   PopulationDensity   |  -0.00529   |
## | Depression_prevelence |   PopulationDensity   |  -0.07737   |
## |      X.HouseRent      |     Population65      |   0.08942   |
## | Neighbor_Disadvantage |     Population65      |   0.04196   |
## |   PopulationDensity   |     Population65      |   0.02396   |
## | Depression_prevelence |     Population65      |   0.02231   |
## |   MentalHealthPati    |     Population65      |   0.00562   |
## |    DrinkingPlaces     |     Population65      |   0.00349   |
## |   NoHealthInsurance   |     Population65      |   0.00346   |
## |         Beer          |     Population65      |  -0.00529   |
## |      NatureParks      |     Population65      |  -0.00766   |
## |        Casinos        |     Population65      |  -0.00976   |
## | Neighbor_Disadvantage |   NoHealthInsurance   |   0.11050   |
## |      X.HouseRent      |   NoHealthInsurance   |   0.06270   |
## |     Population65      |   NoHealthInsurance   |   0.02928   |
## |   PopulationDensity   |   NoHealthInsurance   |   0.02298   |
## |    DrinkingPlaces     |   NoHealthInsurance   |   0.01302   |
## |        Casinos        |   NoHealthInsurance   |   0.00775   |
## |   MentalHealthPati    |   NoHealthInsurance   |   0.00657   |
## |         Beer          |   NoHealthInsurance   |   0.00434   |
## |      NatureParks      |   NoHealthInsurance   |   0.00197   |
## | Depression_prevelence |   NoHealthInsurance   |  -0.00779   |
## |    DrinkingPlaces     | Neighbor_Disadvantage |   0.09369   |
## |   NoHealthInsurance   | Neighbor_Disadvantage |   0.06840   |
## |      X.HouseRent      | Neighbor_Disadvantage |   0.06004   |
## |      NatureParks      | Neighbor_Disadvantage |   0.01924   |
## |     Population65      | Neighbor_Disadvantage |   0.01867   |
## |   MentalHealthPati    | Neighbor_Disadvantage |   0.01157   |
## |        Casinos        | Neighbor_Disadvantage |   0.00541   |
## |   PopulationDensity   | Neighbor_Disadvantage |  -0.00357   |
## | Depression_prevelence | Neighbor_Disadvantage |  -0.00665   |
## |         Beer          | Neighbor_Disadvantage |  -0.00989   |
## |        Casinos        |         Beer          |   0.04989   |
## |     Population65      |         Beer          |   0.01780   |
## |    DrinkingPlaces     |         Beer          |   0.01469   |
## |      NatureParks      |         Beer          |   0.01295   |
## | Neighbor_Disadvantage |         Beer          |   0.00331   |
## |   PopulationDensity   |         Beer          |   0.00211   |
## |   MentalHealthPati    |         Beer          |   0.00161   |
## |      X.HouseRent      |         Beer          |  -0.00016   |
## |   NoHealthInsurance   |         Beer          |  -0.00306   |
## | Depression_prevelence |         Beer          |  -0.03499   |
## |    DrinkingPlaces     |   MentalHealthPati    |   0.07590   |
## |   PopulationDensity   |   MentalHealthPati    |   0.03785   |
## |      NatureParks      |   MentalHealthPati    |   0.03208   |
## | Neighbor_Disadvantage |   MentalHealthPati    |   0.02471   |
## |        Casinos        |   MentalHealthPati    |   0.02460   |
## |         Beer          |   MentalHealthPati    |   0.01057   |
## |     Population65      |   MentalHealthPati    |   0.00982   |
## |      X.HouseRent      |   MentalHealthPati    |   0.00799   |
## | Depression_prevelence |   MentalHealthPati    |  -0.01049   |
## |   NoHealthInsurance   |   MentalHealthPati    |  -0.01681   |
## |    DrinkingPlaces     |      NatureParks      |   0.07349   |
## |   MentalHealthPati    |      NatureParks      |   0.03486   |
## |      X.HouseRent      |      NatureParks      |   0.02807   |
## | Neighbor_Disadvantage |      NatureParks      |   0.02704   |
## |   PopulationDensity   |      NatureParks      |   0.01846   |
## |   NoHealthInsurance   |      NatureParks      |   0.01689   |
## |         Beer          |      NatureParks      |   0.01029   |
## |        Casinos        |      NatureParks      |   0.00842   |
## |     Population65      |      NatureParks      |  -0.01961   |
## | Depression_prevelence |      NatureParks      |  -0.06237   |
## |    DrinkingPlaces     |        Casinos        |   0.05319   |
## |     Population65      |        Casinos        |   0.03494   |
## |         Beer          |        Casinos        |   0.02488   |
## |      NatureParks      |        Casinos        |   0.01989   |
## |   MentalHealthPati    |        Casinos        |   0.01854   |
## | Neighbor_Disadvantage |        Casinos        |   0.00293   |
## |   NoHealthInsurance   |        Casinos        |   0.00009   |
## |   PopulationDensity   |        Casinos        |  -0.00207   |
## |      X.HouseRent      |        Casinos        |  -0.00864   |
## | Depression_prevelence |        Casinos        |  -0.01344   |
## |      NatureParks      |    DrinkingPlaces     |   0.10000   |
## |   MentalHealthPati    |    DrinkingPlaces     |   0.04482   |
## |   PopulationDensity   |    DrinkingPlaces     |   0.03366   |
## |        Casinos        |    DrinkingPlaces     |   0.02222   |
## |         Beer          |    DrinkingPlaces     |   0.01330   |
## |   NoHealthInsurance   |    DrinkingPlaces     |   0.00258   |
## |      X.HouseRent      |    DrinkingPlaces     |   0.00185   |
## | Neighbor_Disadvantage |    DrinkingPlaces     |  -0.00400   |
## | Depression_prevelence |    DrinkingPlaces     |  -0.01162   |
## |     Population65      |    DrinkingPlaces     |  -0.03072   |
## |   PopulationDensity   |      X.HouseRent      |   0.12494   |
## | Neighbor_Disadvantage |      X.HouseRent      |   0.08995   |
## |     Population65      |      X.HouseRent      |   0.04227   |
## |   NoHealthInsurance   |      X.HouseRent      |   0.01481   |
## |    DrinkingPlaces     |      X.HouseRent      |   0.00667   |
## |   MentalHealthPati    |      X.HouseRent      |  -0.00175   |
## |        Casinos        |      X.HouseRent      |  -0.00581   |
## | Depression_prevelence |      X.HouseRent      |  -0.00587   |
## |         Beer          |      X.HouseRent      |  -0.00692   |
## |      NatureParks      |      X.HouseRent      |  -0.01047   |

The results are visualized in a default network graph style:

plot(g)
Figure 1. Spatial Pattern Correlation Network Visualization Results
Figure 1. Spatial Pattern Correlation Network Visualization Results

But the results can also be plotted using the classic correlation coefficient matrix visualization style:

plot(g,style = "matrix")
Figure 2. Spatial Pattern Correlation Matrix Visualization Results
Figure 2. Spatial Pattern Correlation Matrix Visualization Results

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.