Ricardo Adelino
Ricardo Adelino

Reputation: 165

predict function for MaxEnt(Software R)

I'm trying to use predict function for predict potencial occurrence points in space transfer. For this I using dismo package loaded with presence points in original space, 17 raster layers for original space and 17 raster layer for transfer space. All the rasters are identicals in extent, grid resolution and dimension, differing only in geographic coords. The original space and the transfer space are located in different continents and I have used kfold techinque for partitioning of my samples in training and testing.

I fit my maxent model with:

me<-maxent(predictor, training)

but, I can't project my fit model in the transfer space, returning:

pred<-predict(me,predictor2)
    Erro em .local(object, ...) : missing layers (or wrong names)

*predictors 1 and 2 are in raster stack file

*All the directories were correctly choosen, and the files is found into the directory.

*both, stack contain the same variable in for each geographic space

Upvotes: 0

Views: 1535

Answers (2)

matthewjwhittle
matthewjwhittle

Reputation: 1

The raster method for predict specifies that the 'newdata' raster (object) is the first argument and the model the second.

## S4 method for signature 'Raster'
predict(object, model, filename="", fun=predict, ext=NULL, 
const=NULL, index=1, na.rm=TRUE, inf.rm=FALSE, factors=NULL, 
format, datatype, overwrite=FALSE, progress='', ...)

Try:

pred<-predict(predictor2, me)

Upvotes: 0

Robert Hijmans
Robert Hijmans

Reputation: 47146

That points to 'wrong names' then. This could fix that

names(predictor2) <- names(predictor)

But do make sure that this is correct (that is, that the two RasterStack objects have the same layers in the same order), by inspecting

names(predictor2)
names(predictor)

Upvotes: 0

Related Questions