SCM

Forum: biomod2 package is now available !

Posted by: damien georges
Date: 2012-07-26 13:56
Summary: biomod2 package is now available !
Project: BioMod

Content:

Dear BIOMOD-users,

You were eagerly waiting for it, and we are happy to say that the new version of BIOMOD called biomod2 is now online on R-Forge.

Although we kept the same modelling philosophy than the former version (which we will still maintain for a while), we have made crucial changes. biomod2 is now fully object-oriented and made for running on a single species only (see vignette MultiSpeciesModelling for multi-species modelling at once). For advanced BIOMOD users, the new functions might be a bit disturbing at the beginning. Then, you will see that this new version is much more advanced and practical than the former ones. Among the novelties, the addition of MAXENT in the modelling techniques, a large range of evaluation metrics, a more refined definition of ensemble modelling and ensemble forecasting, the possibility to give presence-only data and environmental rasters to biomod2 and let it extract pseudo-absence data directly.

We have created several vignettes for you to get use to this new version and a figure explaining the different ways of giving data to BIOMOD.

Please bear in mind that R-Forge is a development platform, it means that this new package would experience repeated updating the next couple of weeks (correcting bugs, adding documentation, adding functionalities) so think about updating the package before each new study you will do.

Last but not least, all comments are welcome! If you find a bug, if you think some documentation points are unclear, if you think about new functionalities that may be useful, just let us know ASAP.

We count on you to help finalizing this new version to a very nice tool. We will then release it to CRAN by the end of July. Please remember to add your code, R-version, OS and BIOMOD-version every time you report a bug or a mistake in the vignette or help files.

Hoping you will enjoy this new version of BIOMOD.

With our best wishes,

Damien & Wilfried

Latest News

biomod2 is now devel on github

damien georges - 2020-03-02 17:08 -

biomod2 package is now available !

damien georges - 2012-07-26 13:56 -
...

 

Monitor Forum | Start New Thread Start New Thread
RE: ERROR using evaluation data [ Reply ]
By: Rosa Gleave on 2021-11-04 15:06
[forum:49193]
Dear Damien,

You say that pseudoabsences are not supported for evaluation data: my dataset has no true absences, so I am relying on my pseudoabsences.

If I want to evaluate my models, should I re-code my pseudoabsences as 0 (my pseudoabsences are all user defined) or will that violate any model assumptions?

Thanks,

Rosa

RE: ERROR using evaluation data [ Reply ]
By: Ricardo Alvarez on 2018-05-04 04:06
[forum:45911]
Hi Damien,
you're right, it's working withouth NA in the dataframe, Thank you very much for your support

Ricardo

RE: ERROR using evaluation data [ Reply ]
By: Ricardo Alvarez on 2018-05-03 12:42
[forum:45910]
Hi Damien,
If I understand, you mean that have I to run the code in each species? I guess that is the only way to discard all the NA of my dataset.
Second, I assume that this option: na.rm = TRUE in the FormattingData option should avoid my issue (or not??)

cheers

RE: ERROR using evaluation data [ Reply ]
By: damien georges on 2018-05-03 08:55
[forum:45909]
Ok, it think that the NAs in the evaluation response variable cause the issue. (pseudo absences samplingnot supported for evaluation data)

Please remove all points but the 54 presences and 54 absences in your 3 evaluation datasets (MyResptest, myRespCoordTest, MyExplatest) and retry to model your species.

Any amelioration?

RE: ERROR using evaluation data [ Reply ]
By: Ricardo Alvarez on 2018-05-03 08:45
[forum:45908]
Hi Damien,
tHere is you require, hopefully will be useful:

Does it work when you switch MAXENT.Phillips out?
No, I get the same errot, but the following warning does not appear again =
In addition: Warning message:
running command 'java' had status 1

Could you please print the print of myBiomodDataT for one of the failing
species?
I forgot mentioned that does not appear the number of environmental points in the evaluation dataset, why?
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 'BIOMOD.formated.data.PA' -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

sp.name = ALBB

125 presences, 125 true absences and 6404 undifined points in dataset


6 explanatory variables

DPT SST SAL TDPT TSLP LAND
Min. : 22 Min. : 5.10 Min. : 5.20 Min. : 0.00 Min. : 0.000 Min. : 2.0
1st Qu.:1375 1st Qu.:19.50 1st Qu.:33.57 1st Qu.: 1.00 1st Qu.: 1.500 1st Qu.: 59.0
Median :3138 Median :22.60 Median :34.72 Median : 22.00 Median : 3.200 Median : 209.0
Mean :2765 Mean :22.42 Mean :34.24 Mean : 26.17 Mean : 3.703 Mean : 320.1
3rd Qu.:4100 3rd Qu.:26.40 3rd Qu.:35.11 3rd Qu.: 37.00 3rd Qu.: 5.600 3rd Qu.: 435.0
Max. :6352 Max. :30.60 Max. :36.24 Max. :155.00 Max. :13.000 Max. :1646.0


Evaluation data :

54 presences, 54 true absences and 0 undifined points in dataset



DPT SST SAL TDPT TSLP LAND
Min. : 40 Min. : 5.10 Min. : 5.20 Min. : 0.00 Min. : 0.000 Min. : 2.0
1st Qu.:1500 1st Qu.:19.50 1st Qu.:33.70 1st Qu.: 1.00 1st Qu.: 1.500 1st Qu.: 65.0
Median :3184 Median :22.50 Median :34.75 Median : 22.00 Median : 3.100 Median : 204.0
Mean :2824 Mean :22.42 Mean :34.29 Mean : 25.94 Mean : 3.661 Mean : 321.4
3rd Qu.:4107 3rd Qu.:26.30 3rd Qu.:35.15 3rd Qu.: 37.00 3rd Qu.: 5.500 3rd Qu.: 433.0
Max. :6352 Max. :30.60 Max. :36.24 Max. :155.00 Max. :13.000 Max. :1628.0


5 Pseudo Absences dataset available ( PA1 PA2 PA3 PA4 PA5 ) with 1000 absences in each (true abs + pseudo abs)

-=-=-=-
table(MyResptest)
MyResptest
0 1
54 54

length(MyResptest),
2848

summary(MyExplatest)
bject of class SpatialPointsDataFrame
Coordinates:
min max
X -4341818 -794942.6
Y -2577807 4584206.2
Is projected: NA
proj4string : [NA]
Number of points: 2848
Data attributes:
DPT SST SAL TDPT TSLP LAND
Min. : 40 Min. : 5.10 Min. : 5.20 Min. : 0.00 Min. : 0.000 Min. : 2.0
1st Qu.:1500 1st Qu.:19.50 1st Qu.:33.70 1st Qu.: 1.00 1st Qu.: 1.500 1st Qu.: 65.0
Median :3184 Median :22.50 Median :34.75 Median : 22.00 Median : 3.100 Median : 204.0
Mean :2824 Mean :22.42 Mean :34.29 Mean : 25.94 Mean : 3.661 Mean : 321.4
3rd Qu.:4107 3rd Qu.:26.30 3rd Qu.:35.15 3rd Qu.: 37.00 3rd Qu.: 5.500 3rd Qu.: 433.0
Max. :6352 Max. :30.60 Max. :36.24 Max. :155.00 Max. :13.000 Max. :1628.0

str(MyExplatest)
Formal class 'SpatialPointsDataFrame' [package "sp"] with 5 slots
..@ data :'data.frame': 2848 obs. of 6 variables:
.. ..$ DPT : int [1:2848] 200 500 125 70 125 125 230 650 40 4000 ...
.. ..$ SST : num [1:2848] 8 11.4 12.3 11.8 12.2 12.1 12.5 21.3 28.3 23.9 ...
.. ..$ SAL : num [1:2848] 30.4 32.1 33.3 33.3 33.3 ...
.. ..$ TDPT: int [1:2848] 0 0 0 0 0 0 0 0 50 60 ...
.. ..$ TSLP: num [1:2848] 0 0 0 0 0 0 0 0 11 6 ...
.. ..$ LAND: int [1:2848] 15 56 26 18 20 20 20 126 10 296 ...
..@ coords.nrs : num(0)
..@ coords : num [1:2848, 1:2] -794943 -1235908 -1182091 -1178782 -1174599 ...
.. ..- attr(*, "dimnames")=List of 2
.. .. ..$ : NULL
.. .. ..$ : chr [1:2] "X" "Y"
..@ bbox : num [1:2, 1:2] -4341818 -2577807 -794943 4584206
.. ..- attr(*, "dimnames")=List of 2
.. .. ..$ : chr [1:2] "X" "Y"
.. .. ..$ : chr [1:2] "min" "max"
..@ proj4string:Formal class 'CRS' [package "sp"] with 1 slot
.. .. ..@ projargs: chr NA

summary(myRespCoordTest)
X Y
Min. :-4341818 Min. :-2577807
1st Qu.:-3113147 1st Qu.: 1228868
Median :-2393614 Median : 2221016
Mean :-2398454 Mean : 1957342
3rd Qu.:-1611098 3rd Qu.: 3018510
Max. : -794943 Max. : 4584206

str(myRespCoordTest)
'data.frame': 2848 obs. of 2 variables:
$ X: num -794943 -1235908 -1182091 -1178782 -1174599 ...
$ Y: num -2510274 -1608730 -1201116 -1184050 -1150161 ...
>

RE: ERROR using evaluation data [ Reply ]
By: damien georges on 2018-05-03 07:48
[forum:45907]
Thanks,

Does it work when you switch MAXENT.Phillips out?

I suspect that the trouble comes from testing points that do not have all the environmental values defined..

Could you please print the print of myBiomodDataT for one of the failing species?
I am also interested in:

table(MyResptest)
length(MyResptest),


summary(MyExplatest)
str(MyExplatest)


summary(myRespCoordTest)
str(myRespCoordTest)

Best,
Damien

RE: ERROR using evaluation data [ Reply ]
By: Ricardo Alvarez on 2018-05-03 07:26
[forum:45906]
Hi Damien,
Thank you very much in advance
This is the error that appears when the code is run:

ALBB modelingtotal...
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ALBB Data Formating
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

! NAs have been automaticly removed from Evaluation data
> Pseudo Absences Selection checkings...
> random pseudo absences selection
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Done
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


Loading required library...

Checking Models arguments...

Creating suitable Workdir...
Error in data.frame(..., check.names = FALSE) :
arguments imply differing number of rows: 108, 2848
In addition: Warning message:
running command 'java' had status 1
>

THIS IS MY PIECE OF CODE:

# define the species of interest

sp.names <- c("ALBB", "BOMA", "GUST", "PETH", "PHRE", "PTDE", "PTGA", "PTJF", "PTSJ", "SHPF", "SHSO", "STEL",
"STGA", "STHA", "STHO", "STLE", "STMA", "STWF", "STWI")


#######################################################################

myExplaT <- SpatialPointsDataFrame(myRespCoord, train_expla)
MyExplatest <- SpatialPointsDataFrame(myRespCoordTest, test_expla)

##############################ADDITIONAL STEP##
## THIS STEP IS NECESSARY FOR BIOMOD_projetion function
df.myexplaT <- as.data.frame(myExplaT)
df.myexplaT <- dplyr::select(df.myexplaT, -X, -Y)






######################################################################
# loop on species == applying the same functions to each species
for(sp.n in sp.names){
myRespNameT = sp.n
cat('\n',myRespNameT,'modelingtotal...')


### definition of data
## i.e keep only the column of our species
myResp <- as.numeric(data1[,myRespNameT])
MyResptest <- as.numeric(data2[,myRespNameT])


myRespCoord = data1[c('X','Y')]
myRespCoordTest = data2[c('X', 'Y')]



### Initialisation
myBiomodDataT <- BIOMOD_FormatingData(resp.var = myResp,
expl.var = myExplaT,
resp.xy = myRespCoord,
resp.name = myRespNameT,
eval.resp.var = MyResptest,
eval.expl.var= MyExplatest,
eval.resp.xy= myRespCoordTest,
PA.nb.rep = 5, ##one set of pseudo absences
PA.nb.absences = 2000, ##number of n per each repetition
PA.strategy = 'random',
PA.dist.min = 0,
PA.dist.max = NULL,
PA.sre.quant = 0.025,
PA.table = NULL,
na.rm = TRUE)
### Options definition
myBiomodOption <- BIOMOD_ModelingOptions( MAXENT.Phillips = list( path_to_maxent.jar = ("C:/Users/z3366177/Desktop/"),
maximumiterations = 5000,
visible = FALSE,
linear = TRUE,
quadratic = TRUE,
roduct = TRUE,
threshold = TRUE,
hinge = TRUE,
lq2lqptthreshold = 40,
l2lqthreshold = 10,
hingethreshold = 15,
beta_threshold = -1,
beta_categorical = -1,
beta_lqp = -1,
beta_hinge = -1,
defaultprevalence= 0.5))
### Modelling
myBiomodModelOutT <- BIOMOD_Modeling(myBiomodDataT,
models = c('GLM', 'GBM','GAM',
'RF','MAXENT.Phillips'), #Oppel et al 2012 seabirds
models.options = myBiomodOption,
NbRunEval=10,
DataSplit=70, ##DATA USED TO CALIBRATE THE MODELS, THE REMAINING PART WILL VE USED FOR TESTING
Prevalence=NULL, ##allows to give more or less wight to observations.
VarImport=10,
models.eval.meth = c('TSS','ROC'),
SaveObj = TRUE,
rescal.all.models = FALSE,
do.full.models = FALSE,
modeling.id = paste(myRespNameT,"SeabirdsTotal", sep=""))


########################################################### ### Building ensemble-models
myBiomodEMT <- BIOMOD_EnsembleModeling( modeling.output = myBiomodModelOutT,
chosen.models = 'all',
em.by = 'PA_dataset+repet',
eval.metric = c('TSS','ROC'),
eval.metric.quality.threshold = 0.75, #c(0.7, 0.7),
models.eval.meth = c('TSS','ROC'),
prob.mean = TRUE,
prob.cv = FALSE,
prob.ci = FALSE,
prob.ci.alpha = 0.05,
prob.median = FALSE,
committee.averaging = FALSE,
prob.mean.weight = TRUE,
prob.mean.weight.decay = 'proportional' )



myBiomodProj_T <- BIOMOD_Projection(
modeling.output = myBiomodModelOutT,
new.env = df.myexplaT,
proj.name = 'Seabirds_Total_Proj',
selected.models = 'all',
binary.meth = 'ROC',
build.clamping.mask = FALSE) #Damien recommend this function
#compress = 'xz',
#clamping.mask = F)
#output.format = '.grd')
### Make ensemble-models projections on current variable



myBiomodEF_T <- BIOMOD_EnsembleForecasting(
projection.output = myBiomodProj_T,
EM.output = myBiomodEMT)


}



RE: ERROR using evaluation data [ Reply ]
By: damien georges on 2018-05-02 08:10
[forum:45905]
Dear Ricardo,

Could you please paste here the code you are using and loacate when this error shows up?

Thanks,
Damien

ERROR using evaluation data [ Reply ]
By: Ricardo Alvarez on 2018-04-30 01:12
[forum:45904]
Hi everyone
I get a weird problem using calibration/evaluation data. I've split my dataset in dataframe of 10 spp as it is recommended in the BIOMOD2 package. However, I cannot run the modelling function because appear this error in the evaluation section:
Error in data.frame(..., check.names = FALSE) :
arguments imply differing number of rows: 108, 2848
In addition: Warning message:
running command 'java' had status 1

I understand that those values 108, 2848 correspond to 54 presence, 54 absence and 2848 rows of environmental variables for my first species in my evaluation dataset. This error does not appear when I run this function without evaluation dataset and works perfectly. Any idea how to fix this error? thank you very much in advance

Ricardo

Thanks to:
Vienna University of Economics and Business Powered By FusionForge