-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
25 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,9 @@ | ||
#' @title best univariate discretization based on geodetector q-statistic | ||
#' @title optimal univariate discretization based on geodetector q-statistic | ||
#' @author Wenbo Lv \email{[email protected]} | ||
#' @description | ||
#' Function for determining the best univariate discretization based on geodetector q-statistic. | ||
#' | ||
#' @param formula A formula of best univariate discretization. | ||
#' @param formula A formula. | ||
#' @param data A `data.frame`, `tibble` or `sf` object of observation data. | ||
#' @param discnum (optional) A vector of number of classes for discretization. Default is `3:8`. | ||
#' @param discnum (optional) A vector of numbers of discretization. Default is `3:8`. | ||
#' @param discmethod (optional) A vector of methods for discretization, default is using | ||
#' `c("sd","equal","geometric","quantile","natural")` by invoking `sdsfun`. | ||
#' @param cores (optional) Positive integer (default is 1). When cores are greater than 1, use | ||
|
@@ -25,13 +23,13 @@ | |
#' | ||
#' @examples | ||
#' data('sim') | ||
#' gd_bestunidisc(y ~ xa + xb + xc, | ||
#' data = sim, | ||
#' discnum = 3:6) | ||
#' gd_optunidisc(y ~ xa + xb + xc, | ||
#' data = sim, | ||
#' discnum = 3:6) | ||
#' | ||
gd_bestunidisc = \(formula, data, discnum = 3:8, | ||
discmethod = c("sd","equal","geometric","quantile","natural"), | ||
cores = 1, seed = 123456789, ...){ | ||
gd_optunidisc = \(formula, data, discnum = 3:8, | ||
discmethod = c("sd","equal","geometric","quantile","natural"), | ||
cores = 1, seed = 123456789, ...){ | ||
doclust = FALSE | ||
if (cores > 1) { | ||
doclust = TRUE | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
#' @title optimal parameters-based geographical detector(OPGD) model | ||
#' @author Wenbo Lv \email{[email protected]} | ||
#' @description | ||
#' Function for optimal parameters-based geographical detector(OPGD) model. | ||
#' @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 | ||
|
@@ -55,9 +53,9 @@ opgd = \(formula, data, discvar = NULL, discnum = 3:8, | |
discvar = colnames(data)[-which(colnames(data) == yname)] | ||
} | ||
discdf = dplyr::select(data,dplyr::all_of(c(yname,discvar))) | ||
g = gd_bestunidisc(paste0(yname,'~',paste0(discvar,collapse = '+')), | ||
data = discdf, discnum = discnum, | ||
discmethod = discmethod, cores = cores, ...) | ||
g = gd_optunidisc(paste0(yname,'~',paste0(discvar,collapse = '+')), | ||
data = discdf, discnum = discnum, | ||
discmethod = discmethod, cores = cores, ...) | ||
opt_param = tibble::as_tibble(g[1:3]) | ||
names(opt_param) = c("varibale","discnum","method") | ||
discedvar = colnames(data[,-which(colnames(data) %in% discvar)]) | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.