Title: | Geographical Detectors for Assessing Spatial Factors |
---|---|
Description: | Geographical detectors for measuring spatial stratified heterogeneity, as described in Jinfeng Wang (2010) <doi:10.1080/13658810802443457> and Jinfeng Wang (2016) <doi:10.1016/j.ecolind.2016.02.052>. Includes the optimal discretization of continuous data, four primary functions of geographical detectors, comparison of size effects of spatial unit and the visualizations of results. To use the package and to refer the descriptions of the package, methods and case datasets, please cite Yongze Song (2020) <doi:10.1080/15481603.2020.1760434>. The model has been applied in factor exploration of road performance and multi-scale spatial segmentation for network data, as described in Yongze Song (2018) <doi:10.3390/rs10111696> and Yongze Song (2020) <doi:10.1109/TITS.2020.3001193>, respectively. |
Authors: | Yongze Song [aut, cph] , Wenbo Lv [aut, cre] |
Maintainer: | Wenbo Lv <[email protected]> |
License: | GPL-3 |
Version: | 10.9 |
Built: | 2024-11-20 14:20:38 UTC |
Source: | https://github.com/ausgis/GD |
Function for discretizing continuous data and obtaining the different outputs, including discretization intervals, numbers of values within intervals, and visualization of discretization.
disc(var, n, method = "quantile", ManualItv)
disc(var, n, method = "quantile", ManualItv)
var |
A numeric vector of continuous variable |
n |
The numeber of intervals |
method |
A character of discretization method |
ManualItv |
A numeric vector of manual intervals |
## method is default (quantile); number of intervals is 4 ds1 <- disc(ndvi_40$Tempchange, 4) ds1 ## method is equal; number of intervals is 4 ds2 <- disc(ndvi_40$Tempchange, 4, method = "equal") ## method is manual; number of intervals is 4 manualitv1 <- c(-0.5, 0, 1, 2, 4) ds3 <- disc(ndvi_40$Tempchange, 4, method = "manual", ManualItv = manualitv1)
## method is default (quantile); number of intervals is 4 ds1 <- disc(ndvi_40$Tempchange, 4) ds1 ## method is equal; number of intervals is 4 ds2 <- disc(ndvi_40$Tempchange, 4, method = "equal") ## method is manual; number of intervals is 4 manualitv1 <- c(-0.5, 0, 1, 2, 4) ds3 <- disc(ndvi_40$Tempchange, 4, method = "manual", ManualItv = manualitv1)
Function for calculating power determinant using factor detector of geographical detectors and visualization.
gd(formula, data = NULL) ## S3 method for class 'gd' print(x, ...) ## S3 method for class 'gd' plot(x, sig = TRUE, ...)
gd(formula, data = NULL) ## S3 method for class 'gd' print(x, ...) ## S3 method for class 'gd' plot(x, sig = TRUE, ...)
formula |
A formula of response and explanatory variables |
data |
A data.frame includes response and explanatory variables |
x |
A list of factor detector results |
sig |
If TRUE, only spatial associations that are significant at the 0.05 level will be plotted; If FALSE, all spatial associations will be plotted. |
... |
Ignore |
g1 <- gd(NDVIchange ~ Climatezone + Mining, data = ndvi_40) g1 plot(g1)
g1 <- gd(NDVIchange ~ Climatezone + Mining, data = ndvi_40) g1 plot(g1)
Function for ecological detector calculation, ecological matrix and visulization.
gdeco(formula, data = NULL) ## S3 method for class 'gdeco' print(x, ...) ## S3 method for class 'gdeco' plot(x, ...)
gdeco(formula, data = NULL) ## S3 method for class 'gdeco' print(x, ...) ## S3 method for class 'gdeco' plot(x, ...)
formula |
A formula of response and explanatory variables |
data |
A data.frame includes response and explanatory variables |
x |
A list of ecological detector results |
... |
Ignore |
ge1 <- gdeco(NDVIchange ~ Climatezone + Mining, data = ndvi_40) ge1 data <- ndvi_40[,1:3] ge2 <- gdeco(NDVIchange ~ ., data = data) ge2
ge1 <- gdeco(NDVIchange ~ Climatezone + Mining, data = ndvi_40) ge1 data <- ndvi_40[,1:3] ge2 <- gdeco(NDVIchange ~ ., data = data) ge2
Function for interaction detector calculation and visualization. The types of interactions include "Enhance, nonlinear", "Independent", "Enhance, bi-", "Weaken, uni-" and "Weaken, nonlinear".
gdinteract(formula, data = NULL) ## S3 method for class 'gdinteract' print(x, ...) ## S3 method for class 'gdinteract' plot(x, ...)
gdinteract(formula, data = NULL) ## S3 method for class 'gdinteract' print(x, ...) ## S3 method for class 'gdinteract' plot(x, ...)
formula |
A formula of response and explanatory variables |
data |
A data.frame includes response and explanatory variables |
x |
A list of interaction detector results |
... |
Ignore |
gi1 <- gdinteract(NDVIchange ~ Climatezone + Mining, data = ndvi_40) gi1 data <- ndvi_40[,1:3] gi2 <- gdinteract(NDVIchange ~ ., data = data) gi2
gi1 <- gdinteract(NDVIchange ~ Climatezone + Mining, data = ndvi_40) gi1 data <- ndvi_40[,1:3] gi2 <- gdinteract(NDVIchange ~ ., data = data) gi2
A one-step function for optimal discretization and geographical detectors for multiple variables and visualization.
gdm(formula, continuous_variable = NULL, data = NULL, discmethod, discitv) ## S3 method for class 'gdm' print(x, ...) ## S3 method for class 'gdm' plot(x, ...)
gdm(formula, continuous_variable = NULL, data = NULL, discmethod, discitv) ## S3 method for class 'gdm' print(x, ...) ## S3 method for class 'gdm' plot(x, ...)
formula |
A formula of response and explanatory variables |
continuous_variable |
A vector of continuous variable names |
data |
A data.frame includes response and explanatory variables |
discmethod |
A character vector of discretization methods |
discitv |
A numeric vector of numbers of intervals |
x |
A list of |
... |
Ignore |
############### ## NDVI: ndvi_40 ############### ## set optional parameters of optimal discretization ## optional methods: equal, natural, quantile, geometric, sd and manual discmethod <- c("equal","quantile") discitv <- c(4:5) ## "gdm" function ndvigdm <- gdm(NDVIchange ~ Climatezone + Mining + Tempchange, continuous_variable = c("Tempchange"), data = ndvi_40, discmethod = discmethod, discitv = discitv) ndvigdm plot(ndvigdm) ## Not run: ############# ## H1N1: h1n1_100 ############# ## set optional parameters of optimal discretization discmethod <- c("equal","natural","quantile") discitv <- c(4:6) continuous_variable <- colnames(h1n1_100)[-c(1,11)] ## "gdm" function h1n1gdm <- gdm(H1N1 ~ ., continuous_variable = continuous_variable, data = h1n1_100, discmethod = discmethod, discitv = discitv) h1n1gdm plot(h1n1gdm) ## End(Not run)
############### ## NDVI: ndvi_40 ############### ## set optional parameters of optimal discretization ## optional methods: equal, natural, quantile, geometric, sd and manual discmethod <- c("equal","quantile") discitv <- c(4:5) ## "gdm" function ndvigdm <- gdm(NDVIchange ~ Climatezone + Mining + Tempchange, continuous_variable = c("Tempchange"), data = ndvi_40, discmethod = discmethod, discitv = discitv) ndvigdm plot(ndvigdm) ## Not run: ############# ## H1N1: h1n1_100 ############# ## set optional parameters of optimal discretization discmethod <- c("equal","natural","quantile") discitv <- c(4:6) continuous_variable <- colnames(h1n1_100)[-c(1,11)] ## "gdm" function h1n1gdm <- gdm(H1N1 ~ ., continuous_variable = continuous_variable, data = h1n1_100, discmethod = discmethod, discitv = discitv) h1n1gdm plot(h1n1gdm) ## End(Not run)
Function for risk detector calculation, risk matrix and visualization.
gdrisk(formula, data = NULL) ## S3 method for class 'gdrisk' print(x, ...) ## S3 method for class 'gdrisk' plot(x, ...)
gdrisk(formula, data = NULL) ## S3 method for class 'gdrisk' print(x, ...) ## S3 method for class 'gdrisk' plot(x, ...)
formula |
A formula of response and explanatory variables |
data |
A data.frame includes response and explanatory variables |
x |
A list of risk detector results |
... |
Ignore |
gr1 <- gdrisk(NDVIchange ~ Climatezone + Mining, data = ndvi_40) gr1 plot(gr1) data <- ndvi_40[,1:3] gr2 <- gdrisk(NDVIchange ~ ., data = data) gr2
gr1 <- gdrisk(NDVIchange ~ Climatezone + Mining, data = ndvi_40) gr1 plot(gr1) data <- ndvi_40[,1:3] gr2 <- gdrisk(NDVIchange ~ ., data = data) gr2
The "H1N1" dataset provides provincial statistical incidences of influenza A virus subtype H1N1 in China for 2013. It includes H1N1 incidences and related variables across three different spatial grid sizes: 50 km, 100 km, and 150 km. Detailed references and data sources will be added.
h1n1_50 h1n1_100 h1n1_150
h1n1_50 h1n1_100 h1n1_150
h1n1_50
A data frame with 3977 rows and 11 variables (50 km grid size).
h1n1_100
A data frame with 987 rows and 11 variables (100 km grid size).
h1n1_150
A data frame with 443 rows and 11 variables (150 km grid size).
The "NDVI" dataset contains NDVI change data from 2010 to 2014 in Inner Mongolia, China. It includes NDVI change and potential variables sampled from six spatial grid sizes: 5 km, 10 km, 20 km, 30 km, 40 km, and 50 km. References for more details and data sources will be provided.
ndvi_5 ndvi_10 ndvi_20 ndvi_30 ndvi_40 ndvi_50
ndvi_5 ndvi_10 ndvi_20 ndvi_30 ndvi_40 ndvi_50
ndvi_5
A data frame with 46,295 rows and 7 variables (5 km grid size).
ndvi_10
A data frame with 11,567 rows and 7 variables (10 km grid size).
ndvi_20
A data frame with 2,892 rows and 7 variables (20 km grid size).
ndvi_30
A data frame with 1,290 rows and 7 variables (30 km grid size).
ndvi_40
A data frame with 713 rows and 7 variables (40 km grid size).
ndvi_50
A data frame with 469 rows and 7 variables (50 km grid size).
Optimal discretization for continuous variables and visualization.
optidisc(formula, data, discmethod = discmethod, discitv = discitv) ## S3 method for class 'optidisc' print(x, ...) ## S3 method for class 'optidisc' plot(x, ...)
optidisc(formula, data, discmethod = discmethod, discitv = discitv) ## S3 method for class 'optidisc' print(x, ...) ## S3 method for class 'optidisc' plot(x, ...)
formula |
A formula of response and explanatory variables, where the explanatory variables must be continuous variables to be discretized. |
data |
A data.frame includes response and explanatory variables |
discmethod |
A character vector of discretization methods |
discitv |
A numeric vector of numbers of intervals |
x |
A list of |
... |
Ignore |
## set optional discretization methods and numbers of intervals # optional methods: equal, natural, quantile, geometric, sd and manual discmethod <- c("equal","quantile") discitv <- c(4:5) ## optimal discretization odc1 <- optidisc(NDVIchange ~ Tempchange, ndvi_40, discmethod, discitv) odc1 plot(odc1)
## set optional discretization methods and numbers of intervals # optional methods: equal, natural, quantile, geometric, sd and manual discmethod <- c("equal","quantile") discitv <- c(4:5) ## optimal discretization odc1 <- optidisc(NDVIchange ~ Tempchange, ndvi_40, discmethod, discitv) odc1 plot(odc1)
Function for calculating risk means within intervals and visualization.
riskmean(formula, data = NULL) ## S3 method for class 'riskmean' print(x, ...) ## S3 method for class 'riskmean' plot(x, ...)
riskmean(formula, data = NULL) ## S3 method for class 'riskmean' print(x, ...) ## S3 method for class 'riskmean' plot(x, ...)
formula |
a formula of response and explanatory variables |
data |
a data.frame includes response and explanatory variables |
x |
a list of risk mean values |
... |
ignore |
rm1 <- riskmean(NDVIchange ~ Climatezone + Mining, data = ndvi_40) rm1 plot(rm1) data <- ndvi_40[,1:3] rm2 <- riskmean(NDVIchange ~ ., data = data) rm2
rm1 <- riskmean(NDVIchange ~ Climatezone + Mining, data = ndvi_40) rm1 plot(rm1) data <- ndvi_40[,1:3] rm2 <- riskmean(NDVIchange ~ ., data = data) rm2
Function for comparison of size effects of spatial units in spatial heterogeneity analysis.
sesu(gdlist, su)
sesu(gdlist, su)
gdlist |
A list of |
su |
A vector of sizes of spatial units |
ndvilist <- list(ndvi_30, ndvi_40, ndvi_50) su <- c(30, 40, 50) ## sizes of spatial units ## "gdm" function gdlist <- lapply(ndvilist, function(x){ gdm(NDVIchange ~ Climatezone + Mining, data = x) }) sesu(gdlist, su) ## size effects of spatial units
ndvilist <- list(ndvi_30, ndvi_40, ndvi_50) su <- c(30, 40, 50) ## sizes of spatial units ## "gdm" function gdlist <- lapply(ndvilist, function(x){ gdm(NDVIchange ~ Climatezone + Mining, data = x) }) sesu(gdlist, su) ## size effects of spatial units
The function v2m
is used in the functions
gdrisk
, gdinteract
and gdeco
for converting
a vector is from the results of the risk detector result,
interaction detector result or ecological detector to a lower
triangular matrix.
v2m(vec, diag = FALSE)
v2m(vec, diag = FALSE)
vec |
A data.frame of risk/interaction/ecological detector result of a strata variable |
diag |
TRUE/FALSE, indicating if the output matrix is a diagonal matrix. |