2

I am having some troubles trying to produce a leverage plot for a point pattern model in spatstat. This is weird though, because yesterday it worked perfectly fine with the exact same model, and now it just doesn't.

I have a model with 3 covariates and a Geyer interaction, that runs correctly without producing any warning messages. However, when I try to produce the leverage plot I get first this warning:

Large quadrature scheme split into blocks to avoid memory size 
limits;6404 dummy points split into 8 blocks, the first 7 blocks 
containing 801 dummy points and the last block containing 797 dummy 
points 

And then this error:

Error in ppmInfluenceEngine(fit, what = what, ..., iScore = iScore, iHessian = iHessian,  :
number of items to replace is not a multiple of replacement length

I assume the problem has something to do with the fact that R tries to split the quadrature scheme, because before, when it didn't crash and I was able to produce a leverage plot with the exact same model, it didn't have to split it (or at least it din't let me know about it!)

library(spatstat)  
#generate a pattern
pattern <- rpoispp(1454)
summary(pattern)
#generate a covariate
cov1 <- rnoise(rgen = rnorm, dimyx=32, mean=2, sd=1, w = pattern$window)
cov2 <- rnoise(rgen = rnorm, dimyx=32, mean=1, sd=7, w = pattern$window)
cov3 <- rnoise(rgen = rnorm, dimyx=32, mean=5, sd=10, w = pattern$window)

#fit the model
fit <- ppm(pattern ~ cov1 + cov2 + cov3, Geyer(r = 0.01, s = 0.02))

leverage(fit) #this produces the warning and then the error

I am running R version 3.3.1 and spatstat version 1.46-1

2 Answers2

1

Thank you for reporting this. It is a bug in spatstat which we will try to fix as quickly as possible. If you have sufficient memory on your computer you can avoid the quadrature splitting by setting:

spatstat.options(maxmatrix = 2^26)

BEWARE: Your computer may hang for a while if you do this and you don't have enough memory. In some cases it may be hard to interrupt these calculations, so just to be safe I would save any open files etc. before trying this.

Ege Rubak
  • 4,347
  • 1
  • 10
  • 18
  • Glad to be of help! Any idea why this didn't need splitting before (with the exact same model) and then it did? I was not running any additional program in the computer that demanded a lot of memory... – Virginia Morera Pujol Sep 15 '16 at 17:25
  • No, that sounds strange. Did you update R or spatstat in between? Or did you manually set a value for `nd` which determines the number of dummy points in the quadrature scheme? The functions in spatstat are completely independent of the actual load on the computer, so it doesn't matter whether other things are running. The code simply checks whether the number of points in the quadrature scheme is less than the `maxmatrix` option and splits the calculations if there are more that `maxmatrix` points. – Ege Rubak Sep 15 '16 at 19:27
0

The error message

number of items to replace is not a multiple of replacement length

is indeed a bug in spatstat, related to the handling of sparse matrices. Thank you for bringing this to our attention.

The bug has been fixed in the current development version of spatstat, version 1.46-1.043 or later, available from the spatstat github repository.

The message

Large quadrature scheme split into blocks to avoid memory size limits;

is not a warning, only a message for your information.

Adrian Baddeley
  • 1,956
  • 1
  • 8
  • 7