Package 'GD'

Title: Geographical Detectors for Assessing Spatial Factors
Description: Geographical detectors for measuring spatial stratified heterogeneity, as described in Jinfeng Wang (2010) <doi:10.1080/13658810802443457> and Jinfeng Wang (2016) <doi:10.1016/j.ecolind.2016.02.052>. Includes the optimal discretization of continuous data, four primary functions of geographical detectors, comparison of size effects of spatial unit and the visualizations of results. To use the package and to refer the descriptions of the package, methods and case datasets, please cite Yongze Song (2020) <doi:10.1080/15481603.2020.1760434>. The model has been applied in factor exploration of road performance and multi-scale spatial segmentation for network data, as described in Yongze Song (2018) <doi:10.3390/rs10111696> and Yongze Song (2020) <doi:10.1109/TITS.2020.3001193>, respectively.
Authors: Yongze Song [aut, cph] , Wenbo Lv [aut, cre]
Maintainer: Wenbo Lv <[email protected]>
License: GPL-3
Version: 10.8
Built: 2024-11-21 07:08:10 UTC
Source: CRAN

Help Index


Generates discretization parameters for continuous data.

Description

Function for discretizing continuous data and obtaining the different outputs, including discretization intervals, numbers of values within intervals, and visualization of discretization.

Usage

disc(var, n, method = "quantile", ManualItv)

Arguments

var

A numeric vector of continuous variable

n

The numeber of intervals

method

A character of discretization method

ManualItv

A numeric vector of manual intervals

Examples

## method is default (quantile); number of intervals is 4
ds1 <- disc(ndvi_40$Tempchange, 4)
ds1
## method is equal; number of intervals is 4
ds2 <- disc(ndvi_40$Tempchange, 4, method = "equal")
## method is manual; number of intervals is 4
manualitv1 <- c(-0.5, 0, 1, 2, 4)
ds3 <- disc(ndvi_40$Tempchange, 4, method = "manual", ManualItv = manualitv1)

Geographical detectors: factor detector.

Description

Function for calculating power determinant using factor detector of geographical detectors and visualization.

Usage

gd(formula, data = NULL)
## S3 method for class 'gd'
print(x, ...)
## S3 method for class 'gd'
plot(x, sig = TRUE, ...)

Arguments

formula

A formula of response and explanatory variables

data

A data.frame includes response and explanatory variables

x

A list of factor detector results

sig

If TRUE, only spatial associations that are significant at the 0.05 level will be plotted; If FALSE, all spatial associations will be plotted.

...

Ignore

Examples

g1 <- gd(NDVIchange ~ Climatezone + Mining, data = ndvi_40)
g1
plot(g1)

Geographical detectors: ecological detector.

Description

Function for ecological detector calculation, ecological matrix and visulization.

Usage

gdeco(formula, data = NULL)
## S3 method for class 'gdeco'
print(x, ...)
## S3 method for class 'gdeco'
plot(x, ...)

Arguments

formula

A formula of response and explanatory variables

data

A data.frame includes response and explanatory variables

x

A list of ecological detector results

...

Ignore

Examples

ge1 <- gdeco(NDVIchange ~ Climatezone + Mining, data = ndvi_40)
ge1

data <- ndvi_40[,1:3]
ge2 <- gdeco(NDVIchange ~ ., data = data)
ge2

Geographical detectors: interaction detector.

Description

Function for interaction detector calculation and visualization. The types of interactions include "Enhance, nonlinear", "Independent", "Enhance, bi-", "Weaken, uni-" and "Weaken, nonlinear".

Usage

gdinteract(formula, data = NULL)
## S3 method for class 'gdinteract'
print(x, ...)
## S3 method for class 'gdinteract'
plot(x, ...)

Arguments

formula

A formula of response and explanatory variables

data

A data.frame includes response and explanatory variables

x

A list of interaction detector results

...

Ignore

Examples

gi1 <- gdinteract(NDVIchange ~ Climatezone + Mining, data = ndvi_40)
gi1

data <- ndvi_40[,1:3]
gi2 <- gdinteract(NDVIchange ~ ., data = data)
gi2

Geographical detectors: a one-step function.

Description

A one-step function for optimal discretization and geographical detectors for multiple variables and visualization.

Usage

gdm(formula, continuous_variable = NULL, data = NULL, discmethod, discitv)
## S3 method for class 'gdm'
print(x, ...)
## S3 method for class 'gdm'
plot(x, ...)

Arguments

formula

A formula of response and explanatory variables

continuous_variable

A vector of continuous variable names

data

A data.frame includes response and explanatory variables

discmethod

A character vector of discretization methods

discitv

A numeric vector of numbers of intervals

x

A list of gdm result

...

Ignore

Examples

###############
## NDVI: ndvi_40
###############
## set optional parameters of optimal discretization
## optional methods: equal, natural, quantile, geometric, sd and manual
discmethod <- c("equal","quantile")
discitv <- c(4:5)
## "gdm" function
ndvigdm <- gdm(NDVIchange ~ Climatezone + Mining + Tempchange,
               continuous_variable = c("Tempchange"),
               data = ndvi_40,
               discmethod = discmethod, discitv = discitv)
ndvigdm
plot(ndvigdm)
## Not run: 
#############
## H1N1: h1n1_100
#############
## set optional parameters of optimal discretization
discmethod <- c("equal","natural","quantile")
discitv <- c(4:6)
continuous_variable <- colnames(h1n1_100)[-c(1,11)]
## "gdm" function
h1n1gdm <- gdm(H1N1 ~ .,
               continuous_variable = continuous_variable,
               data = h1n1_100,
               discmethod = discmethod, discitv = discitv)
h1n1gdm
plot(h1n1gdm)

## End(Not run)

Geographical detectors: risk detector.

Description

Function for risk detector calculation, risk matrix and visualization.

Usage

gdrisk(formula, data = NULL)
## S3 method for class 'gdrisk'
print(x, ...)
## S3 method for class 'gdrisk'
plot(x, ...)

Arguments

formula

A formula of response and explanatory variables

data

A data.frame includes response and explanatory variables

x

A list of risk detector results

...

Ignore

Examples

gr1 <- gdrisk(NDVIchange ~ Climatezone + Mining, data = ndvi_40)
gr1
plot(gr1)

data <- ndvi_40[,1:3]
gr2 <- gdrisk(NDVIchange ~ ., data = data)
gr2

Spatial datasets of H1N1 flu incidences

Description

The "H1N1" dataset provides provincial statistical incidences of influenza A virus subtype H1N1 in China for 2013. It includes H1N1 incidences and related variables across three different spatial grid sizes: 50 km, 100 km, and 150 km. Detailed references and data sources will be added.

Usage

h1n1_50

h1n1_100

h1n1_150

Format

h1n1_50

A data frame with 3977 rows and 11 variables (50 km grid size).

h1n1_100

A data frame with 987 rows and 11 variables (100 km grid size).

h1n1_150

A data frame with 443 rows and 11 variables (150 km grid size).


Spatial datasets of vegetation index changes.

Description

The "NDVI" dataset contains NDVI change data from 2010 to 2014 in Inner Mongolia, China. It includes NDVI change and potential variables sampled from six spatial grid sizes: 5 km, 10 km, 20 km, 30 km, 40 km, and 50 km. References for more details and data sources will be provided.

Usage

ndvi_5

ndvi_10

ndvi_20

ndvi_30

ndvi_40

ndvi_50

Format

ndvi_5

A data frame with 46,295 rows and 7 variables (5 km grid size).

ndvi_10

A data frame with 11,567 rows and 7 variables (10 km grid size).

ndvi_20

A data frame with 2,892 rows and 7 variables (20 km grid size).

ndvi_30

A data frame with 1,290 rows and 7 variables (30 km grid size).

ndvi_40

A data frame with 713 rows and 7 variables (40 km grid size).

ndvi_50

A data frame with 469 rows and 7 variables (50 km grid size).


Optimal discretization for continuous variables and visualization.

Description

Optimal discretization for continuous variables and visualization.

Usage

optidisc(formula, data,
        discmethod = discmethod, discitv = discitv)
## S3 method for class 'optidisc'
print(x, ...)
## S3 method for class 'optidisc'
plot(x, ...)

Arguments

formula

A formula of response and explanatory variables, where the explanatory variables must be continuous variables to be discretized.

data

A data.frame includes response and explanatory variables

discmethod

A character vector of discretization methods

discitv

A numeric vector of numbers of intervals

x

A list of optidisc result

...

Ignore

Examples

## set optional discretization methods and numbers of intervals
# optional methods: equal, natural, quantile, geometric, sd and manual
discmethod <- c("equal","quantile")
discitv <- c(4:5)
## optimal discretization
odc1 <- optidisc(NDVIchange ~ Tempchange, ndvi_40, discmethod, discitv)
odc1
plot(odc1)

Geographical detectors: risk means in risk detector.

Description

Function for calculating risk means within intervals and visualization.

Usage

riskmean(formula, data = NULL)
## S3 method for class 'riskmean'
print(x, ...)
## S3 method for class 'riskmean'
plot(x, ...)

Arguments

formula

a formula of response and explanatory variables

data

a data.frame includes response and explanatory variables

x

a list of risk mean values

...

ignore

Examples

rm1 <- riskmean(NDVIchange ~ Climatezone + Mining, data = ndvi_40)
rm1
plot(rm1)

data <- ndvi_40[,1:3]
rm2 <- riskmean(NDVIchange ~ ., data = data)
rm2

Comparison of size effects of spatial units.

Description

Function for comparison of size effects of spatial units in spatial heterogeneity analysis.

Usage

sesu(gdlist, su)

Arguments

gdlist

A list of gdm result or gd result

su

A vector of sizes of spatial units

Examples

ndvilist <- list(ndvi_30, ndvi_40, ndvi_50)
su <- c(30, 40, 50) ## sizes of spatial units
## "gdm" function
gdlist <- lapply(ndvilist, function(x){
  gdm(NDVIchange ~ Climatezone + Mining, data = x)
})
sesu(gdlist, su) ## size effects of spatial units

Converts a vector to a lower triangular matrix.

Description

The function v2m is used in the functions gdrisk, gdinteract and gdeco for converting a vector is from the results of the risk detector result, interaction detector result or ecological detector to a lower triangular matrix.

Usage

v2m(vec, diag = FALSE)

Arguments

vec

A data.frame of risk/interaction/ecological detector result of a strata variable

diag

TRUE/FALSE, indicating if the output matrix is a diagonal matrix.