| Title: | Analysis of Spatial Stratified Heterogeneity | 
| Version: | 1.5.1 | 
| 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>. | 
| License: | GPL-3 | 
| Encoding: | UTF-8 | 
| RoxygenNote: | 7.3.3 | 
| URL: | https://stscl.github.io/gdverse/, https://github.com/stscl/gdverse | 
| BugReports: | https://github.com/stscl/gdverse/issues | 
| Depends: | R (≥ 4.1.0) | 
| Imports: | dplyr, forcats, ggplot2, magrittr, parallel, patchwork, purrr, reticulate (≥ 1.41.0), rpart, scatterpie, sdsfun (≥ 0.7.0), sf, stats, tibble, tidyr, utils | 
| Suggests: | cowplot, itmsa, knitr, Rcpp, readr, rmarkdown, terra, testthat (≥ 3.0.0) | 
| LinkingTo: | Rcpp | 
| VignetteBuilder: | knitr | 
| LazyData: | true | 
| Config/testthat/edition: | 3 | 
| NeedsCompilation: | yes | 
| Packaged: | 2025-10-15 10:16:03 UTC; dell | 
| Author: | Wenbo Lv | 
| Maintainer: | Wenbo Lv <lyu.geosocial@gmail.com> | 
| Repository: | CRAN | 
| Date/Publication: | 2025-10-15 10:50:02 UTC | 
Pipe operator
Description
See magrittr::%>% for details.
Usage
lhs %>% rhs
Value
NULL (this is the magrittr pipe operator)
measure information loss by information entropy
Description
Function for measure information loss by shannon information entropy.
Usage
F_informationloss(xvar, xdisc)
Arguments
| xvar | The original undiscretized vector. | 
| xdisc | The discretized vector. | 
Details
The information loss measured by information entropy formula is
F = -\sum\limits_{i=1}^N p_{(i)}\log_2 p_{(i)} - \left(-\sum\limits_{h=1}^L p_{(h)}\log_2 p_{(h)}\right)
Value
A numeric value of information loss measured by information entropy.
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
Examples
F_informationloss(1:7,c('x',rep('y',3),rep('z',3)))
NTDs data
Description
The data were obtained by preprocessing use sf and tidyverse.
Usage
NTDs
Format
NTDs: A tibble with 185 rows and 4 variable columns and 2 location columns, modified from geodetector package.
convert all discretized vectors to integer
Description
convert all discretized vectors to integer
Usage
all2int(x)
Arguments
| x | A discretized vector. | 
Value
An integer vector.
Examples
all2int(factor(letters[1:3],levels = c('b','a','c')))
all2int(letters[1:3])
optimal spatial data discretization based on SPADE q-statistics
Description
Function for determining the optimal spatial data discretization based on SPADE q-statistics.
Usage
cpsd_disc(
  formula,
  data,
  wt,
  discnum = 3:8,
  discmethod = "quantile",
  strategy = 2L,
  increase_rate = 0.05,
  cores = 1,
  seed = 123456789,
  ...
)
Arguments
| 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  | 
Value
A list.
- x
- discretization variable name 
- k
- optimal number of spatial data discreteization 
- method
- optimal spatial data discretization method 
- disc
- the result of optimal spatial data discretization 
Note
When the discmethod is configured to robust, it will operate at a significantly reduced speed.
Consequently, the use of robust discretization is not advised.
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
References
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
Examples
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)
compensated power of spatial determinant(CPSD)
Description
Function for calculate compensated power of spatial determinant Q_s.
Usage
cpsd_spade(yobs, xobs, xdisc, wt)
Arguments
| yobs | Variable Y | 
| xobs | The original undiscretized covariable X. | 
| xdisc | The discretized covariable X. | 
| wt | The spatial weight matrix. | 
Details
The power of compensated spatial determinant formula is
Q_s = \frac{q_s}{q_{s_{inforkep}}}
= \frac{1 - \frac{\sum_{h=1}^L N_h \Gamma_{kdep}}{N \Gamma_{totaldep}}}{1 - \frac{\sum_{h=1}^L N_h \Gamma_{hind}}{N \Gamma_{totalind}}}
Value
A value of compensated power of spatial determinant Q_s.
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
References
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
Examples
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)
ecological detector
Description
Compare the effects of two factors X_1 and X_2 on the spatial distribution of the attribute Y.
Usage
ecological_detector(y, x1, x2, alpha = 0.95)
Arguments
| y | Dependent variable, continuous numeric vector. | 
| x1 | Covariate  | 
| x2 | Covariate  | 
| alpha | (optional) Confidence level of the interval,default is  | 
Value
A list.
- F-statistic
- the result of F statistic for ecological detector 
- P-value
- the result of P value for ecological detector 
- Ecological
- is there a significant difference between the two factors - X_1and- X_2on the spatial distribution of the attribute- Y
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
Examples
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)))
factor detector
Description
The factor detector q-statistic measures the spatial stratified heterogeneity of a variable Y, or the determinant power of a covariate X of Y.
Usage
factor_detector(y, x, confintv = FALSE, alpha = 0.95)
Arguments
| 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  | 
Value
A list.
- Q-statistic
- the q statistic for factor detector 
- P-value
- the p value for factor detector 
- CIL
- the confidence interval lower bound 
- CIU
- the confidence interval upper bound 
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
Examples
factor_detector(y = 1:7,x = c('x',rep('y',3),rep('z',3)))
native geographical detector(GD) model
Description
native geographical detector(GD) model
Usage
gd(formula, data, type = "factor", alpha = 0.95)
Arguments
| 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  | 
Value
A list.
- factor
- the result of factor detector 
- interaction
- the result of interaction detector 
- risk
- the result of risk detector 
- ecological
- the result of ecological detector 
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
References
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
Examples
data("NTDs")
g = gd(incidence ~ watershed + elevation + soiltype,
       data = NTDs,type = c('factor','interaction'))
g
optimal univariate discretization based on geodetector q-statistic
Description
optimal univariate discretization based on geodetector q-statistic
Usage
gd_optunidisc(
  formula,
  data,
  discnum = 3:8,
  discmethod = c("sd", "equal", "geometric", "quantile", "natural"),
  cores = 1,
  seed = 123456789,
  ...
)
Arguments
| 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  | 
Value
A list.
- x
- the name of the variable that needs to be discretized 
- k
- optimal discretization number 
- method
- optimal discretization method 
- qstatistic
- optimal q-statistic 
- disc
- optimal discretization results 
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
Examples
data('sim')
gd_optunidisc(y ~ xa + xb + xc,
              data = sim,
              discnum = 3:6)
generate permutations
Description
generate permutations
Usage
gen_permutations(x, seed = 123456789)
Arguments
| x | A vector. | 
| seed | (optional) Random seed number. Default is  | 
Value
A permutations vector.
Examples
gen_permutations(1:100,42)
geographical detector
Description
geographical detector
Usage
geodetector(formula, data, type = "factor", alpha = 0.95)
Arguments
| 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  | 
Value
A list.
- factor
- the result of factor detector 
- interaction
- the result of interaction detector 
- risk
- the result of risk detector 
- ecological
- the result of ecological detector 
Note
Note that only one type of geodetector is supported at a time in geodetector().
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
Examples
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
Description
geographically optimal zones-based heterogeneity(GOZH) model
Usage
gozh(formula, data, cores = 1, type = "factor", alpha = 0.95, ...)
Arguments
| 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  | 
Value
A list.
- factor
- the result of factor detector 
- interaction
- the result of interaction detector 
- risk
- the result of risk detector 
- ecological
- the result of ecological detector 
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
References
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
Examples
data('ndvi')
g = gozh(NDVIchange ~ ., data = ndvi)
g
geographically optimal zones-based heterogeneity detector
Description
Function for geographically optimal zones-based heterogeneity detector.
Usage
gozh_detector(formula, data, cores = 1, type = "factor", alpha = 0.95, ...)
Arguments
| 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  | 
Value
A list of tibble with the corresponding result under different detector types.
- factor
- the result of factor detector 
- interaction
- the result of interaction detector 
- risk
- the result of risk detector 
- ecological
- the result of ecological detector 
Note
Only one type of detector is supported in a gozh_detector() run at a time.
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
References
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
Examples
data('ndvi')
g = gozh_detector(NDVIchange ~ ., data = ndvi)
g
interactive detector for spatial associations(IDSA) model
Description
interactive detector for spatial associations(IDSA) model
Usage
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,
  ...
)
Arguments
| 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  | 
Value
A list.
- interaction
- the interaction result of IDSA model 
- risk
- whether values of the response variable between a pair of overlay zones are significantly different 
- number_individual_explanatory_variables
- the number of individual explanatory variables used for examining the interaction effects 
- number_overlay_zones
- the number of overlay zones 
- percentage_finely_divided_zones
- the percentage of finely divided zones that are determined by the interaction of variables 
Note
Please note that all variables in the IDSA model need to be continuous data.
The IDSA model requires at least 2^n-1 calculations when has n 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.
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
References
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
Examples
data('sim')
sim1 = sf::st_as_sf(sim,coords = c('lo','la'))
g = idsa(y ~ ., data = sim1)
g
interaction detector
Description
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.
Usage
interaction_detector(y, x1, x2)
Arguments
| y | Dependent variable, continuous numeric vector. | 
| x1 | Covariate  | 
| x2 | Covariate  | 
Value
A list.
- Variable1 Q-statistics
- Q-statistics for variable1 
- Variable2 Q-statistics
- Q-statistics for variable2 
- Variable1 and Variable2 interact Q-statistics
- Q-statistics for variable1 and variable2 interact 
- Interaction
- the interact result type 
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
Examples
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
Description
locally explained stratified heterogeneity(LESH) model
Usage
lesh(formula, data, cores = 1, ...)
Arguments
| 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  | 
Value
A list.
- interaction
- the interaction result of LESH model 
- spd_lesh
- a tibble of the shap power of determinants 
Note
The LESH model requires at least 2^n-1 calculations when has n 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.
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
References
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
Examples
data('ndvi')
g = lesh(NDVIchange ~ ., data = ndvi)
g
determine optimal spatial data analysis scale
Description
Function for determining optimal spatial data analysis scale based on locally estimated scatter plot smoothing (LOESS) model.
Usage
loess_optscale(qvec, spscalevec, increase_rate = 0.05)
Arguments
| 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  | 
Value
A numeric vector about optimal number of spatial scale and the critical increase rate of q value.
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
Examples
## 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
Description
dataset of NDVI changes and its influencing factors, modified from GD package.
Usage
ndvi
Format
ndvi: A tibble with 713 rows and 7 variables
Author(s)
Yongze Song yongze.song@outlook.com
optimal parameters-based geographical detector(OPGD) model
Description
optimal parameters-based geographical detector(OPGD) model
Usage
opgd(
  formula,
  data,
  discvar = NULL,
  discnum = 3:8,
  discmethod = c("sd", "equal", "geometric", "quantile", "natural"),
  cores = 1,
  type = "factor",
  alpha = 0.95,
  ...
)
Arguments
| 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  | 
Value
A list.
- opt_param
- optimal discretization parameter 
- factor
- the result of factor detector 
- interaction
- the result of interaction detector 
- risk
- the result of risk detector 
- ecological
- the result of ecological detector 
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
References
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.
Examples
data('sim')
opgd(y ~ xa + xb + xc, data = sim,
     discvar = paste0('x',letters[1:3]),
     discnum = 3:6)
IDSA Q-saistics PID
Description
IDSA Q-saistics PID
Usage
pid_idsa(formula, rawdata, discdata, wt, overlaymethod = "and")
Arguments
| 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  | 
Details
Q_{IDSA} = \frac{\theta_r}{\phi}
Value
The value of IDSA Q-saistics PID.
Examples
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)
plot ecological detector
Description
S3 method to plot output for ecological detector in geodetector().
Usage
## S3 method for class 'ecological_detector'
plot(x, ...)
Arguments
| x | Return by  | 
| ... | (optional) Other arguments passed to  | 
Value
A ggplot2 layer
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
plot factor detector result
Description
S3 method to plot output for factor detector in geodetector().
Usage
## S3 method for class 'factor_detector'
plot(x, slicenum = 2, alpha = 0.95, keep = TRUE, qlabelsize = 3.88, ...)
Arguments
| 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  | 
Value
A ggplot2 layer.
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
plot GD result
Description
S3 method to plot output for GD model result in gd().
Usage
## S3 method for class 'gd_result'
plot(x, ...)
Arguments
| x | Return by  | 
| ... | (optional) Other arguments. | 
Value
A ggplot2 layer
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
plot GOZH result
Description
S3 method to plot output for GOZH model result in gozh().
Usage
## S3 method for class 'gozh_result'
plot(x, ...)
Arguments
| x | Return by  | 
| ... | (optional) Other arguments. | 
Value
A ggplot2 layer
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
plot IDSA risk result
Description
S3 method to plot output for IDSA risk result in idsa().
Usage
## S3 method for class 'idsa_result'
plot(x, ...)
Arguments
| x | Return by  | 
| ... | (optional) Other arguments passed to  | 
Value
A ggplot2 layer
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
plot interaction detector result
Description
S3 method to plot output for interaction detector in geodetector().
Usage
## S3 method for class 'interaction_detector'
plot(x, alpha = 1, ...)
Arguments
| x | Return by  | 
| alpha | (optional) Picture transparency. Default is  | 
| ... | (optional) Other arguments passed to  | 
Value
A ggplot2 layer
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
plot LESH model result
Description
S3 method to plot output for LESH model interaction result in lesh().
Usage
## 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,
  ...
)
Arguments
| 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  | 
Value
A ggplot2 layer.
Note
When both scatter and pie are set to TRUE in RStudio, enlarge the drawing frame
for normal display.
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
plot OPGD result
Description
S3 method to plot output for OPGD model result in opgd().
Usage
## S3 method for class 'opgd_result'
plot(x, ...)
Arguments
| x | Return by  | 
| ... | (optional) Other arguments. | 
Value
A ggplot2 layer
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
plot RGD result
Description
S3 method to plot output for RGD model result in rgd().
Usage
## S3 method for class 'rgd_result'
plot(x, slicenum = 2, alpha = 0.95, keep = TRUE, ...)
Arguments
| 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  | 
Value
A ggplot2 layer
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
plot RID result
Description
S3 method to plot output for RID model from rid().
Usage
## S3 method for class 'rid_result'
plot(x, alpha = 1, ...)
Arguments
| x | Return by  | 
| alpha | (optional) Picture transparency. Default is  | 
| ... | (optional) Other arguments passed to  | 
Value
A ggplot2 layer
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
plot risk detector
Description
S3 method to plot output for risk detector in geodetector().
Usage
## S3 method for class 'risk_detector'
plot(x, ...)
Arguments
| x | Return by  | 
| ... | (optional) Other arguments passed to  | 
Value
A ggplot2 layer
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
plot gozh sesu
Description
S3 method to plot output for gozh sesu in sesu_gozh().
Usage
## S3 method for class 'sesu_gozh'
plot(x, ...)
Arguments
| x | Return by  | 
| ... | (optional) Other arguments passed to  | 
Value
A ggplot2 layer.
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
plot opgd sesu
Description
S3 method to plot output for opgd sesu in sesu_opgd().
Usage
## S3 method for class 'sesu_opgd'
plot(x, ...)
Arguments
| x | Return by  | 
| ... | (optional) Other arguments passed to  | 
Value
A ggplot2 layer.
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
plot SPADE power of spatial and multilevel discretization determinant
Description
S3 method to plot output for SPADE power of spatial and multilevel discretization
determinant from spade().
Usage
## S3 method for class 'spade_result'
plot(x, slicenum = 2, alpha = 0.95, keep = TRUE, ...)
Arguments
| 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  | 
Value
A ggplot2 layer.
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
plot spatial rough set-based ecological detector
Description
S3 method to plot output for spatial rough set-based ecological detector in srsgd().
Usage
## S3 method for class 'srs_ecological_detector'
plot(x, ...)
Arguments
| x | Return by  | 
| ... | (optional) Other arguments passed to  | 
Value
A ggplot2 layer
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
plot spatial rough set-based factor detector result
Description
S3 method to plot output for spatial rough set-based factor detector in srsgd().
Usage
## S3 method for class 'srs_factor_detector'
plot(x, slicenum = 2, ...)
Arguments
| x | Return by  | 
| slicenum | (optional) The number of labels facing inward. Default is  | 
| ... | (optional) Other arguments passed to  | 
Value
A ggplot2 layer.
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
plot spatial rough set-based interaction detector result
Description
S3 method to plot output for spatial rough set-based interaction detector in srsgd().
Usage
## S3 method for class 'srs_interaction_detector'
plot(x, alpha = 1, ...)
Arguments
| x | Return by  | 
| alpha | (optional) Picture transparency. Default is  | 
| ... | (optional) Other arguments passed to  | 
Value
A ggplot2 layer
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
plot SRSGD result
Description
S3 method to plot output for SRSGD model result in srsgd().
Usage
## S3 method for class 'srsgd_result'
plot(x, ...)
Arguments
| x | Return by  | 
| ... | (optional) Other arguments. | 
Value
A ggplot2 layer
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
print ecological detector
Description
S3 method to format output for ecological detector in geodetector().
Usage
## S3 method for class 'ecological_detector'
print(x, ...)
Arguments
| x | Return by  | 
| ... | (optional) Other arguments passed to  | 
Value
Formatted string output
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
print factor detector
Description
S3 method to format output for factor detector in geodetector().
Usage
## S3 method for class 'factor_detector'
print(x, ...)
Arguments
| x | Return by  | 
| ... | (optional) Other arguments passed to  | 
Value
Formatted string output
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
print GD result
Description
S3 method to format output for GD model from gd().
Usage
## S3 method for class 'gd_result'
print(x, ...)
Arguments
| x | Return by  | 
| ... | (optional) Other arguments passed to  | 
Value
Formatted string output
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
print GOZH result
Description
S3 method to format output for GOZH model from gozh().
Usage
## S3 method for class 'gozh_result'
print(x, ...)
Arguments
| x | Return by  | 
| ... | (optional) Other arguments passed to  | 
Value
Formatted string output
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
print IDSA result
Description
S3 method to format output for IDSA model from idsa().
Usage
## S3 method for class 'idsa_result'
print(x, ...)
Arguments
| x | Return by  | 
| ... | (optional) Other arguments passed to  | 
Value
Formatted string output
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
print interaction detector
Description
S3 method to format output for interaction detector in geodetector().
Usage
## S3 method for class 'interaction_detector'
print(x, ...)
Arguments
| x | Return by  | 
| ... | (optional) Other arguments passed to  | 
Value
Formatted string output
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
print LESH model interaction result
Description
S3 method to format output for LESH model interaction result in lesh().
Usage
## S3 method for class 'lesh_result'
print(x, ...)
Arguments
| x | Return by  | 
| ... | (optional) Other arguments passed to  | 
Value
Formatted string output
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
print OPGD result
Description
S3 method to format output for OPGD model from opgd().
Usage
## S3 method for class 'opgd_result'
print(x, ...)
Arguments
| x | Return by  | 
| ... | (optional) Other arguments passed to  | 
Value
Formatted string output
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
print RGD result
Description
S3 method to format output for RGD model from rgd().
Usage
## S3 method for class 'rgd_result'
print(x, ...)
Arguments
| x | Return by  | 
| ... | (optional) Other arguments passed to  | 
Value
Formatted string output
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
print RID result
Description
S3 method to format output for RID model from rid().
Usage
## S3 method for class 'rid_result'
print(x, ...)
Arguments
| x | Return by  | 
| ... | (optional) Other arguments passed to  | 
Value
Formatted string output
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
print risk detector
Description
S3 method to format output for risk detector in geodetector().
Usage
## S3 method for class 'risk_detector'
print(x, ...)
Arguments
| x | Return by  | 
| ... | (optional) Other arguments passed to  | 
Value
Formatted string output
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
print gozh sesu
Description
S3 method to format output for gozh sesu from sesu_gozh().
Usage
## S3 method for class 'sesu_gozh'
print(x, ...)
Arguments
| x | Return by  | 
| ... | (optional) Other arguments passed to  | 
Value
Formatted string output
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
print opgd sesu
Description
S3 method to format output for opgd sesu from sesu_opgd().
Usage
## S3 method for class 'sesu_opgd'
print(x, ...)
Arguments
| x | Return by  | 
| ... | (optional) Other arguments passed to  | 
Value
Formatted string output
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
print SPADE power of spatial and multilevel discretization determinant
Description
S3 method to format output for SPADE power of spatial and multilevel discretization
determinant from spade().
Usage
## S3 method for class 'spade_result'
print(x, ...)
Arguments
| x | Return by  | 
| ... | Other arguments. | 
Value
Formatted string output
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
print spatial rough set-based ecological detector
Description
S3 method to format output for spatial rough set-based ecological detector in srsgd().
Usage
## S3 method for class 'srs_ecological_detector'
print(x, ...)
Arguments
| x | Return by  | 
| ... | (optional) Other arguments passed to  | 
Value
Formatted string output
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
print spatial rough set-based factor detector
Description
S3 method to format output for spatial rough set-based factor detector in srsgd().
Usage
## S3 method for class 'srs_factor_detector'
print(x, ...)
Arguments
| x | Return by  | 
| ... | (optional) Other arguments passed to  | 
Value
Formatted string output
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
print spatial rough set-based interaction detector
Description
S3 method to format output for spatial rough set-based interaction detector in srsgd().
Usage
## S3 method for class 'srs_interaction_detector'
print(x, ...)
Arguments
| x | Return by  | 
| ... | (optional) Other arguments passed to  | 
Value
Formatted string output
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
print SRSGD result
Description
S3 method to format output for SRSGD model from srsgd().
Usage
## S3 method for class 'srsgd_result'
print(x, ...)
Arguments
| x | Return by  | 
| ... | (optional) Other arguments passed to  | 
Value
Formatted string output
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
PSD of an interaction of explanatory variables (PSD-IEV)
Description
PSD of an interaction of explanatory variables (PSD-IEV)
Usage
psd_iev(discdata, spzone, wt)
Arguments
| discdata | Observed data with discrete explanatory variables. A  | 
| spzone | Fuzzy overlay spatial zones. Returned from  | 
| wt | Spatial weight matrix | 
Details
\phi = 1 - \frac{\sum_{i=1}^m \sum_{k=1}^{n_i}N_{i,k}\tau_{i,k}}{\sum_{i=1}^m N_i \tau_i}
Value
The Value of PSD-IEV
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
References
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
Examples
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)
calculate power of spatial determinant(PSD) and the corresponding pseudo-p value
Description
Function for calculate power of spatial determinant q_s.
Usage
psd_pseudop(y, x, wt, cores = 1, seed = 123456789, permutations = 0)
Arguments
| 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  | 
Details
The power of spatial determinant formula is
q_s = 1 - \frac{\sum_{h=1}^L N_h \Gamma_h}{N \Gamma}
Value
A tibble of power of spatial determinant and the corresponding pseudo-p value.
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
References
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
Examples
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)
power of spatial determinant(PSD)
Description
Function for calculate power of spatial determinant q_s
Usage
psd_spade(y, x, wt)
Arguments
| y | Variable Y, continuous numeric vector. | 
| x | Covariable X,  | 
| wt | The spatial weight matrix. | 
Details
The power of spatial determinant formula is
q_s = 1 - \frac{\sum_{h=1}^L N_h \Gamma_h}{N \Gamma}
Value
A value of power of spatial determinant q_s.
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
References
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
Examples
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)
power of spatial and multilevel discretization determinant(PSMD) and the corresponding pseudo-p value
Description
Function for calculate power of spatial and multilevel discretization determinant and the corresponding pseudo-p value.
Usage
psmd_pseudop(
  yobs,
  xobs,
  wt,
  discnum = 3:8,
  discmethod = "quantile",
  cores = 1,
  seed = 123456789,
  permutations = 0,
  ...
)
Arguments
| 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  | 
Details
The power of spatial and multilevel discretization determinant formula is
PSMDQ_s = MEAN(Q_s)
Value
A tibble of power of spatial and multilevel discretization determinant and the corresponding pseudo-p value.
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
References
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
Examples
data('sim')
wt = sdsfun::inverse_distance_swm(sf::st_as_sf(sim,coords = c('lo','la')))
psmd_pseudop(sim$y,sim$xa,wt)
power of spatial and multilevel discretization determinant(PSMD)
Description
Function for calculate power of spatial and multilevel discretization determinant PSMDQ_s.
Usage
psmd_spade(
  yobs,
  xobs,
  wt,
  discnum = 3:8,
  discmethod = "quantile",
  cores = 1,
  seed = 123456789,
  ...
)
Arguments
| 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  | 
Details
The power of spatial and multilevel discretization determinant formula is
PSMDQ_s = MEAN(Q_s)
Value
A value of power of spatial and multilevel discretization determinant PSMDQ_s.
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
References
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
Examples
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
Description
robust geographical detector(RGD) model
Usage
rgd(
  formula,
  data,
  discvar = NULL,
  discnum = 3:8,
  minsize = 1,
  strategy = 2L,
  increase_rate = 0.05,
  cores = 1
)
Arguments
| 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. | 
Value
A list.
- factor
- robust power of determinant 
- opt_disc
- optimal robust discrete results 
- allfactor
- factor detection results corresponding to different number of robust discreteizations 
- alldisc
- all robust discrete results 
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
References
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.
Examples
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
Description
robust interaction detector(RID) model
Usage
rid(
  formula,
  data,
  discvar = NULL,
  discnum = 3:8,
  minsize = 1,
  strategy = 2L,
  increase_rate = 0.05,
  cores = 1
)
Arguments
| 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. | 
Value
A list.
- interaction
- the result of RID model 
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
References
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
Examples
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))
risk detector
Description
Determine whether there is a significant difference between the attribute means of two sub regions.
Usage
risk_detector(y, x, alpha = 0.95)
Arguments
| y | Variable Y, continuous numeric vector. | 
| x | Covariate X,  | 
| alpha | (optional) Confidence level of the interval, default is  | 
Value
A tibble.
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
Examples
risk_detector(y = 1:7,
              x = c('x',rep('y',3),rep('z',3)))
univariate discretization based on offline change point detection
Description
Determines discretization interval breaks using an optimization algorithm for variance-based change point detection.
Usage
robust_disc(formula, data, discnum, minsize = 1, cores = 1)
Arguments
| 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  | 
Value
A tibble.
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
Examples
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
Description
discretization of variables based on recursive partitioning
Usage
rpart_disc(formula, data, ...)
Arguments
| formula | A formula. | 
| data | A data.frame or tibble of observation data. | 
| ... | (optional) Other arguments passed to  | 
Value
A vector that being discretized.
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
References
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
Examples
data('ndvi')
rpart_disc(NDVIchange ~ ., data = ndvi)
comparison of size effects of spatial units based on GOZH
Description
comparison of size effects of spatial units based on GOZH
Usage
sesu_gozh(
  formula,
  datalist,
  su,
  cores = 1,
  strategy = 2L,
  increase_rate = 0.05,
  alpha = 0.95,
  ...
)
Arguments
| 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  | 
Details
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.
Value
A list.
- sesu
- a tibble representing size effects of spatial units 
- optsu
- optimal spatial unit 
- strategy
- the optimal analytical scale selection strategy 
- increase_rate
- the critical increase rate of q value 
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
References
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
Examples
## 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
Description
comparison of size effects of spatial units based on OPGD
Usage
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,
  ...
)
Arguments
| 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  | 
Details
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.
Value
A list.
- sesu
- a tibble representing size effects of spatial units 
- optsu
- optimal spatial unit 
- increase_rate
- the critical increase rate of q value 
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
References
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.
Examples
## 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.
Description
Simulation data.
Usage
sim
Format
sim: A tibble with 80 rows and 6 variables, modified from IDSA package.
Author(s)
Yongze Song yongze.song@outlook.com
spatial association detector (SPADE) model
Description
spatial association detector (SPADE) model
Usage
spade(
  formula,
  data,
  wt = NULL,
  discvar = NULL,
  discnum = 3:8,
  discmethod = "quantile",
  cores = 1,
  seed = 123456789,
  permutations = 0,
  ...
)
Arguments
| 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  | 
Value
A list.
- factor
- the result of SPADE model 
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
References
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
Examples
data('sim')
sim1 = sf::st_as_sf(sim,coords = c('lo','la'))
g = spade(y ~ ., data = sim1)
g
shap power of determinants
Description
Function for calculate shap power of determinants SPD.
Usage
spd_lesh(formula, data, cores = 1, ...)
Arguments
| 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  | 
Details
The power of shap power of determinants formula is
\theta_{x_j} \left( S \right) = \sum\limits_{s \in M \setminus \{x_j\}} \frac{|S|! \left(|M| - |S| - 1\right)!}{|M|!}\left(v \left(S \cup \left\{x_j\right\} \right) - v\left(S\right)\right).
shap power of determinants (SPD) is the contribution of variable x_j to the power of determinants.
Value
A tibble with variable and its corresponding SPD value.
Note
The shap power of determinants (SPD) requires at least 2^n-1 calculations when has n 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.
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
References
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
Examples
data('ndvi')
g = spd_lesh(NDVIchange ~ ., data = ndvi)
g
spatial rough set-based ecological detector
Description
spatial rough set-based ecological detector
Usage
srs_ecological_detector(y, x1, x2, wt, alpha = 0.95)
Arguments
| y | Dependent variable,  | 
| x1 | Covariate  | 
| x2 | Covariate  | 
| wt | Spatial adjacency matrix. | 
| alpha | (optional) Confidence level of the interval,default is  | 
Value
A list.
- T-statistic
- the result of T statistic for spatial rough set-based ecological detector 
- P-value
- the result of P value for spatial rough set-based ecological detector 
- Ecological
- does one spatial feature - X_1play a more important role than- X_2
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
References
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
Examples
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
Description
spatial rough set-based factor detector
Usage
srs_factor_detector(y, x, wt)
Arguments
| y | Variable Y,  | 
| x | Covariate X,  | 
| wt | Spatial adjacency matrix. | 
Value
A list.
- PD
- the average local explanatory power 
- SE_PD
- the degree of spatial heterogeneity of the local explanatory power 
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
References
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
Examples
data('srs_table')
data('srs_wt')
srs_factor_detector(srs_table$d,srs_table$a1,srs_wt)
spatial rough set-based geographical detector
Description
spatial rough set-based geographical detector
Usage
srs_geodetector(formula, data, wt = NULL, type = "factor", alpha = 0.95)
Arguments
| 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  | 
Value
A list.
- factor
- the result of spatial rough set-based factor detector 
- interaction
- the result of spatial rough set-based interaction detector 
- ecological
- the result of spatial rough set-based ecological detector 
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
Examples
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
Description
spatial rough set-based interaction detector
Usage
srs_interaction_detector(y, x1, x2, wt)
Arguments
| y | Dependent variable,  | 
| x1 | Covariate  | 
| x2 | Covariate  | 
| wt | Spatial adjacency matrix. | 
Value
A list.
- Variable1 PD
- the average local explanatory power for variable1 
- Variable2 PD
- the average local explanatory power for variable2 
- Variable1 and Variable2 interact PD
- the average local explanatory power for variable1 and variable2 interact 
- Variable1 SE_PD
- the degree of spatial heterogeneity of the local explanatory power for variable1 
- Variable2 SE_PD
- the degree of spatial heterogeneity of the local explanatory power for variable2 
- Variable1 and Variable2 SE_PD
- the degree of spatial heterogeneity of the local explanatory power for variable1 and variable2 interact 
- Interaction
- the interact result type 
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
References
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
Examples
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
Description
example of spatial information system table
Usage
srs_table
Format
srs_table: A tibble with 11 rows and 5 variables(one ID column).
example of spatial information system spatial adjacency matrix
Description
example of spatial information system spatial adjacency matrix
Usage
srs_wt
Format
srs_wt: A matrix with 11rows and 11cols.
spatial rough set-based geographical detector(SRSGD) model
Description
spatial rough set-based geographical detector(SRSGD) model
Usage
srsgd(formula, data, wt = NULL, type = "factor", alpha = 0.95)
Arguments
| 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  | 
Value
A list.
- factor
- the result of spatial rough set-based factor detector 
- interaction
- the result of spatial rough set-based interaction detector 
- ecological
- the result of spatial rough set-based ecological detector 
Note
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.
Author(s)
Wenbo Lv lyu.geosocial@gmail.com
References
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
Examples
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
Description
assign values by weight
Usage
weight_assign(x, w, list = FALSE)
Arguments
| x | A numeric value | 
| w | A weight vector | 
| list | (optional) Return list or not. if  | 
Value
A numeric Vector.
Examples
weight_assign(0.875,1:3)