Skip to content

Commit

Permalink
Change default in bw.ppl
Browse files Browse the repository at this point in the history
  • Loading branch information
baddstats committed Sep 6, 2024
1 parent 05c3e32 commit 32dc551
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 11 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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"),
Expand Down
11 changes: 11 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -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
Expand Down
11 changes: 8 additions & 3 deletions R/bw.ppl.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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]
Expand All @@ -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),
Expand All @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion inst/doc/packagesizes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion inst/info/packagesizes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 4 additions & 4 deletions man/bw.ppl.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -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}{
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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{
Expand Down

0 comments on commit 32dc551

Please sign in to comment.