Virginia Morera Pujol Virginia Morera Pujol - 1 year ago 129
R Question

error in leverage function: number of items to replace is not a multiple of replacement length

I am having some troubles trying to produce a leverage plot for a point pattern model in

. 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

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!)

#generate a pattern
pattern <- rpoispp(1454)
#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

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download