Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add warning when bandwidth < cell size #29

Open
mpjashby opened this issue Feb 11, 2023 · 2 comments
Open

Add warning when bandwidth < cell size #29

mpjashby opened this issue Feb 11, 2023 · 2 comments
Assignees
Labels
enhancement New feature or request low priority

Comments

@mpjashby
Copy link
Owner

Is your feature request related to a problem? Please describe.
When the bandwidth approaches the cell size, the KDE estimates will fall to zero because no cells will be included in the density estimation.

Describe the solution you'd like
A warning if the bandwidth is either less than the cell size or less than whatever multiple of the cell size means that no cells are included.

Describe alternatives you've considered
The warning could be an error, but a warning is probably best because there may be unforeseen circumstances in which a small bandwidth is desirable.

@mpjashby mpjashby added the enhancement New feature or request label Feb 11, 2023
@mpjashby mpjashby self-assigned this Feb 11, 2023
@mpjashby
Copy link
Owner Author

This is probably best dealt with in the validate_bandwidth() function:

#' Validate bandwidth parameters
#'
#' This function validates function arguments related to bandwidth.
#'
#' @param bandwidth \code{numeric} value specifying the bandwidth to be used in
#' calculating kernel density estimates.

This function will therefore need the cell size as an argument, so this will need to be added to the functions that call validate_bandwidth().

@mpjashby
Copy link
Owner Author

This is harder than it initially seems, because users can supply arbitrary polygons for the grid for which KDE values are calculated. This means that the 'cell' size has to be extracted from the grid. If this is done by finding the typical nearest-neighbour distance, it is quite slow and therefore the check should probably be made optional.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request low priority
Projects
None yet
Development

No branches or pull requests

1 participant