Skip to contents

Function for determining optimal spatial data discretization for individual variables based on locally estimated scatterplot smoothing (LOESS) model.

Usage

loess_optdiscnum(qvec, discnumvec, increase_rate = 0.05)

Arguments

qvec

A numeric vector of q statistics.

discnumvec

A numeric vector of break numbers corresponding to qvec.

increase_rate

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

Value

A optimal number of spatial data discretization.

Note

When increase_rate is not satisfied by the calculation, increase_rate*0.1 is used first. At this time, if increase_rate*0.1 is not satisfied again, the discrete number corresponding to the highest Q-statistic is selected as a return.

Note that gdverse sorts discnumvec from smallest to largest and keeps qvec in one-to-one correspondence with discnumvec.

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

Author

Wenbo Lv lyu.geosocial@gmail.com

Examples

data('sim')
3:10 %>%
  purrr::map_dbl(\(.k) st_unidisc(sim$xa,.k) %>%
               factor_detector(sim$y,.) %>%
               {.[[1]]}) %>%
 loess_optdiscnum(3:10)
#> discnum 
#>       7