Title: | Analysis of Spatial Stratified Heterogeneity |
---|---|
Description: | Analyzing spatial factors and exploring spatial associations based on the concept of spatial stratified heterogeneity, and also takes into account local spatial dependencies, spatial interpretability, potential spatial interactions, and robust spatial stratification. Additionally, it supports geographical detector models established in academic literature. |
Authors: | Wenbo Lv [aut, cre, cph] , Yangyang Lei [aut] , Fangmei Liu [aut] , Wufan Zhao [aut] , Yongze Song [aut] , Jianwu Yan [aut] |
Maintainer: | Wenbo Lv <[email protected]> |
License: | GPL-3 |
Version: | 1.2 |
Built: | 2024-11-08 10:26:25 UTC |
Source: | CRAN |
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:22, discmethod = "quantile", strategy = 2L, increase_rate = 0.05, cores = 1, return_disc = TRUE, seed = 123456789, ... )
cpsd_disc( formula, data, wt, discnum = 3:22, discmethod = "quantile", strategy = 2L, increase_rate = 0.05, cores = 1, return_disc = TRUE, seed = 123456789, ... )
formula |
A formula of optimal spatial data discretization. |
data |
A data.frame or tibble of observation data. |
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) A positive integer(default is 1). If cores > 1, a 'parallel' package cluster with that many cores is created and used. You can also supply a cluster object. |
return_disc |
(optional) Whether or not return discretized result used the optimal parameter.
Default is |
seed |
(optional) Random seed number, default is |
... |
(optional) Other arguments passed to |
A list with the optimal parameter in the provided parameter combination with k
,
method
and disc
(when return_disc
is TRUE
).
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
When the discmethod
is configured to robust
, it will operate at a significantly reduced speed.
Consequently, the use of robust discretization is not advised.
Wenbo Lv [email protected]
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 = inverse_distance_weight(sim$lo,sim$la) cpsd_disc(y ~ xa + xb + xc, data = sim, wt = wt)
data('sim') wt = inverse_distance_weight(sim$lo,sim$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
.
Wenbo Lv [email protected]
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 = inverse_distance_weight(sim$lo,sim$la) xa = sim$xa xa_disc = sdsfun::discretize_vector(xa,5) cpsd_spade(sim$y,xa,xa_disc,wt)
data('sim') wt = inverse_distance_weight(sim$lo,sim$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-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 and
on the spatial distribution of the attribute
Wenbo Lv [email protected]
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.
Wenbo Lv [email protected]
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)
factor_detector(y, x)
y |
Variable Y, continuous numeric vector. |
x |
Covariate X, |
A list.
Q-statistic
the q statistic for factor detector
P-value
the p value for factor detector
Wenbo Lv [email protected]
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)))
Function for native geographical detector 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.
factor
the result of factor detector
interaction
the result of interaction detector
risk
the result of risk detector
ecological
the result of ecological detector
Wenbo Lv [email protected]
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')) g
data("NTDs") g = gd(incidence ~ watershed + elevation + soiltype, data = NTDs,type = c('factor','interaction')) g
Function for determining the best univariate discretization based on geodetector q-statistic.
gd_bestunidisc( formula, data, discnum = 3:8, discmethod = c("sd", "equal", "geometric", "quantile", "natural"), cores = 1, return_disc = TRUE, seed = 123456789, ... )
gd_bestunidisc( formula, data, discnum = 3:8, discmethod = c("sd", "equal", "geometric", "quantile", "natural"), cores = 1, return_disc = TRUE, seed = 123456789, ... )
formula |
A formula of best univariate discretization. |
data |
A |
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. |
return_disc |
(optional) Whether or not return discretized result used the optimal parameter.
Default is |
seed |
(optional) Random seed number, default is |
... |
(optional) Other arguments passed to |
A list.
x
the name of the variable that needs to be discretized
k
optimal discretization number
method
optimal discretization method
disc
optimal discretization results
Wenbo Lv [email protected]
data('sim') gd_bestunidisc(y ~ xa + xb + xc, data = sim, discnum = 3:6)
data('sim') gd_bestunidisc(y ~ xa + xb + xc, data = sim, discnum = 3:6)
generate subsets of a set
generate_subsets(set, empty = TRUE, self = TRUE)
generate_subsets(set, empty = TRUE, self = TRUE)
set |
A vector. |
empty |
(optional) When |
self |
(optional) When |
A list.
generate_subsets(letters[1:3]) generate_subsets(letters[1:3],empty = FALSE) generate_subsets(letters[1:3],self = FALSE) generate_subsets(letters[1:3],empty = FALSE,self = FALSE)
generate_subsets(letters[1:3]) generate_subsets(letters[1:3],empty = FALSE) generate_subsets(letters[1:3],self = FALSE) generate_subsets(letters[1:3],empty = FALSE,self = FALSE)
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 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 that only one type of geodetector is supported at a time in geodetector()
.
Wenbo Lv [email protected]
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)
Function for 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.
factor
the result of factor detector
interaction
the result of interaction detector
risk
the result of risk detector
ecological
the result of ecological detector
Wenbo Lv [email protected]
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) g
data('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) A positive integer(default is 1). If cores > 1, a 'parallel' package cluster with that many cores is created and used. You can also supply a cluster object. |
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.
factor
the result of factor detector
interaction
the result of interaction detector
risk
the result of risk detector
ecological
the result of ecological detector
Only one type of detector is supported in a gozh_detector()
run at a time.
Wenbo Lv [email protected]
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) g
data('ndvi') g = gozh_detector(NDVIchange ~ ., data = ndvi) g
Function for interactive detector for spatial associations 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.
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
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.
Wenbo Lv [email protected]
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) g
data('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-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
Wenbo Lv [email protected]
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)))
Function for calculate inverse distance weight.
inverse_distance_weight(locx, locy, power = 1, is_arc = FALSE)
inverse_distance_weight(locx, locy, power = 1, is_arc = FALSE)
locx |
The x axis location. |
locy |
The y axis location. |
power |
(optional) Default is 1. Set to 2 for gravity weights. |
is_arc |
(optional) |
The inverse distance weight formula is
A inverse distance weight matrices with class of matrix
.
Wenbo Lv [email protected]
x = 1:10 y = 1:10 inverse_distance_weight(x,y) inverse_distance_weight(x,y,is_arc = TRUE)
x = 1:10 y = 1:10 inverse_distance_weight(x,y) inverse_distance_weight(x,y,is_arc = TRUE)
Function for interpretable stratified power model.
isp( formula, data, discvar = NULL, discnum = 3:8, overlay = "and", strategy = 2L, increase_rate = 0.05, minsize = 1, cores = 1, alpha = 0.95 )
isp( formula, data, discvar = NULL, discnum = 3:8, overlay = "and", strategy = 2L, increase_rate = 0.05, minsize = 1, cores = 1, alpha = 0.95 )
formula |
A formula of ISP model. |
data |
A |
discvar |
(optional) 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 |
overlay |
(optional) Spatial overlay method. One of |
strategy |
(optional) Optimal discretization strategy. When |
increase_rate |
(optional) The critical increase rate of the number of discretization. Default is |
minsize |
(optional) The min size of each discretization group. Default all use |
cores |
(optional) Positive integer (default is 1). When cores are greater than 1, use multi-core parallel computing. |
alpha |
(optional) Specifies the size of confidence level. Default is |
A list.
factor
factor detect results
interaction
interaction detect results
optdisc
independent variable optimal spatial discretization
risk1
whether values of the response variable between a pair of overlay zones are significantly different
risk2
risk detection result of the input data
rpd
robust power of determinants
spd
shap power of determinants
determination
determination of the optimal interaction of variables
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
Please set up python dependence and configure GDVERSE_PYTHON
environment variable if you want to run rgd()
.
See vignette('rgdrid',package = 'gdverse')
for more details.
Wenbo Lv [email protected]
## Not run: ## The following code needs to configure the Python environment to run: data('sim') sim1 = dplyr::select(sim,-dplyr::any_of(c('lo','la'))) g = isp(y ~ ., data = sim1, discnum = 3:8, cores = 6) g ## End(Not run)
## Not run: ## The following code needs to configure the Python environment to run: data('sim') sim1 = dplyr::select(sim,-dplyr::any_of(c('lo','la'))) g = isp(y ~ ., data = sim1, discnum = 3:8, cores = 6) g ## End(Not run)
Function for locally explained heterogeneity 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.
interaction
the interaction result of LESH model
spd_lesh
a 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.
Wenbo Lv [email protected]
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) g
data('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.
Wenbo Lv [email protected]
## 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.
ndvi
ndvi
ndvi
: A tibble with 713 rows and 7 variables
Yongze Song [email protected]
The data were obtained by preprocessing use sf
and tidyverse
.
NTDs
NTDs
NTDs
: A tibble with 185 rows and 4 variable columns and 2 location columns, modified from geodetector
package.
Function for 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_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
Wenbo Lv [email protected]
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 = inverse_distance_weight(sim$lo,sim$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 = inverse_distance_weight(sim$lo,sim$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
Wenbo Lv [email protected]
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, ...)
## S3 method for class 'factor_detector' 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.
Wenbo Lv [email protected]
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 passed to |
A ggplot2 layer
Wenbo Lv [email protected]
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 passed to |
A ggplot2 layer
Wenbo Lv [email protected]
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
Wenbo Lv [email protected]
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
Wenbo Lv [email protected]
S3 method to plot output for ISP result in isp()
.
## S3 method for class 'isp_result' plot(x, low_color = "#6600CC", high_color = "#FFCC33", ...)
## S3 method for class 'isp_result' plot(x, low_color = "#6600CC", high_color = "#FFCC33", ...)
x |
Return by |
low_color |
(optional) The low color of the color gradient, default is |
high_color |
(optional) The high color of the color gradient, default is |
... |
(optional) Other arguments passed to |
A ggplot2 layer
Wenbo Lv [email protected]
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.
Wenbo Lv [email protected]
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 passed to |
A ggplot2 layer
Wenbo Lv [email protected]
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
Wenbo Lv [email protected]
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
Wenbo Lv [email protected]
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
Wenbo Lv [email protected]
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.
Wenbo Lv [email protected]
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.
Wenbo Lv [email protected]
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.
Wenbo Lv [email protected]
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
Wenbo Lv [email protected]
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.
Wenbo Lv [email protected]
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
Wenbo Lv [email protected]
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 passed to |
A ggplot2 layer
Wenbo Lv [email protected]
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
Wenbo Lv [email protected]
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
Wenbo Lv [email protected]
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
Wenbo Lv [email protected]
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
Wenbo Lv [email protected]
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
Wenbo Lv [email protected]
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
Wenbo Lv [email protected]
S3 method to format output for ISP model from isp()
.
## S3 method for class 'isp_result' print(x, ...)
## S3 method for class 'isp_result' print(x, ...)
x |
Return by |
... |
(optional) Other arguments passed to |
Formatted string output
Wenbo Lv [email protected]
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
Wenbo Lv [email protected]
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
Wenbo Lv [email protected]
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
Wenbo Lv [email protected]
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
Wenbo Lv [email protected]
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
Wenbo Lv [email protected]
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
Wenbo Lv [email protected]
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
Wenbo Lv [email protected]
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
Wenbo Lv [email protected]
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
Wenbo Lv [email protected]
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
Wenbo Lv [email protected]
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
Wenbo Lv [email protected]
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
Wenbo Lv [email protected]
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
Wenbo Lv [email protected]
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 = inverse_distance_weight(sim$lo,sim$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 = inverse_distance_weight(sim$lo,sim$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.
Wenbo Lv [email protected]
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 = inverse_distance_weight(sim$lo,sim$la,power = 2) psd_pseudop(sim$y,sdsfun::discretize_vector(sim$xa,5),wt)
data('sim') wt = inverse_distance_weight(sim$lo,sim$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
.
Wenbo Lv [email protected]
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 = inverse_distance_weight(sim$lo,sim$la,power = 2) psd_spade(sim$y,sdsfun::discretize_vector(sim$xa,5),wt)
data('sim') wt = inverse_distance_weight(sim$lo,sim$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:22, discmethod = "quantile", cores = 1, seed = 123456789, permutations = 0, ... )
psmd_pseudop( yobs, xobs, wt, discnum = 3:22, 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.
Wenbo Lv [email protected]
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 = inverse_distance_weight(sim$lo,sim$la) psmd_pseudop(sim$y,sim$xa,wt)
data('sim') wt = inverse_distance_weight(sim$lo,sim$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:22, discmethod = "quantile", cores = 1, seed = 123456789, ... )
psmd_spade( yobs, xobs, wt, discnum = 3:22, discmethod = "quantile", cores = 1, seed = 123456789, ... )
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 |
... |
(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
.
Wenbo Lv [email protected]
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 = inverse_distance_weight(sim$lo,sim$la) psmd_spade(sim$y,sim$xa,wt)
data('sim') wt = inverse_distance_weight(sim$lo,sim$la) psmd_spade(sim$y,sim$xa,wt)
Function for robust geographical detector(RGD) model.
rgd(formula, data, discvar = NULL, discnum = 3:8, minsize = 1, cores = 1)
rgd(formula, data, discvar = NULL, discnum = 3:8, minsize = 1, 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 |
cores |
(optional) Positive integer (default is 1). When cores are greater than 1, use multi-core parallel computing. |
A list.
factor
the result of RGD model
disc
robust discrete results
Please set up python dependence and configure GDVERSE_PYTHON
environment variable if you want to run rgd()
.
See vignette('rgdrid',package = 'gdverse')
for more details.
Wenbo Lv [email protected]
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.
## Not run: ## The following code needs to configure the Python environment to run: data('sim') g = rgd(y ~ ., data = dplyr::select(sim,-dplyr::any_of(c('lo','la'))), discnum = 3:6, cores = 6) g ## End(Not run)
## Not run: ## The following code needs to configure the Python environment to run: data('sim') g = rgd(y ~ ., data = dplyr::select(sim,-dplyr::any_of(c('lo','la'))), discnum = 3:6, cores = 6) g ## End(Not run)
Function for robust interaction detector(RID) model.
rid(formula, data, discvar = NULL, discnum = 10, minsize = 1, cores = 1)
rid(formula, data, discvar = NULL, discnum = 10, minsize = 1, cores = 1)
formula |
A formula of RID model. |
data |
A |
discvar |
Name of continuous variable columns that need to be discretized. Noted that
when |
discnum |
A numeric vector for the number of discretized classes of columns that need
to be discretized. Default all |
minsize |
(optional) The min size of each discretization group. Default all use |
cores |
(optional) Positive integer (default is 1). When cores are greater than 1, use multi-core parallel computing. |
A list.
interaction
the result of RID model
Please set up python dependence and configure GDVERSE_PYTHON
environment variable if you want to run rid()
.
See vignette('rgdrid',package = 'gdverse')
for more details.
Wenbo Lv [email protected]
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
## Not run: ## The following code needs to configure the Python environment to run: data('sim') g = rid(y ~ ., data = dplyr::select(sim,-dplyr::any_of(c('lo','la'))), discnum = 4, cores = 6) g ## End(Not run)
## Not run: ## The following code needs to configure the Python environment to run: data('sim') g = rid(y ~ ., data = dplyr::select(sim,-dplyr::any_of(c('lo','la'))), discnum = 4, cores = 6) g ## End(Not run)
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. contains different combinations of covariate X
level and student t-test statistics,
degrees of freedom, p-values, and whether has risk (Yes or No).
Wenbo Lv [email protected]
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 of discretized columns which need to be discretized.
Please set up python dependence and configure GDVERSE_PYTHON
environment variable if you want to run robust_disc()
.
See vignette('rgdrid',package = 'gdverse')
for more details.
Wenbo Lv [email protected]
## Not run: ## The following code needs to configure the Python environment to run: data('ndvi') robust_disc(NDVIchange ~ GDP,data = ndvi,discnum = 5) robust_disc(NDVIchange ~ ., data = dplyr::select(ndvi,-c(Climatezone,Mining)), discnum = 10,cores = 6) ## End(Not run)
## Not run: ## The following code needs to configure the Python environment to run: data('ndvi') robust_disc(NDVIchange ~ GDP,data = ndvi,discnum = 5) robust_disc(NDVIchange ~ ., data = dplyr::select(ndvi,-c(Climatezone,Mining)), discnum = 10,cores = 6) ## End(Not run)
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.
Wenbo Lv [email protected]
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)
Function for comparison of size effects of spatial units in spatial heterogeneity analysis based on geographically optimal zones-based heterogeneity(GOZH) model.
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.
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
Wenbo Lv [email protected]
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)
Function for comparison of size effects of spatial units in spatial heterogeneity analysis based on optimal parameters geographical detector(OPGD) model.
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.
sesu
a tibble representing size effects of spatial units
optsu
optimal spatial unit
increase_rate
the critical increase rate of q value
Wenbo Lv [email protected]
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)
randomly shuffling vector
shuffle_vector(x, shuffle_rate, seed = 123456789)
shuffle_vector(x, shuffle_rate, seed = 123456789)
x |
A vector. |
shuffle_rate |
The shuffling rate. |
seed |
(optional) Random seed number. Default is |
A shuffled vector.
shuffle_vector(1:100,0.15)
shuffle_vector(1:100,0.15)
Simulation data.
sim
sim
sim
: A tibble with 80 rows and 6 variables, modified from IDSA
package.
Yongze Song [email protected]
Function for 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.
factor
the result of SPADE model
Wenbo Lv [email protected]
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) g
data('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) A positive integer(default is 1). If cores > 1, a 'parallel' package cluster with that many cores is created and used. You can also supply a cluster object. |
... |
(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.
Wenbo Lv [email protected]
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) g
data('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-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 play a more important role than
Wenbo Lv [email protected]
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.
PD
the average local explanatory power
SE_PD
the degree of spatial heterogeneity of the local explanatory power
Wenbo Lv [email protected]
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 of tibble with the corresponding result under different detector types.
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
Wenbo Lv [email protected]
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 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
Wenbo Lv [email protected]
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_table
srs_table
srs_table
: A tibble with 11 rows and 5 variables(one ID
column).
example of spatial information system spatial adjacency matrix
srs_wt
srs_wt
srs_wt
: A matrix with 11rows and 11cols.
Function for spatial rough set-based geographical detector 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.
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
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.
Wenbo Lv [email protected]
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)