Learn R Programming

GD (version 1.6)

gdm: 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 gdm
print(x, ...)
# S3 method for 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

Run this code
# NOT RUN {
###############
## NDVI: ndvi_40
###############
## define elements orders of categorical variables
cz <- c("Bwk","Bsk","Dwa","Dwb","Dwc") ## climate zone
mp <- c("very low","low","medium","high","very high") ## mining production
ndvi_40$Climatezone <- as.numeric(1:5)[match(ndvi_40$Climatezone, cz)]
ndvi_40$Mining <- as.numeric(1:5)[match(ndvi_40$Mining, mp)]
## set optional parameters of optimal discretization
## optional methods: equal, natural, quantile, geometric, sd and manual
discmethod <- c("equal","natural","quantile")
discitv <- c(4:6)
## "gdm" function
ndvigdm <- gdm(NDVIchange ~ Climatezone + Mining + Tempchange + GDP,
               continuous_variable = c("Tempchange", "GDP"),
               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)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab