Learn R Programming

gdverse (version 1.3-1)

cpsd_disc: 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,
  return_disc = TRUE,
  seed = 123456789,
  ...
)

Value

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

Arguments

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 3:8.

discmethod

(optional) The discretization methods. Default all use quantile. Noted that robust will use robust_disc(); rpart will use rpart_disc(); Others use sdsfun::discretize_vector().

strategy

(optional) Discretization strategy. When strategy is 1L, choose the highest SPADE model q-statistics to determinate optimal spatial data discretization parameters. When strategy is 2L, The optimal discrete parameters of spatial data are selected by combining LOESS model.

increase_rate

(optional) The critical increase rate of the number of discretization. Default is 5%.

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 TRUE.

seed

(optional) Random seed number, default is 123456789.Setting random seed is useful when the sample size is greater than 3000(the default value for largeN) and the data is discretized by sampling 10%(the default value for samp_prop in st_unidisc()).

...

(optional) Other arguments passed to st_unidisc(),robust_disc() or rpart_disc().

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

Run this code
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)

Run the code above in your browser using DataLab