0

I am new using r and the package biomod2. I have the problem that when i try to run the model MAXENT.Phillips by biomod 2 i get the next error:

Error in file(file, "rt") : no se puede abrir la conexión
Además: Warning message:
In file(file, "rt") :
  no fue posible abrir el archivo 'A.Bicornis/models/A.BicornisFirstModeling/A.Bicornis_AllData_RUN2_MAXENT.Phillips_outputs/A.Bicornis_AllData_RUN2_Pred_swd.csv': No such file or directory

I have update the package and still not working. When I run the code, I'll have the maxent window when I introduce the variables and points. Then I run it in the maxent window and get this error.

The code that I use:

predictor<-stack(Bio2,Bio3,Bio8,Bio10,Bio13,Bio14)
DataSpecies1 <-data.frame(workBiomod1,package="biomod2")
myRespName1 <-as.character('A.Bicornis')
colnames(DataSpecies1)[1]<-"A.Bicornis"
myResp1 <- as.data.frame(DataSpecies1[,myRespName1])
myRespXY1 <- DataSpecies1[,c("DECLONGITUDE","DECLATITUDE")]
myExpl1<-predictor

myBiomodData1 <- BIOMOD_FormatingData(resp.var = myResp1,
                                      expl.var = myExpl1,
                                      resp.xy = myRespXY1,
                                      resp.name = myRespName1)


myBiomodData1
plot(myBiomodData1)
myBiomodOption1 <- BIOMOD_ModelingOptions(
  RF=list(ntree=128),MAXENT.Phillips=list(path_to_maxent.jar="C:\\Users\\nikom\\Desktop\\Maxent\\maxent",
                                          memory_allocated=NULL, background_data_dir="D:\\TFM\\Especies\\",
                                          linear=FALSE,quadratic=FALSE,product=TRUE,
                                          threshold=TRUE,hinge=TRUE))
myBiomodModelOut1 <- BIOMOD_Modeling(
  myBiomodData1,
  models = c('RF','MAXENT.Phillips'),
  models.options = myBiomodOption1,
  NbRunEval=10,
  DataSplit=80,
  Prevalence=0.5,
  VarImport=0,
  models.eval.meth = c('TSS','ROC','ACCURACY'),
  SaveObj = TRUE,
  rescal.all.models = TRUE,
  do.full.models = FALSE,
  modeling.id = paste(myRespName1,"FirstModeling",sep=""))

myBiomodModelOut1
myBiomodModelEval1 <- get_evaluations(myBiomodModelOut1)
dimnames(myBiomodModelEval1)
myBiomodModelEval1["TSS","Testing.data","RF",,]
myBiomodModelEval1["ROC","Testing.data",,,]
get_variables_importance(myBiomodModelOut1)

myBiomodEM1 <- BIOMOD_EnsembleModeling(
  modeling.output = myBiomodModelOut1,
  chosen.models = 'all',
  em.by='all',
  eval.metric = c('TSS'),
  eval.metric.quality.threshold = c(0.7),
  prob.mean = T,
  prob.cv = T,
  prob.ci = T,
  prob.ci.alpha = 0.05,
  prob.median = T,
  committee.averaging = T,
  prob.mean.weight = T,
  prob.mean.weight.decay = 'proportional' )

workBiomod1 is composed by XY coordinates, values of 1 (presence) and 0 (ausence), and values in the corresponding variables. Meanwhile, random forest is working well.

Mark
  • 7,785
  • 2
  • 14
  • 34
  • Hi Niko. It seems that either, you don't haver permission or the path to the file is wrong. Please make sure you have write and read permissions in order to get this working. Plus, double check if you're referring to correct path. `getwd()` could help you with this – patL Nov 05 '20 at 15:33
  • Can you explain me a little bit about the permision? The path is the correct one, cause i have cheked it out before, getwd() [1] "D:/TFM/Especies", the directory where i have the data. The problen can be the csv that i am using? I am telling this cause i have created a new csv just for Maxent with the data of XY presence points – NikoMatanov Nov 05 '20 at 19:30
  • If you don't have permission to write you won't be able to use a function that is creating temporary directory (even though sometimes you won't even see it). Which are the packages are you using for this code? I can't try running it and see if it works for me – patL Nov 11 '20 at 15:26
  • Thank you, but finally it works. I think that was the directory. – NikoMatanov Nov 11 '20 at 20:11

0 Answers0