Virginia Morera Pujol
Virginia Morera Pujol

Reputation: 477

Error plotting the Smoothed residual measure via diagnose.ppm of a Geyer model

I am trying to fit a Geyer model to a point pattern, and I manage to do so without trouble. However, when I want to check the diagnostic plots, I encounter a problem. If I give value "all" to the argument "which" it plots the 4 panels without problem, but when I ask just for the smoothed residual measure (which = "smooth" I get the following error:

Error in as.vector(rasterx.mask(W)) : error in evaluating the argument 'x' in selecting a method for function 'as.vector': Error in validate.mask(w) : w is not a binary mask

Reproducible code follows:

library(spatstat)
#generate a pattern
pattern <- rpoispp(300)
#generate a covariate
cov <- rnoise(rgen = rnorm, dimyx=32, mean=2, sd=1, w = pattern$window)

#fit the model
fit <- ppm(pattern ~ cov, Geyer(r = 0.01, s = 0.02))

#plot diagnostics
diag <- diagnose.ppm(fit, type = "pearson", which = "all") #this works
diag <- diagnose.ppm(fit, type = "pearson", which = "smooth") #this doesn't

I have tried with all the options allowed in type= with the same luck.

Any ideas what I might be doing wrong? (I'll asume it's me) or how can I get that smoothed residual any other way?

Upvotes: 0

Views: 96

Answers (2)

Adrian Baddeley
Adrian Baddeley

Reputation: 1984

Just confirming that this is a bug. It has been fixed in the next development version of spatstat (version 1.45-0.026). Thank you for bringing this to our attention.

Upvotes: 1

Ege Rubak
Ege Rubak

Reputation: 4507

This is probably a bug in plot.diagppm. I'm currently on Holiday, so I won't take a lot of action right now. I will report the bug on https://github.com/spatstat/spatstat/issues and hopefully Adrian will fix it within too long.

A workaround for now:

library(spatstat)
#generate a pattern
pattern <- rpoispp(300)
#generate a covariate
cov <- rnoise(rgen = rnorm, dimyx=32, mean=2, sd=1, w = pattern$window)

#fit the model
fit <- ppm(pattern ~ cov, Geyer(r = 0.01, s = 0.02))

#plot diagnostics
diag <- diagnose.ppm(fit, type = "pearson", which = "smooth", plot.it = FALSE)
s <- diag$smooth$Z
plot(s)

Upvotes: 1

Related Questions