Luc
Luc

Reputation: 1

How to adress error message related to S4 object in R?

I'm with spatstat package in R.I'm working on species distribution models mainly on point process models.

My goal is to evaluate the predictive performance of point process models of Gibbs, Log-Gaussian Cox, and many more, point processes.

I've fitted Gibbs models to my data and when doing prediction

predict(f.ppm, window = W, covariates=present$bio4)

an error occurs

Error in covariates[covnames.needed] : objet de type 'S4' non indicable

which means that object of type 'S4' cannot be identified.

present yields:

class      : RasterStack 
dimensions : 694, 350, 242900, 5  (nrow, ncol, ncell, nlayers)
resolution : 1000, 1000  (x, y)
extent     : 248674.5, 598674.5, 683042.6, 1377043  (xmin, xmax, ymin, ymax)
crs        : +proj=utm +zone=31 +ellps=WGS84 +units=m +no_defs 
names      :       bio4,       llds,       mimq,        pet,         SV 
min values :   10.02888,    4.00000,   95.45561, 1293.52945,    0.00000 
max values :   25.00000,    8.00000,  222.91389, 2062.00000,    7.80565 

Upvotes: 0

Views: 147

Answers (1)

Adrian Baddeley
Adrian Baddeley

Reputation: 2973

Presumably your object f.ppm is a fitted model of class ppm. Then your code is invoking the predict method for this class, predict.ppm. The help file for predict.ppm states that the argument covariates should be "either a data frame, or a list of pixel images of class im". Your data present$bio4 does not conform to either of these formats. You will need to convert the data to the required format.

Upvotes: 1

Related Questions