Skip to content

Commit

Permalink
Correcting a minor bug in bandwidth selection
Browse files Browse the repository at this point in the history
  • Loading branch information
JeremyGelb committed Nov 2, 2023
1 parent 2fb784d commit 66cb380
Show file tree
Hide file tree
Showing 66 changed files with 45 additions and 10,974 deletions.
17 changes: 0 additions & 17 deletions .Rbuildignore.bak

This file was deleted.

64 changes: 0 additions & 64 deletions DESCRIPTION.bak

This file was deleted.

7 changes: 6 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@ This is an important release!
* It is now possible to do bandwidth selection with adaptive bandwidths
* One can also set local bandwidths manually for bandwidth selection

## Changes in function
## Changes in functions

* for all the function where the parameters *bw_range* and *bw_step* were used, they were replaced by a single argument *bws*. It gives more flexibility to the user.

## corrected bugs

When using ESC-NKDE with bandwidths selection, negative density values could be obtained (with a small parameter of depth). It led to NAN values in LOO score. They are now treated like zeros.

# spNetwork 0.4.3.7

This is only a maintenance release. A bug in CRAN caused by multiprocessing in example caused the rejection of hte package.
Expand Down
8 changes: 4 additions & 4 deletions R/bandwidth_selection_cv_sf.R
Original file line number Diff line number Diff line change
Expand Up @@ -435,10 +435,10 @@ bw_cv_likelihood_calc <- function(bws = NULL,

# and we can calculate now the scores
if(zero_strat == "min_double"){
all_loo_scores <- ifelse(all_loo_scores == 0, .Machine$double.xmin, all_loo_scores)
all_loo_scores <- ifelse(all_loo_scores <= 0, .Machine$double.xmin, all_loo_scores)
cv_scores <- colSums(log(all_loo_scores)) / nrow(all_loo_scores)
}else{
binary_mat <- all_loo_scores == 0
binary_mat <- all_loo_scores <= 0
all_loo_scores <- ifelse(binary_mat, 1, all_loo_scores)
cv_scores <- colSums(log(all_loo_scores)) / colSums(binary_mat == FALSE)
}
Expand Down Expand Up @@ -692,10 +692,10 @@ bw_cv_likelihood_calc.mc <- function(bws, lines, events, w, kernel_name, method,

# and we can calculate now the scores
if(zero_strat == "min_double"){
all_loo_scores <- ifelse(all_loo_scores == 0, .Machine$double.xmin, all_loo_scores)
all_loo_scores <- ifelse(all_loo_scores <= 0, .Machine$double.xmin, all_loo_scores)
cv_scores <- colSums(log(all_loo_scores)) / nrow(all_loo_scores)
}else{
binary_mat <- all_loo_scores == 0
binary_mat <- all_loo_scores <= 0
all_loo_scores <- ifelse(binary_mat, 1, all_loo_scores)
cv_scores <- colSums(log(all_loo_scores)) / colSums(binary_mat == FALSE)
}
Expand Down
Loading

0 comments on commit 66cb380

Please sign in to comment.