[R-sig-Geo] Problem using trend covariates in predict.ppm (spatstat)

Rawlins, Barry G. bgr at bgs.ac.uk
Wed Mar 25 17:32:53 CET 2015


Dear list

I have been successfully forming spatial point pattern models using the function ppm and a series of covariates stored as im objects:

Example here in which I have a spatial point pattern object "CI_pipe_40_spp" and a covariate "cov_CI_len"

mod2<-ppm(CI_pipe40_spp, trend=~cov_CI_len, covariates=list(cov_CI_len)) # this works fine giving me a ppm model
summary(mod2)

Point process model
Fitting method: maximum likelihood (Berman-Turner approximation)
Model was fitted using glm()
Algorithm converged
Call:
ppm.ppp(Q = CI_pipe40_spp, trend = ~cov_CI_len, covariates = list(cov_CI_len))
Edge correction: "border"
        [border correction distance r = 0 ]

I then want to use the predict function I next write in the same workspace:
preds=predict.ppm(mod2,type="trend", window=mask40,ngrid=c(402,402),
                  covariates=list(cov_CI_len))

But I get the following error:
Error in mpl.get.covariates(covariates, list(x = xpredict, y = ypredict),  :
  Each entry in the list 'covariates' should be an image, a function, a window, a tessellation or a single number

But if I check the class of "cov_CI_len":
class(cov_CI_len)
[1] "im"


Which shows that this object is an image. Can someone suggest what is wrong here? The

The help says "If covariates is a list of images, then the names of the entries should correspond to the names of covariates in the model formula trend."
I think I have the code correct - can anyone help with this?

Best wishes, Barry

Dr Barry Rawlins
Soils Team Leader
British Geological Survey
Nottingham
NG12 5GG
Tel  01159363140
Mob 07884235473

www.soil-journal.net




  ________________________________
This message (and any attachments) is for the recipient ...{{dropped:9}}



More information about the R-sig-Geo mailing list