Search code examples
rkernel-densityspatstat

Issue pasing arguments to kernel functions through `density.ppp`


I am currently working intensively with the density.ppp function, calling it with different kernel functions of my own design. For this, I need to pass some arguments through density.ppp to my kernel functions via the ... arglist.

There is one case in which this does not work, namely if I want to calculate at = "points" with edge correction.

In densitypointsengine it says

# evaluate edge correction weights at points 
  if(edge) {
    win <- x$window
    if(isgauss && is.null(varcov) && win$type == "rectangle") {
      # evaluate Gaussian probabilities directly
      xr <- win$xrange
      yr <- win$yrange
      xx <- x$x
      yy <- x$y
      xprob <-
        pnorm(xr[2L], mean=xx, sd=sigma) - pnorm(xr[1L], mean=xx, sd=sigma)
      yprob <-
        pnorm(yr[2L], mean=yy, sd=sigma) - pnorm(yr[1L], mean=yy, sd=sigma)
      edgeweight <- xprob * yprob
    } else {
      edg <- second.moment.calc(x, sigma=sigma,
                                kernel=kernel,
                                scalekernel=scalekernel,
                                what="edge", varcov=varcov)
      edgeweight <- safelookup(edg, x, warn=FALSE)
}

so here the call for second.moment.calc does not support additional parameters hidden in ....

I would like to know whether this might be a bug or if it is done this way on purpose.


Solution

  • This is a bug. There should be a ... in the call to second.moment.calc.

    It will be fixed in the development version of spatstat shortly.