Skip to contents

Function for optimal parameters-based geographical detector(OPGD) model.

Usage

opgd(
  formula,
  data,
  discvar = NULL,
  discnum = 3:22,
  discmethod = c("sd", "equal", "pretty", "quantile", "fisher", "headtails", "maximum",
    "box"),
  cores = 1,
  type = "factor",
  alpha = 0.95,
  ...
)

Arguments

formula

A formula of OPGD model.

data

A data.frame, tibble or sf object of observation data.

discvar

Name of continuous variable columns that need to be discretized. Noted that when formula has discvar, data must have these columns. By default, all independent variables are used as discvar.

discnum

(optional) A vector of number of classes for discretization. Default is 3:22.

discmethod

(optional) A vector of methods for discretization, default is using c("sd","equal","pretty","quantile","fisher","headtails","maximum","box").

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 factor(default), interaction, risk, ecological. You can run one or more types at one time.

alpha

(optional) Specifies the size of confidence level.Default is 0.95.

...

(optional) Other arguments passed to gd_bestunidisc().A useful parameter is seed, which is used to set the random number seed.

Value

A list of the OPGD model result.

factor

the result of factor detector

interaction

the result of interaction detector

risk

the result of risk detector

ecological

the result of ecological detector

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.

Author

Wenbo Lv lyu.geosocial@gmail.com

Examples

data('sim')
opgd(y ~ xa + xb + xc, data = sim,
     discvar = paste0('x',letters[1:3]),
     discnum = 3:6)
#>                 OPGD Model                  
#> ***          Factor Detector            
#> 
#> | variable | Q-statistic |   P-value    |
#> |:--------:|:-----------:|:------------:|
#> |    xc    |  0.5476636  | 4.500000e-09 |
#> |    xb    |  0.4723013  | 5.350665e-05 |
#> |    xa    |  0.3164566  | 6.695939e-04 |
#>