| Title: | Analysis of Spatial Stratified Heterogeneity |
|---|---|
| Description: | Detecting spatial associations via spatial stratified heterogeneity, accounting for spatial dependencies, interpretability, complex interactions, and robust stratification. In addition, it supports the spatial stratified heterogeneity family described in Lv et al. (2025)<doi:10.1111/tgis.70032>. |
| Authors: | Wenbo Lyu [aut, cre, cph] (ORCID: <https://orcid.org/0009-0002-6003-3800>), Yangyang Lei [aut] (ORCID: <https://orcid.org/0009-0002-6518-3613>), Fangmei Liu [aut] (ORCID: <https://orcid.org/0009-0008-8634-7588>), Jianwu Yan [aut] (ORCID: <https://orcid.org/0000-0001-9411-8453>), Yongze Song [aut] (ORCID: <https://orcid.org/0000-0003-3420-9622>), Wufan Zhao [aut] (ORCID: <https://orcid.org/0000-0002-0265-3465>) |
| Maintainer: | Wenbo Lyu <[email protected]> |
| License: | GPL-3 |
| Version: | 1.7 |
| Built: | 2026-06-05 09:44:04 UTC |
| Source: | https://github.com/stscl/gdverse |
convert all discretized vectors to integer
all2int(x)all2int(x)
x |
A discretized vector. |
An integer vector.
all2int(factor(letters[1:3],levels = c('b','a','c'))) all2int(letters[1:3])all2int(factor(letters[1:3],levels = c('b','a','c'))) all2int(letters[1:3])
Function for determining the optimal spatial data discretization based on SPADE q-statistics.
cpsd_disc( formula, data, wt, discnum = 3:8, discmethod = "quantile", strategy = 2L, increase_rate = 0.05, cores = 1, seed = 123456789, ... )cpsd_disc( formula, data, wt, discnum = 3:8, discmethod = "quantile", strategy = 2L, increase_rate = 0.05, cores = 1, seed = 123456789, ... )
formula |
A formula of optimal spatial data discretization. |
data |
A |
wt |
The spatial weight matrix. |
discnum |
(optional) A vector of number of classes for discretization. Default is |
discmethod |
(optional) The discretization methods. Default all use |
strategy |
(optional) Discretization strategy. When |
increase_rate |
(optional) The critical increase rate of the number of discretization.
Default is |
cores |
(optional) Positive integer (default is 1). When cores are greater than 1, use multi-core parallel computing. |
seed |
(optional) Random seed number, default is |
... |
(optional) Other arguments passed to |
A list.
xdiscretization variable name
koptimal number of spatial data discreteization
methodoptimal spatial data discretization method
discthe result of optimal spatial data discretization
When the discmethod is configured to robust, it will operate at a significantly reduced speed.
Consequently, the use of robust discretization is not advised.
Yongze Song & Peng Wu (2021) An interactive detector for spatial associations, International Journal of Geographical Information Science, 35:8, 1676-1701, DOI:10.1080/13658816.2021.1882680
data('sim') wt = sdsfun::inverse_distance_swm(sf::st_as_sf(sim,coords = c('lo','la'))) cpsd_disc(y ~ xa + xb + xc, data = sim, wt = wt)data('sim') wt = sdsfun::inverse_distance_swm(sf::st_as_sf(sim,coords = c('lo','la'))) cpsd_disc(y ~ xa + xb + xc, data = sim, wt = wt)
Function for calculate compensated power of spatial determinant Q_s.
cpsd_spade(yobs, xobs, xdisc, wt)cpsd_spade(yobs, xobs, xdisc, wt)
yobs |
Variable Y |
xobs |
The original undiscretized covariable X. |
xdisc |
The discretized covariable X. |
wt |
The spatial weight matrix. |
The power of compensated spatial determinant formula is
A value of compensated power of spatial determinant Q_s.
Xuezhi Cang & Wei Luo (2018) Spatial association detector (SPADE),International Journal of Geographical Information Science, 32:10, 2055-2075, DOI: 10.1080/13658816.2018.1476693
data('sim') wt = sdsfun::inverse_distance_swm(sf::st_as_sf(sim,coords = c('lo','la'))) xa = sim$xa xa_disc = sdsfun::discretize_vector(xa,5) cpsd_spade(sim$y,xa,xa_disc,wt)data('sim') wt = sdsfun::inverse_distance_swm(sf::st_as_sf(sim,coords = c('lo','la'))) xa = sim$xa xa_disc = sdsfun::discretize_vector(xa,5) cpsd_spade(sim$y,xa,xa_disc,wt)
Compare the effects of two factors and on the spatial distribution of the attribute .
ecological_detector(y, x1, x2, alpha = 0.95)ecological_detector(y, x1, x2, alpha = 0.95)
y |
Dependent variable, continuous numeric vector. |
x1 |
Covariate |
x2 |
Covariate |
alpha |
(optional) Confidence level of the interval,default is |
A list.
F-statisticthe result of F statistic for ecological detector
P-valuethe result of P value for ecological detector
Ecologicalis there a significant difference between the two factors and on the spatial distribution of the attribute
ecological_detector(y = 1:7, x1 = c('x',rep('y',3),rep('z',3)), x2 = c(rep('a',2),rep('b',2),rep('c',3)))ecological_detector(y = 1:7, x1 = c('x',rep('y',3),rep('z',3)), x2 = c(rep('a',2),rep('b',2),rep('c',3)))
Function for measure information loss by shannon information entropy.
F_informationloss(xvar, xdisc)F_informationloss(xvar, xdisc)
xvar |
The original undiscretized vector. |
xdisc |
The discretized vector. |
The information loss measured by information entropy formula is
A numeric value of information loss measured by information entropy.
F_informationloss(1:7,c('x',rep('y',3),rep('z',3)))F_informationloss(1:7,c('x',rep('y',3),rep('z',3)))
The factor detector q-statistic measures the spatial stratified heterogeneity of a variable Y, or the determinant power of a covariate X of Y.
factor_detector(y, x, confintv = FALSE, alpha = 0.95)factor_detector(y, x, confintv = FALSE, alpha = 0.95)
y |
Variable Y, continuous numeric vector. |
x |
Covariate X, |
confintv |
(optional) Whether to compute the confidence interval for the q statistic,
default is |
alpha |
(optional) Confidence level of the interval, default is |
A list.
Q-statisticthe q statistic for factor detector
P-valuethe p value for factor detector
CILthe confidence interval lower bound
CIUthe confidence interval upper bound
factor_detector(y = 1:7,x = c('x',rep('y',3),rep('z',3)))factor_detector(y = 1:7,x = c('x',rep('y',3),rep('z',3)))
native geographical detector(GD) model
gd(formula, data, type = "factor", alpha = 0.95)gd(formula, data, type = "factor", alpha = 0.95)
formula |
A formula of geographical detector model. |
data |
A |
type |
(optional) The type of geographical detector, which must be one of |
alpha |
(optional) Specifies the size of the alpha (confidence level). Default is |
A list.
factorthe result of factor detector
interactionthe result of interaction detector
riskthe result of risk detector
ecologicalthe result of ecological detector
Jin‐Feng Wang, Xin‐Hu Li, George Christakos, Yi‐Lan Liao, Tin Zhang, XueGu & Xiao‐Ying Zheng (2010) Geographical Detectors‐Based Health Risk Assessment and its Application in the Neural Tube Defects Study of the Heshun Region, China, International Journal of Geographical Information Science, 24:1, 107-127, DOI: 10.1080/13658810802443457
data("NTDs") g = gd(incidence ~ watershed + elevation + soiltype, data = NTDs,type = c('factor','interaction')) gdata("NTDs") g = gd(incidence ~ watershed + elevation + soiltype, data = NTDs,type = c('factor','interaction')) g
optimal univariate discretization based on geodetector q-statistic
gd_optunidisc( formula, data, discnum = 3:8, discmethod = c("sd", "equal", "geometric", "quantile", "natural"), cores = 1, seed = 123456789, ... )gd_optunidisc( formula, data, discnum = 3:8, discmethod = c("sd", "equal", "geometric", "quantile", "natural"), cores = 1, seed = 123456789, ... )
formula |
A formula. |
data |
A |
discnum |
(optional) A vector of numbers of discretization. Default is |
discmethod |
(optional) A vector of methods for discretization, default is using
|
cores |
(optional) Positive integer (default is 1). When cores are greater than 1, use multi-core parallel computing. |
seed |
(optional) Random seed number, default is |
... |
(optional) Other arguments passed to |
A list.
xthe name of the variable that needs to be discretized
koptimal discretization number
methodoptimal discretization method
qstatisticoptimal q-statistic
discoptimal discretization results
data('sim') gd_optunidisc(y ~ xa + xb + xc, data = sim, discnum = 3:6)data('sim') gd_optunidisc(y ~ xa + xb + xc, data = sim, discnum = 3:6)
generate permutations
gen_permutations(x, seed = 123456789)gen_permutations(x, seed = 123456789)
x |
A vector. |
seed |
(optional) Random seed number. Default is |
A permutations vector.
gen_permutations(1:100,42)gen_permutations(1:100,42)
geographical detector
geodetector(formula, data, type = "factor", alpha = 0.95)geodetector(formula, data, type = "factor", alpha = 0.95)
formula |
A formula of geographical detector model. |
data |
A data.frame or tibble of observation data. |
type |
(optional) The type of geographical detector, which must be one of |
alpha |
(optional) Specifies the size of the alpha (confidence level). Default is |
A list.
factorthe result of factor detector
interactionthe result of interaction detector
riskthe result of risk detector
ecologicalthe result of ecological detector
Note that only one type of geodetector is supported at a time in geodetector().
geodetector(y ~ x1 + x2, tibble::tibble(y = 1:7, x1 = c('x',rep('y',3),rep('z',3)), x2 = c(rep('a',2),rep('b',2),rep('c',3)))) geodetector(y ~ x1 + x2, tibble::tibble(y = 1:7, x1 = c('x',rep('y',3),rep('z',3)), x2 = c(rep('a',2),rep('b',2),rep('c',3))), type = 'interaction') geodetector(y ~ x1 + x2, tibble::tibble(y = 1:7, x1 = c('x',rep('y',3),rep('z',3)), x2 = c(rep('a',2),rep('b',2),rep('c',3))), type = 'risk',alpha = 0.95) geodetector(y ~ x1 + x2, tibble::tibble(y = 1:7, x1 = c('x',rep('y',3),rep('z',3)), x2 = c(rep('a',2),rep('b',2),rep('c',3))), type = 'ecological',alpha = 0.95)geodetector(y ~ x1 + x2, tibble::tibble(y = 1:7, x1 = c('x',rep('y',3),rep('z',3)), x2 = c(rep('a',2),rep('b',2),rep('c',3)))) geodetector(y ~ x1 + x2, tibble::tibble(y = 1:7, x1 = c('x',rep('y',3),rep('z',3)), x2 = c(rep('a',2),rep('b',2),rep('c',3))), type = 'interaction') geodetector(y ~ x1 + x2, tibble::tibble(y = 1:7, x1 = c('x',rep('y',3),rep('z',3)), x2 = c(rep('a',2),rep('b',2),rep('c',3))), type = 'risk',alpha = 0.95) geodetector(y ~ x1 + x2, tibble::tibble(y = 1:7, x1 = c('x',rep('y',3),rep('z',3)), x2 = c(rep('a',2),rep('b',2),rep('c',3))), type = 'ecological',alpha = 0.95)
geographically optimal zones-based heterogeneity(GOZH) model
gozh(formula, data, cores = 1, type = "factor", alpha = 0.95, ...)gozh(formula, data, cores = 1, type = "factor", alpha = 0.95, ...)
formula |
A formula of GOZH model. |
data |
A |
cores |
(optional) Positive integer (default is 1). When cores are greater than 1, use multi-core parallel computing. |
type |
(optional) The type of geographical detector, which must be |
alpha |
(optional) Specifies the size of confidence level. Default is |
... |
(optional) Other arguments passed to |
A list.
factorthe result of factor detector
interactionthe result of interaction detector
riskthe result of risk detector
ecologicalthe result of ecological detector
Luo, P., Song, Y., Huang, X., Ma, H., Liu, J., Yao, Y., & Meng, L. (2022). Identifying determinants of spatio-temporal disparities in soil moisture of the Northern Hemisphere using a geographically optimal zones-based heterogeneity model. ISPRS Journal of Photogrammetry and Remote Sensing: Official Publication of the International Society for Photogrammetry and Remote Sensing (ISPRS), 185, 111–128. https://doi.org/10.1016/j.isprsjprs.2022.01.009
data('ndvi') g = gozh(NDVIchange ~ ., data = ndvi) gdata('ndvi') g = gozh(NDVIchange ~ ., data = ndvi) g
Function for geographically optimal zones-based heterogeneity detector.
gozh_detector(formula, data, cores = 1, type = "factor", alpha = 0.95, ...)gozh_detector(formula, data, cores = 1, type = "factor", alpha = 0.95, ...)
formula |
A formula of GOZH detector. |
data |
A data.frame or tibble of observation data. |
cores |
(optional) Positive integer (default is 1). When cores are greater than 1, use multi-core parallel computing. |
type |
(optional) The type of geographical detector,which must be one of |
alpha |
(optional) Confidence level of the interval,default is |
... |
(optional) Other arguments passed to |
A list of tibble with the corresponding result under different detector types.
factorthe result of factor detector
interactionthe result of interaction detector
riskthe result of risk detector
ecologicalthe result of ecological detector
Only one type of detector is supported in a gozh_detector() run at a time.
Luo, P., Song, Y., Huang, X., Ma, H., Liu, J., Yao, Y., & Meng, L. (2022). Identifying determinants of spatio-temporal disparities in soil moisture of the Northern Hemisphere using a geographically optimal zones-based heterogeneity model. ISPRS Journal of Photogrammetry and Remote Sensing: Official Publication of the International Society for Photogrammetry and Remote Sensing (ISPRS), 185, 111–128. https://doi.org/10.1016/j.isprsjprs.2022.01.009
data('ndvi') g = gozh_detector(NDVIchange ~ ., data = ndvi) gdata('ndvi') g = gozh_detector(NDVIchange ~ ., data = ndvi) g
interactive detector for spatial associations(IDSA) model
idsa( formula, data, wt = NULL, discnum = 3:8, discmethod = "quantile", overlay = "and", strategy = 2L, increase_rate = 0.05, cores = 1, seed = 123456789, alpha = 0.95, ... )idsa( formula, data, wt = NULL, discnum = 3:8, discmethod = "quantile", overlay = "and", strategy = 2L, increase_rate = 0.05, cores = 1, seed = 123456789, alpha = 0.95, ... )
formula |
A formula of IDSA model. |
data |
A |
wt |
(optional) The spatial weight matrix. When |
discnum |
(optional) Number of multilevel discretization. Default will use |
discmethod |
(optional) The discretization methods. Default all use |
overlay |
(optional) Spatial overlay method. One of |
strategy |
(optional) Discretization strategy. When |
increase_rate |
(optional) The critical increase rate of the number of discretization.
Default is |
cores |
(optional) Positive integer (default is 1). When cores are greater than 1, use multi-core parallel computing. |
seed |
(optional) Random number seed, default is |
alpha |
(optional) Specifies the size of confidence level. Default is |
... |
(optional) Other arguments passed to |
A list.
interactionthe interaction result of IDSA model
riskwhether values of the response variable between a pair of overlay zones are significantly different
number_individual_explanatory_variablesthe number of individual explanatory variables used for examining the interaction effects
number_overlay_zonesthe number of overlay zones
percentage_finely_divided_zonesthe percentage of finely divided zones that are determined by the interaction of variables
Please note that all variables in the IDSA model need to be continuous data.
The IDSA model requires at least calculations when has explanatory variables.
When there are more than 10 explanatory variables, carefully consider the computational burden of this model.
When there are a large number of explanatory variables, the data dimensionality reduction method can be used
to ensure the trade-off between analysis results and calculation speed.
Yongze Song & Peng Wu (2021) An interactive detector for spatial associations, International Journal of Geographical Information Science, 35:8, 1676-1701, DOI:10.1080/13658816.2021.1882680
data('sim') sim1 = sf::st_as_sf(sim,coords = c('lo','la')) g = idsa(y ~ ., data = sim1) gdata('sim') sim1 = sf::st_as_sf(sim,coords = c('lo','la')) g = idsa(y ~ ., data = sim1) g
Identify the interaction between different risk factors, that is, assess whether factors X1 and X2 together increase or decrease the explanatory power of the dependent variable Y, or whether the effects of these factors on Y are independent of each other.
interaction_detector(y, x1, x2)interaction_detector(y, x1, x2)
y |
Dependent variable, continuous numeric vector. |
x1 |
Covariate |
x2 |
Covariate |
A list.
Variable1 Q-statisticsQ-statistics for variable1
Variable2 Q-statisticsQ-statistics for variable2
Variable1 and Variable2 interact Q-statisticsQ-statistics for variable1 and variable2 interact
Interactionthe interact result type
Variable1 P-valueP-value of the Q-statistic for Variable1
Variable2 P-valueP-value of the Q-statistic for Variable2
Variable1 and Variable2 interact P-valueP-value of the Q-statistic for variable1 and variable2 interact
interaction_detector(y = 1:7, x1 = c('x',rep('y',3),rep('z',3)), x2 = c(rep('a',2),rep('b',2),rep('c',3)))interaction_detector(y = 1:7, x1 = c('x',rep('y',3),rep('z',3)), x2 = c(rep('a',2),rep('b',2),rep('c',3)))
locally explained stratified heterogeneity(LESH) model
lesh(formula, data, cores = 1, ...)lesh(formula, data, cores = 1, ...)
formula |
A formula of LESH model. |
data |
A |
cores |
(optional) Positive integer (default is 1). When cores are greater than 1, use multi-core parallel computing. |
... |
(optional) Other arguments passed to |
A list.
interactionthe interaction result of LESH model
spd_lesha tibble of the shap power of determinants
The LESH model requires at least calculations when has explanatory variables.
When there are more than 10 explanatory variables, carefully consider the computational burden of this model.
When there are a large number of explanatory variables, the data dimensionality reduction method can be used
to ensure the trade-off between analysis results and calculation speed.
Li, Y., Luo, P., Song, Y., Zhang, L., Qu, Y., & Hou, Z. (2023). A locally explained heterogeneity model for examining wetland disparity. International Journal of Digital Earth, 16(2), 4533–4552. https://doi.org/10.1080/17538947.2023.2271883
data('ndvi') g = lesh(NDVIchange ~ ., data = ndvi) gdata('ndvi') g = lesh(NDVIchange ~ ., data = ndvi) g
Function for determining optimal spatial data analysis scale based on locally estimated scatter plot smoothing (LOESS) model.
loess_optscale(qvec, spscalevec, increase_rate = 0.05)loess_optscale(qvec, spscalevec, increase_rate = 0.05)
qvec |
A numeric vector of q statistics. |
spscalevec |
A numeric vector of spatial scales corresponding to |
increase_rate |
(optional) The critical increase rate of the number of discretization.
Default is |
A numeric vector about optimal number of spatial scale and the critical increase rate of q value.
## Not run: ## The following code takes a long time to run: library(tidyverse) fvcpath = "https://github.com/SpatLyu/rdevdata/raw/main/FVC.tif" fvc = terra::rast(paste0("/vsicurl/",fvcpath)) fvc1000 = fvc %>% terra::as.data.frame(na.rm = T) %>% as_tibble() fvc5000 = fvc %>% terra::aggregate(fact = 5) %>% terra::as.data.frame(na.rm = T) %>% as_tibble() qv1000 = factor_detector(fvc1000$fvc, sdsfun::discretize_vector(fvc1000$premax,10,'quantile'))[[1]] qv5000 = factor_detector(fvc5000$fvc, sdsfun::discretize_vector(fvc5000$premax,10,'quantile'))[[1]] loess_optscale(c(qv1000,qv5000),c(1000,5000)) ## End(Not run)## Not run: ## The following code takes a long time to run: library(tidyverse) fvcpath = "https://github.com/SpatLyu/rdevdata/raw/main/FVC.tif" fvc = terra::rast(paste0("/vsicurl/",fvcpath)) fvc1000 = fvc %>% terra::as.data.frame(na.rm = T) %>% as_tibble() fvc5000 = fvc %>% terra::aggregate(fact = 5) %>% terra::as.data.frame(na.rm = T) %>% as_tibble() qv1000 = factor_detector(fvc1000$fvc, sdsfun::discretize_vector(fvc1000$premax,10,'quantile'))[[1]] qv5000 = factor_detector(fvc5000$fvc, sdsfun::discretize_vector(fvc5000$premax,10,'quantile'))[[1]] loess_optscale(c(qv1000,qv5000),c(1000,5000)) ## End(Not run)
dataset of NDVI changes and its influencing factors, modified from GD package.
ndvindvi
ndvi: A tibble with 713 rows and 7 variables
Yongze Song [email protected]
The data were obtained by preprocessing use sf and tidyverse.
NTDsNTDs
NTDs: A tibble with 185 rows and 4 variable columns and 2 location columns, modified from geodetector package.
optimal parameters-based geographical detector(OPGD) model
opgd( formula, data, discvar = NULL, discnum = 3:8, discmethod = c("sd", "equal", "geometric", "quantile", "natural"), cores = 1, type = "factor", alpha = 0.95, ... )opgd( formula, data, discvar = NULL, discnum = 3:8, discmethod = c("sd", "equal", "geometric", "quantile", "natural"), cores = 1, type = "factor", alpha = 0.95, ... )
formula |
A formula of OPGD model. |
data |
A |
discvar |
Name of continuous variable columns that need to be discretized. Noted that
when |
discnum |
(optional) A vector of number of classes for discretization. Default is |
discmethod |
(optional) A vector of methods for discretization, default is using
|
cores |
(optional) Positive integer (default is 1). When cores are greater than 1, use multi-core parallel computing. |
type |
(optional) The type of geographical detector, which must be |
alpha |
(optional) Specifies the size of confidence level. Default is |
... |
(optional) Other arguments passed to |
A list.
opt_paramoptimal discretization parameter
factorthe result of factor detector
interactionthe result of interaction detector
riskthe result of risk detector
ecologicalthe result of ecological detector
Song, Y., Wang, J., Ge, Y. & Xu, C. (2020) An optimal parameters-based geographical detector model enhances geographic characteristics of explanatory variables for spatial heterogeneity analysis: Cases with different types of spatial data, GIScience & Remote Sensing, 57(5), 593-610. doi: 10.1080/15481603.2020.1760434.
data('sim') opgd(y ~ xa + xb + xc, data = sim, discvar = paste0('x',letters[1:3]), discnum = 3:6)data('sim') opgd(y ~ xa + xb + xc, data = sim, discvar = paste0('x',letters[1:3]), discnum = 3:6)
PID
IDSA Q-saistics PID
pid_idsa(formula, rawdata, discdata, wt, overlaymethod = "and")pid_idsa(formula, rawdata, discdata, wt, overlaymethod = "and")
formula |
A formula for IDSA Q-saistics |
rawdata |
Raw observation data |
discdata |
Observed data with discrete explanatory variables |
wt |
Spatial weight matrix |
overlaymethod |
(optional) Spatial overlay method. One of |
The value of IDSA Q-saistics PID.
data('sim') wt = sdsfun::inverse_distance_swm(sf::st_as_sf(sim,coords = c('lo','la'))) sim1 = dplyr::mutate(sim,dplyr::across(xa:xc,\(.x) sdsfun::discretize_vector(.x,5))) pid_idsa(y ~ xa + xb + xc, rawdata = sim, discdata = sim1, wt = wt)data('sim') wt = sdsfun::inverse_distance_swm(sf::st_as_sf(sim,coords = c('lo','la'))) sim1 = dplyr::mutate(sim,dplyr::across(xa:xc,\(.x) sdsfun::discretize_vector(.x,5))) pid_idsa(y ~ xa + xb + xc, rawdata = sim, discdata = sim1, wt = wt)
S3 method to plot output for ecological detector in geodetector().
## S3 method for class 'ecological_detector' plot(x, ...)## S3 method for class 'ecological_detector' plot(x, ...)
x |
Return by |
... |
(optional) Other arguments passed to |
A ggplot2 layer
S3 method to plot output for factor detector in geodetector().
## S3 method for class 'factor_detector' plot(x, slicenum = 2, alpha = 0.95, keep = TRUE, qlabelsize = 3.88, ...)## S3 method for class 'factor_detector' plot(x, slicenum = 2, alpha = 0.95, keep = TRUE, qlabelsize = 3.88, ...)
x |
Return by |
slicenum |
(optional) The number of labels facing inward. Default is |
alpha |
(optional) Confidence level. Default is |
keep |
(optional) Whether to keep Q-value results for insignificant variables,
default is |
qlabelsize |
(optional) Set the font size of the q-value text labels in the plot. |
... |
(optional) Other arguments passed to |
A ggplot2 layer.
S3 method to plot output for GD model result in gd().
## S3 method for class 'gd_result' plot(x, ...)## S3 method for class 'gd_result' plot(x, ...)
x |
Return by |
... |
(optional) Other arguments. |
A ggplot2 layer
S3 method to plot output for GOZH model result in gozh().
## S3 method for class 'gozh_result' plot(x, ...)## S3 method for class 'gozh_result' plot(x, ...)
x |
Return by |
... |
(optional) Other arguments. |
A ggplot2 layer
S3 method to plot output for IDSA risk result in idsa().
## S3 method for class 'idsa_result' plot(x, ...)## S3 method for class 'idsa_result' plot(x, ...)
x |
Return by |
... |
(optional) Other arguments passed to |
A ggplot2 layer
S3 method to plot output for interaction detector in geodetector().
## S3 method for class 'interaction_detector' plot(x, alpha = 1, ...)## S3 method for class 'interaction_detector' plot(x, alpha = 1, ...)
x |
Return by |
alpha |
(optional) Picture transparency. Default is |
... |
(optional) Other arguments passed to |
A ggplot2 layer
S3 method to plot output for LESH model interaction result in lesh().
## S3 method for class 'lesh_result' plot( x, pie = TRUE, scatter = FALSE, scatter_alpha = 1, pieradius_factor = 15, pielegend_x = 0.99, pielegend_y = 0.1, pielegend_num = 3, ... )## S3 method for class 'lesh_result' plot( x, pie = TRUE, scatter = FALSE, scatter_alpha = 1, pieradius_factor = 15, pielegend_x = 0.99, pielegend_y = 0.1, pielegend_num = 3, ... )
x |
x Return by |
pie |
(optional) Whether to draw the interaction contributions. Default is |
scatter |
(optional) Whether to draw the interaction direction diagram. Default is |
scatter_alpha |
(optional) Picture transparency. Default is |
pieradius_factor |
(optional) The radius expansion factor of interaction contributions pie plot. Default is |
pielegend_x |
(optional) The X-axis relative position of interaction contributions pie plot legend. Default is |
pielegend_y |
(optional) The Y-axis relative position of interaction contributions pie plot legend. Default is |
pielegend_num |
(optional) The number of interaction contributions pie plot legend. Default is |
... |
(optional) Other arguments passed to |
A ggplot2 layer.
When both scatter and pie are set to TRUE in RStudio, enlarge the drawing frame
for normal display.
S3 method to plot output for OPGD model result in opgd().
## S3 method for class 'opgd_result' plot(x, ...)## S3 method for class 'opgd_result' plot(x, ...)
x |
Return by |
... |
(optional) Other arguments. |
A ggplot2 layer
S3 method to plot output for RGD model result in rgd().
## S3 method for class 'rgd_result' plot(x, slicenum = 2, alpha = 0.95, keep = TRUE, ...)## S3 method for class 'rgd_result' plot(x, slicenum = 2, alpha = 0.95, keep = TRUE, ...)
x |
Return by |
slicenum |
(optional) The number of labels facing inward. Default is |
alpha |
(optional) Confidence level. Default is |
keep |
(optional) Whether to keep Q-value results for insignificant variables,
default is |
... |
(optional) Other arguments passed to |
A ggplot2 layer
S3 method to plot output for RID model from rid().
## S3 method for class 'rid_result' plot(x, alpha = 1, ...)## S3 method for class 'rid_result' plot(x, alpha = 1, ...)
x |
Return by |
alpha |
(optional) Picture transparency. Default is |
... |
(optional) Other arguments passed to |
A ggplot2 layer
S3 method to plot output for risk detector in geodetector().
## S3 method for class 'risk_detector' plot(x, ...)## S3 method for class 'risk_detector' plot(x, ...)
x |
Return by |
... |
(optional) Other arguments passed to |
A ggplot2 layer
S3 method to plot output for gozh sesu in sesu_gozh().
## S3 method for class 'sesu_gozh' plot(x, ...)## S3 method for class 'sesu_gozh' plot(x, ...)
x |
Return by |
... |
(optional) Other arguments passed to |
A ggplot2 layer.
S3 method to plot output for opgd sesu in sesu_opgd().
## S3 method for class 'sesu_opgd' plot(x, ...)## S3 method for class 'sesu_opgd' plot(x, ...)
x |
Return by |
... |
(optional) Other arguments passed to |
A ggplot2 layer.
S3 method to plot output for SPADE power of spatial and multilevel discretization
determinant from spade().
## S3 method for class 'spade_result' plot(x, slicenum = 2, alpha = 0.95, keep = TRUE, ...)## S3 method for class 'spade_result' plot(x, slicenum = 2, alpha = 0.95, keep = TRUE, ...)
x |
Return by |
slicenum |
(optional) The number of labels facing inward. Default is |
alpha |
(optional) Confidence level.Default is |
keep |
(optional) Whether to keep Q-value results for insignificant variables,
default is |
... |
(optional) Other arguments passed to |
A ggplot2 layer.
S3 method to plot output for spatial rough set-based ecological detector in srsgd().
## S3 method for class 'srs_ecological_detector' plot(x, ...)## S3 method for class 'srs_ecological_detector' plot(x, ...)
x |
Return by |
... |
(optional) Other arguments passed to |
A ggplot2 layer
S3 method to plot output for spatial rough set-based factor detector in srsgd().
## S3 method for class 'srs_factor_detector' plot(x, slicenum = 2, ...)## S3 method for class 'srs_factor_detector' plot(x, slicenum = 2, ...)
x |
Return by |
slicenum |
(optional) The number of labels facing inward. Default is |
... |
(optional) Other arguments passed to |
A ggplot2 layer.
S3 method to plot output for spatial rough set-based interaction detector in srsgd().
## S3 method for class 'srs_interaction_detector' plot(x, alpha = 1, ...)## S3 method for class 'srs_interaction_detector' plot(x, alpha = 1, ...)
x |
Return by |
alpha |
(optional) Picture transparency. Default is |
... |
(optional) Other arguments passed to |
A ggplot2 layer
S3 method to plot output for SRSGD model result in srsgd().
## S3 method for class 'srsgd_result' plot(x, ...)## S3 method for class 'srsgd_result' plot(x, ...)
x |
Return by |
... |
(optional) Other arguments. |
A ggplot2 layer
S3 method to format output for ecological detector in geodetector().
## S3 method for class 'ecological_detector' print(x, ...)## S3 method for class 'ecological_detector' print(x, ...)
x |
Return by |
... |
(optional) Other arguments passed to |
Formatted string output
S3 method to format output for factor detector in geodetector().
## S3 method for class 'factor_detector' print(x, ...)## S3 method for class 'factor_detector' print(x, ...)
x |
Return by |
... |
(optional) Other arguments passed to |
Formatted string output
S3 method to format output for GD model from gd().
## S3 method for class 'gd_result' print(x, ...)## S3 method for class 'gd_result' print(x, ...)
x |
Return by |
... |
(optional) Other arguments passed to |
Formatted string output
S3 method to format output for GOZH model from gozh().
## S3 method for class 'gozh_result' print(x, ...)## S3 method for class 'gozh_result' print(x, ...)
x |
Return by |
... |
(optional) Other arguments passed to |
Formatted string output
S3 method to format output for IDSA model from idsa().
## S3 method for class 'idsa_result' print(x, ...)## S3 method for class 'idsa_result' print(x, ...)
x |
Return by |
... |
(optional) Other arguments passed to |
Formatted string output
S3 method to format output for interaction detector in geodetector().
## S3 method for class 'interaction_detector' print(x, ...)## S3 method for class 'interaction_detector' print(x, ...)
x |
Return by |
... |
(optional) Other arguments passed to |
Formatted string output
S3 method to format output for LESH model interaction result in lesh().
## S3 method for class 'lesh_result' print(x, ...)## S3 method for class 'lesh_result' print(x, ...)
x |
Return by |
... |
(optional) Other arguments passed to |
Formatted string output
S3 method to format output for OPGD model from opgd().
## S3 method for class 'opgd_result' print(x, ...)## S3 method for class 'opgd_result' print(x, ...)
x |
Return by |
... |
(optional) Other arguments passed to |
Formatted string output
S3 method to format output for RGD model from rgd().
## S3 method for class 'rgd_result' print(x, ...)## S3 method for class 'rgd_result' print(x, ...)
x |
Return by |
... |
(optional) Other arguments passed to |
Formatted string output
S3 method to format output for RID model from rid().
## S3 method for class 'rid_result' print(x, ...)## S3 method for class 'rid_result' print(x, ...)
x |
Return by |
... |
(optional) Other arguments passed to |
Formatted string output
S3 method to format output for risk detector in geodetector().
## S3 method for class 'risk_detector' print(x, ...)## S3 method for class 'risk_detector' print(x, ...)
x |
Return by |
... |
(optional) Other arguments passed to |
Formatted string output
S3 method to format output for gozh sesu from sesu_gozh().
## S3 method for class 'sesu_gozh' print(x, ...)## S3 method for class 'sesu_gozh' print(x, ...)
x |
Return by |
... |
(optional) Other arguments passed to |
Formatted string output
S3 method to format output for opgd sesu from sesu_opgd().
## S3 method for class 'sesu_opgd' print(x, ...)## S3 method for class 'sesu_opgd' print(x, ...)
x |
Return by |
... |
(optional) Other arguments passed to |
Formatted string output
S3 method to format output for SPADE power of spatial and multilevel discretization
determinant from spade().
## S3 method for class 'spade_result' print(x, ...)## S3 method for class 'spade_result' print(x, ...)
x |
Return by |
... |
Other arguments. |
Formatted string output
S3 method to format output for spatial rough set-based ecological detector in srsgd().
## S3 method for class 'srs_ecological_detector' print(x, ...)## S3 method for class 'srs_ecological_detector' print(x, ...)
x |
Return by |
... |
(optional) Other arguments passed to |
Formatted string output
S3 method to format output for spatial rough set-based factor detector in srsgd().
## S3 method for class 'srs_factor_detector' print(x, ...)## S3 method for class 'srs_factor_detector' print(x, ...)
x |
Return by |
... |
(optional) Other arguments passed to |
Formatted string output
S3 method to format output for spatial rough set-based interaction detector in srsgd().
## S3 method for class 'srs_interaction_detector' print(x, ...)## S3 method for class 'srs_interaction_detector' print(x, ...)
x |
Return by |
... |
(optional) Other arguments passed to |
Formatted string output
S3 method to format output for SRSGD model from srsgd().
## S3 method for class 'srsgd_result' print(x, ...)## S3 method for class 'srsgd_result' print(x, ...)
x |
Return by |
... |
(optional) Other arguments passed to |
Formatted string output
PSD of an interaction of explanatory variables (PSD-IEV)
psd_iev(discdata, spzone, wt)psd_iev(discdata, spzone, wt)
discdata |
Observed data with discrete explanatory variables. A |
spzone |
Fuzzy overlay spatial zones. Returned from |
wt |
Spatial weight matrix |
The Value of PSD-IEV
Yongze Song & Peng Wu (2021) An interactive detector for spatial associations, International Journal of Geographical Information Science, 35:8, 1676-1701, DOI:10.1080/13658816.2021.1882680
data('sim') wt = sdsfun::inverse_distance_swm(sf::st_as_sf(sim,coords = c('lo','la'))) sim1 = dplyr::mutate(sim,dplyr::across(xa:xc,\(.x) sdsfun::discretize_vector(.x,5))) sz = sdsfun::fuzzyoverlay(y ~ xa + xb + xc, data = sim1) psd_iev(dplyr::select(sim1,xa:xc),sz,wt)data('sim') wt = sdsfun::inverse_distance_swm(sf::st_as_sf(sim,coords = c('lo','la'))) sim1 = dplyr::mutate(sim,dplyr::across(xa:xc,\(.x) sdsfun::discretize_vector(.x,5))) sz = sdsfun::fuzzyoverlay(y ~ xa + xb + xc, data = sim1) psd_iev(dplyr::select(sim1,xa:xc),sz,wt)
Function for calculate power of spatial determinant .
psd_pseudop(y, x, wt, cores = 1, seed = 123456789, permutations = 0)psd_pseudop(y, x, wt, cores = 1, seed = 123456789, permutations = 0)
y |
Variable Y, continuous numeric vector. |
x |
Covariable X, |
wt |
The spatial weight matrix. |
cores |
(optional) A positive integer(default is 1). If cores > 1, use parallel computation. |
seed |
(optional) Random seed number, default is |
permutations |
(optional) The number of permutations for the PSD computation. Default is |
The power of spatial determinant formula is
A tibble of power of spatial determinant and the corresponding pseudo-p value.
Xuezhi Cang & Wei Luo (2018) Spatial association detector (SPADE),International Journal of Geographical Information Science, 32:10, 2055-2075, DOI: 10.1080/13658816.2018.1476693
data('sim') wt = sdsfun::inverse_distance_swm(sf::st_as_sf(sim,coords = c('lo','la')), power = 2) psd_pseudop(sim$y,sdsfun::discretize_vector(sim$xa,5),wt)data('sim') wt = sdsfun::inverse_distance_swm(sf::st_as_sf(sim,coords = c('lo','la')), power = 2) psd_pseudop(sim$y,sdsfun::discretize_vector(sim$xa,5),wt)
Function for calculate power of spatial determinant q_s
psd_spade(y, x, wt)psd_spade(y, x, wt)
y |
Variable Y, continuous numeric vector. |
x |
Covariable X, |
wt |
The spatial weight matrix. |
The power of spatial determinant formula is
A value of power of spatial determinant q_s.
Xuezhi Cang & Wei Luo (2018) Spatial association detector (SPADE),International Journal of Geographical Information Science, 32:10, 2055-2075, DOI: 10.1080/13658816.2018.1476693
data('sim') wt = sdsfun::inverse_distance_swm(sf::st_as_sf(sim,coords = c('lo','la')), power = 2) psd_spade(sim$y,sdsfun::discretize_vector(sim$xa,5),wt)data('sim') wt = sdsfun::inverse_distance_swm(sf::st_as_sf(sim,coords = c('lo','la')), power = 2) psd_spade(sim$y,sdsfun::discretize_vector(sim$xa,5),wt)
Function for calculate power of spatial and multilevel discretization determinant and the corresponding pseudo-p value.
psmd_pseudop( yobs, xobs, wt, discnum = 3:8, discmethod = "quantile", cores = 1, seed = 123456789, permutations = 0, ... )psmd_pseudop( yobs, xobs, wt, discnum = 3:8, discmethod = "quantile", cores = 1, seed = 123456789, permutations = 0, ... )
yobs |
Variable Y |
xobs |
The original undiscretized covariable X. |
wt |
The spatial weight matrix. |
discnum |
(optional) Number of multilevel discretization. Default will use |
discmethod |
(optional) The discretization methods. Default will use |
cores |
(optional) A positive integer(default is 1). If cores > 1, use parallel computation. |
seed |
(optional) Random seed number, default is |
permutations |
(optional) The number of permutations for the PSD computation. Default is |
... |
(optional) Other arguments passed to |
The power of spatial and multilevel discretization determinant formula is
A tibble of power of spatial and multilevel discretization determinant and the corresponding pseudo-p value.
Xuezhi Cang & Wei Luo (2018) Spatial association detector (SPADE),International Journal of Geographical Information Science, 32:10, 2055-2075, DOI: 10.1080/13658816.2018.1476693
data('sim') wt = sdsfun::inverse_distance_swm(sf::st_as_sf(sim,coords = c('lo','la'))) psmd_pseudop(sim$y,sim$xa,wt)data('sim') wt = sdsfun::inverse_distance_swm(sf::st_as_sf(sim,coords = c('lo','la'))) psmd_pseudop(sim$y,sim$xa,wt)
Function for calculate power of spatial and multilevel discretization determinant PSMDQ_s.
psmd_spade( yobs, xobs, wt, discnum = 3:8, discmethod = "quantile", cores = 1, seed = 123456789, ... )psmd_spade( yobs, xobs, wt, discnum = 3:8, discmethod = "quantile", cores = 1, seed = 123456789, ... )
yobs |
Variable Y |
xobs |
The original continuous covariable X. |
wt |
The spatial weight matrix. |
discnum |
(optional) Number of multilevel discretizations. Default will use |
discmethod |
(optional) The discretize methods. Default will use |
cores |
(optional) A positive integer(default is 1). If cores > 1, use parallel computation. |
seed |
(optional) Random seed number, default is |
... |
(optional) Other arguments passed to |
The power of spatial and multilevel discretization determinant formula is
A value of power of spatial and multilevel discretization determinant PSMDQ_s.
Xuezhi Cang & Wei Luo (2018) Spatial association detector (SPADE),International Journal of Geographical Information Science, 32:10, 2055-2075, DOI: 10.1080/13658816.2018.1476693
data('sim') wt = sdsfun::inverse_distance_swm(sf::st_as_sf(sim,coords = c('lo','la'))) psmd_spade(sim$y,sim$xa,wt)data('sim') wt = sdsfun::inverse_distance_swm(sf::st_as_sf(sim,coords = c('lo','la'))) psmd_spade(sim$y,sim$xa,wt)
robust geographical detector(RGD) model
rgd( formula, data, discvar = NULL, discnum = 3:8, minsize = 1, strategy = 2L, increase_rate = 0.05, cores = 1 )rgd( formula, data, discvar = NULL, discnum = 3:8, minsize = 1, strategy = 2L, increase_rate = 0.05, cores = 1 )
formula |
A formula of RGD model. |
data |
A |
discvar |
Name of continuous variable columns that need to be discretized. Noted that
when |
discnum |
A numeric vector of discretized classes of columns that need to be discretized.
Default all |
minsize |
(optional) The min size of each discretization group. Default all use |
strategy |
(optional) Optimal discretization strategy. When |
increase_rate |
(optional) The critical increase rate of the number of discretization. Default is |
cores |
(optional) Positive integer (default is 1). When cores are greater than 1, use multi-core parallel computing. |
A list.
factorrobust power of determinant
opt_discoptimal robust discrete results
allfactorfactor detection results corresponding to different number of robust discreteizations
alldiscall robust discrete results
Zhang, Z., Song, Y.*, & Wu, P., 2022. Robust geographical detector. International Journal of Applied Earth Observation and Geoinformation. 109, 102782. DOI: 10.1016/j.jag.2022.102782.
data('sim') tryCatch({ g = rgd(y ~ ., data = dplyr::select(sim,-dplyr::any_of(c('lo','la'))), discnum = 3:6, cores = 1) g }, error = \(e) message("Skipping Python-dependent example: ", e$message))data('sim') tryCatch({ g = rgd(y ~ ., data = dplyr::select(sim,-dplyr::any_of(c('lo','la'))), discnum = 3:6, cores = 1) g }, error = \(e) message("Skipping Python-dependent example: ", e$message))
robust interaction detector(RID) model
rid( formula, data, discvar = NULL, discnum = 3:8, minsize = 1, strategy = 2L, increase_rate = 0.05, cores = 1 )rid( formula, data, discvar = NULL, discnum = 3:8, minsize = 1, strategy = 2L, increase_rate = 0.05, cores = 1 )
formula |
A formula of RGD model. |
data |
A |
discvar |
Name of continuous variable columns that need to be discretized. Noted that
when |
discnum |
A numeric vector of discretized classes of columns that need to be discretized.
Default all |
minsize |
(optional) The min size of each discretization group. Default all use |
strategy |
(optional) Optimal discretization strategy. When |
increase_rate |
(optional) The critical increase rate of the number of discretization. Default is |
cores |
(optional) Positive integer (default is 1). When cores are greater than 1, use multi-core parallel computing. |
A list.
interactionthe result of RID model
Zhang, Z., Song, Y., Karunaratne, L., & Wu, P. (2024). Robust interaction detector: A case of road life expectancy analysis. Spatial Statistics, 59(100814), 100814. https://doi.org/10.1016/j.spasta.2024.100814
data('sim') tryCatch({ g = rid(y ~ ., data = dplyr::select(sim,-dplyr::any_of(c('lo','la'))), discnum = 3:6, cores = 1) g }, error = \(e) message("Skipping Python-dependent example: ", e$message))data('sim') tryCatch({ g = rid(y ~ ., data = dplyr::select(sim,-dplyr::any_of(c('lo','la'))), discnum = 3:6, cores = 1) g }, error = \(e) message("Skipping Python-dependent example: ", e$message))
Determine whether there is a significant difference between the attribute means of two sub regions.
risk_detector(y, x, alpha = 0.95)risk_detector(y, x, alpha = 0.95)
y |
Variable Y, continuous numeric vector. |
x |
Covariate X, |
alpha |
(optional) Confidence level of the interval, default is |
A tibble.
risk_detector(y = 1:7, x = c('x',rep('y',3),rep('z',3)))risk_detector(y = 1:7, x = c('x',rep('y',3),rep('z',3)))
Determines discretization interval breaks using an optimization algorithm for variance-based change point detection.
robust_disc(formula, data, discnum, minsize = 1, cores = 1)robust_disc(formula, data, discnum, minsize = 1, cores = 1)
formula |
A formula of univariate discretization. |
data |
A data.frame or tibble of observation data. |
discnum |
A numeric vector of discretized classes of columns that need to be discretized. |
minsize |
(optional) The min size of each discretization group. Default all use |
cores |
(optional) A positive integer(default is 1). If cores > 1, use |
A tibble.
data('sim') tryCatch({ robust_disc(y ~ xa, data = sim, discnum = 5) robust_disc(y ~ ., data = dplyr::select(sim,-dplyr::any_of(c('lo','la'))), discnum = 5, cores = 3) }, error = \(e) message("Skipping Python-dependent example: ", e$message))data('sim') tryCatch({ robust_disc(y ~ xa, data = sim, discnum = 5) robust_disc(y ~ ., data = dplyr::select(sim,-dplyr::any_of(c('lo','la'))), discnum = 5, cores = 3) }, error = \(e) message("Skipping Python-dependent example: ", e$message))
discretization of variables based on recursive partitioning
rpart_disc(formula, data, ...)rpart_disc(formula, data, ...)
formula |
A formula. |
data |
A data.frame or tibble of observation data. |
... |
(optional) Other arguments passed to |
A vector that being discretized.
Luo, P., Song, Y., Huang, X., Ma, H., Liu, J., Yao, Y., & Meng, L. (2022). Identifying determinants of spatio-temporal disparities in soil moisture of the Northern Hemisphere using a geographically optimal zones-based heterogeneity model. ISPRS Journal of Photogrammetry and Remote Sensing: Official Publication of the International Society for Photogrammetry and Remote Sensing (ISPRS), 185, 111–128. https://doi.org/10.1016/j.isprsjprs.2022.01.009
data('ndvi') rpart_disc(NDVIchange ~ ., data = ndvi)data('ndvi') rpart_disc(NDVIchange ~ ., data = ndvi)
comparison of size effects of spatial units based on GOZH
sesu_gozh( formula, datalist, su, cores = 1, strategy = 2L, increase_rate = 0.05, alpha = 0.95, ... )sesu_gozh( formula, datalist, su, cores = 1, strategy = 2L, increase_rate = 0.05, alpha = 0.95, ... )
formula |
A formula of comparison of size effects of spatial units. |
datalist |
A list of |
su |
A vector of sizes of spatial units. |
cores |
(optional) Positive integer (default is 1). When cores are greater than 1, use multi-core parallel computing. |
strategy |
(optional) Calculation strategies of Q statistics at different scales. Default
is |
increase_rate |
(optional) The critical increase rate of the number of discretization.
Default is |
alpha |
(optional) Specifies the size of confidence level. Default is |
... |
(optional) Other arguments passed to |
When strategy is 1, use the same process as sesu_opgd().If not, all explanatory
variables are used to generate a unique Q statistic corresponding to the data in the
datalist based on rpart_disc() and gd(), and then loess_optscale()is used to
determine the optimal analysis scale.
A list.
sesua tibble representing size effects of spatial units
optsuoptimal spatial unit
strategythe optimal analytical scale selection strategy
increase_ratethe critical increase rate of q value
Song, Y., Wang, J., Ge, Y. & Xu, C. (2020) An optimal parameters-based geographical detector model enhances geographic characteristics of explanatory variables for spatial heterogeneity analysis: Cases with different types of spatial data, GIScience & Remote Sensing, 57(5), 593-610. doi: 10.1080/15481603.2020.1760434.
Luo, P., Song, Y., Huang, X., Ma, H., Liu, J., Yao, Y., & Meng, L. (2022). Identifying determinants of spatio-temporal disparities in soil moisture of the Northern Hemisphere using a geographically optimal zones-based heterogeneity model. ISPRS Journal of Photogrammetry and Remote Sensing: Official Publication of the International Society for Photogrammetry and Remote Sensing (ISPRS), 185, 111–128. https://doi.org/10.1016/j.isprsjprs.2022.01.009
## Not run: ## The following code takes a long time to run: library(tidyverse) fvcpath = "https://github.com/SpatLyu/rdevdata/raw/main/FVC.tif" fvc = terra::rast(paste0("/vsicurl/",fvcpath)) fvc1000 = fvc %>% terra::as.data.frame(na.rm = T) %>% as_tibble() fvc5000 = fvc %>% terra::aggregate(fact = 5) %>% terra::as.data.frame(na.rm = T) %>% as_tibble() sesu_gozh(fvc ~ ., datalist = list(fvc1000,fvc5000), su = c(1000,5000), cores = 6) ## End(Not run)## Not run: ## The following code takes a long time to run: library(tidyverse) fvcpath = "https://github.com/SpatLyu/rdevdata/raw/main/FVC.tif" fvc = terra::rast(paste0("/vsicurl/",fvcpath)) fvc1000 = fvc %>% terra::as.data.frame(na.rm = T) %>% as_tibble() fvc5000 = fvc %>% terra::aggregate(fact = 5) %>% terra::as.data.frame(na.rm = T) %>% as_tibble() sesu_gozh(fvc ~ ., datalist = list(fvc1000,fvc5000), su = c(1000,5000), cores = 6) ## End(Not run)
comparison of size effects of spatial units based on OPGD
sesu_opgd( formula, datalist, su, discvar, discnum = 3:8, discmethod = c("sd", "equal", "geometric", "quantile", "natural"), cores = 1, increase_rate = 0.05, alpha = 0.95, ... )sesu_opgd( formula, datalist, su, discvar, discnum = 3:8, discmethod = c("sd", "equal", "geometric", "quantile", "natural"), cores = 1, increase_rate = 0.05, alpha = 0.95, ... )
formula |
A formula of comparison of size effects of spatial units. |
datalist |
A list of |
su |
A vector of sizes of spatial units. |
discvar |
Name of continuous variable columns that need to be discretized.Noted that
when |
discnum |
(optional) A vector of number of classes for discretization. Default is |
discmethod |
(optional) A vector of methods for discretization, default is using
|
cores |
(optional) Positive integer (default is 1). When cores are greater than 1, use multi-core parallel computing. |
increase_rate |
(optional) The critical increase rate of the number of discretization.
Default is |
alpha |
(optional) Specifies the size of confidence level. Default is |
... |
(optional) Other arguments passed to |
Firstly, the OPGD model is executed for each data in the datalist (all significant
Q statistic of each data are averaged to represent the spatial association strength under
this spatial unit), and then the loess_optscale function is used to select the optimal
spatial analysis scale.
A list.
sesua tibble representing size effects of spatial units
optsuoptimal spatial unit
increase_ratethe critical increase rate of q value
Song, Y., Wang, J., Ge, Y. & Xu, C. (2020) An optimal parameters-based geographical detector model enhances geographic characteristics of explanatory variables for spatial heterogeneity analysis: Cases with different types of spatial data, GIScience & Remote Sensing, 57(5), 593-610. doi: 10.1080/15481603.2020.1760434.
## Not run: ## The following code takes a long time to run: library(tidyverse) fvcpath = "https://github.com/SpatLyu/rdevdata/raw/main/FVC.tif" fvc = terra::rast(paste0("/vsicurl/",fvcpath)) fvc1000 = fvc %>% terra::as.data.frame(na.rm = T) %>% as_tibble() fvc5000 = fvc %>% terra::aggregate(fact = 5) %>% terra::as.data.frame(na.rm = T) %>% as_tibble() sesu_opgd(fvc ~ ., datalist = list(fvc1000,fvc5000), su = c(1000,5000), discvar = names(select(fvc5000,-c(fvc,lulc))), cores = 6) ## End(Not run)## Not run: ## The following code takes a long time to run: library(tidyverse) fvcpath = "https://github.com/SpatLyu/rdevdata/raw/main/FVC.tif" fvc = terra::rast(paste0("/vsicurl/",fvcpath)) fvc1000 = fvc %>% terra::as.data.frame(na.rm = T) %>% as_tibble() fvc5000 = fvc %>% terra::aggregate(fact = 5) %>% terra::as.data.frame(na.rm = T) %>% as_tibble() sesu_opgd(fvc ~ ., datalist = list(fvc1000,fvc5000), su = c(1000,5000), discvar = names(select(fvc5000,-c(fvc,lulc))), cores = 6) ## End(Not run)
Simulation data.
simsim
sim: A tibble with 80 rows and 6 variables, modified from IDSA package.
Yongze Song [email protected]
spatial association detector (SPADE) model
spade( formula, data, wt = NULL, discvar = NULL, discnum = 3:8, discmethod = "quantile", cores = 1, seed = 123456789, permutations = 0, ... )spade( formula, data, wt = NULL, discvar = NULL, discnum = 3:8, discmethod = "quantile", cores = 1, seed = 123456789, permutations = 0, ... )
formula |
A formula of spatial association detector (SPADE) model. |
data |
A |
wt |
(optional) The spatial weight matrix. When |
discvar |
(optional) Name of continuous variable columns that need to be discretized. Noted that
when |
discnum |
(optional) Number of multilevel discretization. Default will use |
discmethod |
(optional) The discretization methods. Default all use |
cores |
(optional) Positive integer (default is 1). When cores are greater than 1, use multi-core parallel computing. |
seed |
(optional) Random number seed, default is |
permutations |
(optional) The number of permutations for the PSD computation. Default is |
... |
(optional) Other arguments passed to |
A list.
factorthe result of SPADE model
Xuezhi Cang & Wei Luo (2018) Spatial association detector (SPADE),International Journal of Geographical Information Science, 32:10, 2055-2075, DOI: 10.1080/13658816.2018.1476693
data('sim') sim1 = sf::st_as_sf(sim,coords = c('lo','la')) g = spade(y ~ ., data = sim1) gdata('sim') sim1 = sf::st_as_sf(sim,coords = c('lo','la')) g = spade(y ~ ., data = sim1) g
Function for calculate shap power of determinants .
spd_lesh(formula, data, cores = 1, ...)spd_lesh(formula, data, cores = 1, ...)
formula |
A formula of calculate shap power of determinants. |
data |
A data.frame or tibble of observation data. |
cores |
(optional) Positive integer (default is 1). When cores are greater than 1, use multi-core parallel computing. |
... |
(optional) Other arguments passed to |
The power of shap power of determinants formula is
.
shap power of determinants (SPD) is the contribution of variable to the power of determinants.
A tibble with variable and its corresponding value.
The shap power of determinants (SPD) requires at least calculations when has explanatory variables.
When there are more than 10 explanatory variables, carefully consider the computational burden of this model.
When there are a large number of explanatory variables, the data dimensionality reduction method can be used
to ensure the trade-off between analysis results and calculation speed.
Li, Y., Luo, P., Song, Y., Zhang, L., Qu, Y., & Hou, Z. (2023). A locally explained heterogeneity model for examining wetland disparity. International Journal of Digital Earth, 16(2), 4533–4552. https://doi.org/10.1080/17538947.2023.2271883
data('ndvi') g = spd_lesh(NDVIchange ~ ., data = ndvi) gdata('ndvi') g = spd_lesh(NDVIchange ~ ., data = ndvi) g
spatial rough set-based ecological detector
srs_ecological_detector(y, x1, x2, wt, alpha = 0.95)srs_ecological_detector(y, x1, x2, wt, alpha = 0.95)
y |
Dependent variable, |
x1 |
Covariate |
x2 |
Covariate |
wt |
Spatial adjacency matrix. |
alpha |
(optional) Confidence level of the interval,default is |
A list.
T-statisticthe result of T statistic for spatial rough set-based ecological detector
P-valuethe result of P value for spatial rough set-based ecological detector
Ecologicaldoes one spatial feature play a more important role than
Bai, H., Li, D., Ge, Y., Wang, J., & Cao, F. (2022). Spatial rough set-based geographical detectors for nominal target variables. Information Sciences, 586, 525–539. https://doi.org/10.1016/j.ins.2021.12.019
data('srs_table') data('srs_wt') srs_ecological_detector(srs_table$d,srs_table$a1,srs_table$a2,srs_wt)data('srs_table') data('srs_wt') srs_ecological_detector(srs_table$d,srs_table$a1,srs_table$a2,srs_wt)
spatial rough set-based factor detector
srs_factor_detector(y, x, wt)srs_factor_detector(y, x, wt)
y |
Variable Y, |
x |
Covariate X, |
wt |
Spatial adjacency matrix. |
A list.
PDthe average local explanatory power
SE_PDthe degree of spatial heterogeneity of the local explanatory power
Bai, H., Li, D., Ge, Y., Wang, J., & Cao, F. (2022). Spatial rough set-based geographical detectors for nominal target variables. Information Sciences, 586, 525–539. https://doi.org/10.1016/j.ins.2021.12.019
data('srs_table') data('srs_wt') srs_factor_detector(srs_table$d,srs_table$a1,srs_wt)data('srs_table') data('srs_wt') srs_factor_detector(srs_table$d,srs_table$a1,srs_wt)
spatial rough set-based geographical detector
srs_geodetector(formula, data, wt = NULL, type = "factor", alpha = 0.95)srs_geodetector(formula, data, wt = NULL, type = "factor", alpha = 0.95)
formula |
A formula of spatial rough set-based geographical detector model. |
data |
A data.frame, tibble or sf object of observation data. |
wt |
Spatial adjacency matrix. If |
type |
(optional) The type of geographical detector, which must be one of
|
alpha |
(optional) Specifies the size of the alpha (confidence level). Default is |
A list.
factorthe result of spatial rough set-based factor detector
interactionthe result of spatial rough set-based interaction detector
ecologicalthe result of spatial rough set-based ecological detector
data('srs_table') data('srs_wt') srs_geodetector(d ~ a1 + a2 + a3, data = srs_table, wt = srs_wt) srs_geodetector(d ~ a1 + a2 + a3, data = srs_table, wt = srs_wt, type = 'interaction') srs_geodetector(d ~ a1 + a2 + a3, data = srs_table, wt = srs_wt, type = 'ecological')data('srs_table') data('srs_wt') srs_geodetector(d ~ a1 + a2 + a3, data = srs_table, wt = srs_wt) srs_geodetector(d ~ a1 + a2 + a3, data = srs_table, wt = srs_wt, type = 'interaction') srs_geodetector(d ~ a1 + a2 + a3, data = srs_table, wt = srs_wt, type = 'ecological')
spatial rough set-based interaction detector
srs_interaction_detector(y, x1, x2, wt)srs_interaction_detector(y, x1, x2, wt)
y |
Dependent variable, |
x1 |
Covariate |
x2 |
Covariate |
wt |
Spatial adjacency matrix. |
A list.
Variable1 PDthe average local explanatory power for variable1
Variable2 PDthe average local explanatory power for variable2
Variable1 and Variable2 interact PDthe average local explanatory power for variable1 and variable2 interact
Variable1 SE_PDthe degree of spatial heterogeneity of the local explanatory power for variable1
Variable2 SE_PDthe degree of spatial heterogeneity of the local explanatory power for variable2
Variable1 and Variable2 SE_PDthe degree of spatial heterogeneity of the local explanatory power for variable1 and variable2 interact
Interactionthe interact result type
Bai, H., Li, D., Ge, Y., Wang, J., & Cao, F. (2022). Spatial rough set-based geographical detectors for nominal target variables. Information Sciences, 586, 525–539. https://doi.org/10.1016/j.ins.2021.12.019
data('srs_table') data('srs_wt') srs_interaction_detector(srs_table$d,srs_table$a1,srs_table$a2,srs_wt)data('srs_table') data('srs_wt') srs_interaction_detector(srs_table$d,srs_table$a1,srs_table$a2,srs_wt)
example of spatial information system table
srs_tablesrs_table
srs_table: A tibble with 11 rows and 5 variables(one ID column).
example of spatial information system spatial adjacency matrix
srs_wtsrs_wt
srs_wt: A matrix with 11rows and 11cols.
spatial rough set-based geographical detector(SRSGD) model
srsgd(formula, data, wt = NULL, type = "factor", alpha = 0.95)srsgd(formula, data, wt = NULL, type = "factor", alpha = 0.95)
formula |
A formula of spatial rough set-based geographical detector model. |
data |
A |
wt |
Spatial adjacency matrix. If |
type |
(optional) The type of geographical detector, which must be one of
|
alpha |
(optional) Specifies the size of the alpha (confidence level). Default is |
A list.
factorthe result of spatial rough set-based factor detector
interactionthe result of spatial rough set-based interaction detector
ecologicalthe result of spatial rough set-based ecological detector
The Spatial Rough Set-based Geographical Detector Model (SRSGD) conducts spatial
hierarchical heterogeneity analysis utilizing a geographical detector for data
where the dependent variable is discrete. Given the complementary relationship
between SRSGD and the native version of geographical detector, I strive to maintain
consistency with gd() function when establishing srsgd() function. This implies
that all input variable data in srsgd must be discretized prior to use.
Bai, H., Li, D., Ge, Y., Wang, J., & Cao, F. (2022). Spatial rough set-based geographical detectors for nominal target variables. Information Sciences, 586, 525–539. https://doi.org/10.1016/j.ins.2021.12.019
data('srs_table') data('srs_wt') srsgd(d ~ a1 + a2 + a3, data = srs_table, wt = srs_wt, type = c('factor','interaction','ecological'))data('srs_table') data('srs_wt') srsgd(d ~ a1 + a2 + a3, data = srs_table, wt = srs_wt, type = c('factor','interaction','ecological'))
assign values by weight
weight_assign(x, w, list = FALSE)weight_assign(x, w, list = FALSE)
x |
A numeric value |
w |
A weight vector |
list |
(optional) Return list or not. if |
A numeric Vector.
weight_assign(0.875,1:3)weight_assign(0.875,1:3)