From 32dc551004340dcb71c4bf3a42a81517573947f5 Mon Sep 17 00:00:00 2001 From: Adrian Baddeley Date: Fri, 6 Sep 2024 15:50:18 +0800 Subject: [PATCH] Change default in bw.ppl --- DESCRIPTION | 4 ++-- NEWS | 11 +++++++++++ R/bw.ppl.R | 11 ++++++++--- inst/doc/packagesizes.txt | 2 +- inst/info/packagesizes.txt | 2 +- man/bw.ppl.Rd | 8 ++++---- 6 files changed, 27 insertions(+), 11 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 05bdcf8..f1edcc2 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: spatstat.explore -Version: 3.3-2 -Date: 2024-08-20 +Version: 3.3-2.001 +Date: 2024-09-06 Title: Exploratory Data Analysis for the 'spatstat' Family Authors@R: c(person("Adrian", "Baddeley", role = c("aut", "cre", "cph"), diff --git a/NEWS b/NEWS index 01bf379..a59f1bb 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,15 @@ + CHANGES IN spatstat.explore VERSION 3.3-2.001 + +OVERVIEW + + o Tweaks to bandwidth selection. + +SIGNIFICANT USER-VISIBLE CHANGES + + o bw.ppl + Argument 'shortcut' now defaults to TRUE. + CHANGES IN spatstat.explore VERSION 3.3-2 OVERVIEW diff --git a/R/bw.ppl.R b/R/bw.ppl.R index 8a2863e..b4d4ffa 100644 --- a/R/bw.ppl.R +++ b/R/bw.ppl.R @@ -3,11 +3,11 @@ #' #' Likelihood cross-validation for kernel smoother of point pattern #' -#' $Revision: 1.15 $ $Date: 2024/06/08 23:59:34 $ +#' $Revision: 1.17 $ $Date: 2024/09/06 07:09:13 $ #' bw.ppl <- function(X, ..., srange=NULL, ns=16, sigma=NULL, varcov1=NULL, - weights=NULL, shortcut=FALSE, warn=TRUE) { + weights=NULL, shortcut=TRUE, warn=TRUE) { stopifnot(is.ppp(X)) if(!is.null(varcov1)) check.nmatrix(varcov1, 2, things="spatial dimensions", mname="varcov1") @@ -44,6 +44,7 @@ bw.ppl <- function(X, ..., srange=NULL, ns=16, sigma=NULL, varcov1=NULL, cv[i] <- sum(log(lamx)) } } else { + IntLam <- numeric(ns) for(i in 1:ns) { if(is.null(varcov1)) { si <- sigma[i] @@ -57,7 +58,9 @@ bw.ppl <- function(X, ..., srange=NULL, ns=16, sigma=NULL, varcov1=NULL, weights=weights, ...) lam <- density(X, sigma=si, varcov=vi, weights=weights, ...) - cv[i] <- sum(log(lamx)) - integral.im(lam) + mu <- integral.im(lam) + cv[i] <- sum(log(lamx)) - mu + IntLam[i] <- mu } } result <- bw.optim(cv, sigma, iopt=which.max(cv), @@ -68,6 +71,8 @@ bw.ppl <- function(X, ..., srange=NULL, ns=16, sigma=NULL, varcov1=NULL, hargnames="srange", unitname=if(is.null(varcov1)) unitname(X) else NULL, template=varcov1, exponent=2) + if(!shortcut) + attr(result, "info") <- list(IntegralLambda=IntLam) return(result) } diff --git a/inst/doc/packagesizes.txt b/inst/doc/packagesizes.txt index b9f7f30..fdf0e3c 100755 --- a/inst/doc/packagesizes.txt +++ b/inst/doc/packagesizes.txt @@ -10,5 +10,5 @@ date version nhelpfiles nobjects ndatasets Rlines srclines "2024-01-31" "3.2-6" 241 535 0 32147 6365 "2024-03-21" "3.2-7" 241 535 0 32149 6365 "2024-07-09" "3.3-1" 230 517 0 31571 6365 - "2024-08-20" "3.3-2" 230 517 0 31571 6364 +"2024-09-06" "3.3-2.001" 230 517 0 31576 6364 diff --git a/inst/info/packagesizes.txt b/inst/info/packagesizes.txt index b9f7f30..fdf0e3c 100755 --- a/inst/info/packagesizes.txt +++ b/inst/info/packagesizes.txt @@ -10,5 +10,5 @@ date version nhelpfiles nobjects ndatasets Rlines srclines "2024-01-31" "3.2-6" 241 535 0 32147 6365 "2024-03-21" "3.2-7" 241 535 0 32149 6365 "2024-07-09" "3.3-1" 230 517 0 31571 6365 - "2024-08-20" "3.3-2" 230 517 0 31571 6364 +"2024-09-06" "3.3-2.001" 230 517 0 31576 6364 diff --git a/man/bw.ppl.Rd b/man/bw.ppl.Rd index 67f665f..c752258 100644 --- a/man/bw.ppl.Rd +++ b/man/bw.ppl.Rd @@ -9,7 +9,7 @@ } \usage{ bw.ppl(X, \dots, srange=NULL, ns=16, sigma=NULL, varcov1=NULL, - weights=NULL, shortcut=FALSE, warn=TRUE) + weights=NULL, shortcut=TRUE, warn=TRUE) } \arguments{ \item{X}{ @@ -81,9 +81,9 @@ which can be plotted to show the (rescaled) mean-square error as a function of \code{sigma}. - If \code{shortcut=TRUE}, the computation is accelerated by + If \code{shortcut=TRUE} (the default), the computation is accelerated by omitting the integral term in the equation above. This is valid - because the integral is approximately constant. + because the integral is approximately constant. } \section{Anisotropic Smoothing}{ Anisotropic kernel smoothing is available in \code{\link{density.ppp}} using @@ -118,7 +118,7 @@ } \testonly{ b1 <- bw.ppl(redwood, srange=c(0.03, 0.07), ns=2) - b2 <- bw.ppl(redwood, srange=c(0.03, 0.07), ns=2, shortcut=TRUE) + b2 <- bw.ppl(redwood, srange=c(0.03, 0.07), ns=2, shortcut=FALSE) } } \references{