This function selects the optimal bandwidths (spatial and/or temporal) for GWR or MGWR models by minimizing the Corrected Akaike Information Criterion (AICc). It uses a multi-round grid search approach (coarse-to-fine) to efficiently narrow down the optimal parameter space before optionally applying a golden section search for final refinement.
search_bandwidths(
formula,
data,
coords,
fixed_vars = NULL,
kernels = c("gauss", "gauss"),
Model = "GWR",
control = list(),
hs_range = NULL,
ht_range = NULL,
n_seq = 10,
ncore = 1,
n_rounds = 0,
refine = TRUE,
verbose = FALSE,
show_progress = FALSE,
tol = NULL,
parallel_method = "auto"
)A list containing:
The mode of optimization ("spatial_only" or "spatio-temporal").
A list of data frames containing the results (bandwidths and AICc) for each round.
A data frame row corresponding to the best parameter combination found.
The result of the refinement step (if refine = TRUE).
The final mgwrsar model object fitted with the optimal bandwidths.
The total computation time.
A formula object specifying the model (e.g., y ~ x1 + x2).
A data frame containing the variables in the model.
A matrix or data frame of coordinates (2 columns for spatial, 1 for temporal, or more for GDT).
A character vector indicating the names of variables with spatially stationary (fixed) coefficients.
Default is NULL (all coefficients are varying).
A character vector specifying the kernel types for spatial and temporal components
(e.g., c("gauss", "gauss")).
A character string specifying the model type. Options include "GWR", "MGWR", "OLS", "SAR", etc. Default is "GWR".
A named list of extra control arguments passed to the MGWRSAR function
(e.g., adaptive, NN, Z).
A numeric vector of length 2 defining the lower and upper bounds for the spatial bandwidth search.
A numeric vector of length 2 defining the lower and upper bounds for the temporal bandwidth search.
Set to NULL for spatial-only models.
An integer specifying the number of bandwidth candidates to test per dimension in each round.
An integer specifying the number of CPU cores to use for parallel processing.
Default is parallel::detectCores() - 1.
An integer specifying the number of grid search rounds (zooming steps). Default is 3.
Logical. If TRUE, a final optimization step using golden section search is performed
around the best candidate found. Default is FALSE.
Logical. If TRUE, prints progress messages to the console.
Logical. If TRUE, displays a progress bar during computation.
A numeric vector of length 2 (or 1) specifying the
tolerance for spatial and temporal bandwidths. If NULL, it
is calculated automatically based on the range.
Parallelization method ("auto", "fork", "socket"); "auto" selects the best available backend depending on the OS, other values run sequentially.
The function performs a grid search over n_rounds. In the first round, it tests n_seq
candidates linearly or geometrically spaced within the provided ranges. In subsequent rounds,
the search range is narrowed around the best candidate from the previous round.
MGWRSAR