0% found this document useful (0 votes)
8 views

Include Maxent Biomod2

This document provides a guide for setting up MAXENT to run within the biomod2 package in R, detailing the necessary Java installation for Windows, Linux, and Mac OS. It outlines the steps to download and configure the MAXENT software, including placing the maxent.jar file in the working directory. Additionally, it includes example R code for loading species data, defining modeling options, computing models, and projecting results.

Uploaded by

iminoli.dev
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Include Maxent Biomod2

This document provides a guide for setting up MAXENT to run within the biomod2 package in R, detailing the necessary Java installation for Windows, Linux, and Mac OS. It outlines the steps to download and configure the MAXENT software, including placing the maxent.jar file in the working directory. Additionally, it includes example R code for loading species data, defining modeling options, computing models, and projecting results.

Uploaded by

iminoli.dev
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

How to set up MAXENT to be run within biomod2

biomod2 version : 1.2.0


R version 2.15.2 (2012-10-26)

Damien Georges & Wilfried Thuiller

November 5, 2012

1
biomod2: include MAXENT CONTENTS

Contents
1 Introduction 3

2 Java software 3
2.1 Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.2 Linux and Mac OS . . . . . . . . . . . . . . . . . . . . . . . . 4

3 MAXENT software 4

4 A little test 5

2
biomod2: include MAXENT 2 JAVA SOFTWARE

1 Introduction
This vignette explain how to configure your computer to run MAXENT within
biomod2.

2 Java software
Given MAXENT is a java software, a Java interpreter needs to be installed on
your computer. Skip the following step if Java is already installed on your
machine. We consider here the three most usual OS (i.e. Windows, Linux
and Mac OS).

2.1 Windows
These instructions concern Windows 7, but should work with former XP
and Vista.

1. Download and install the latest version of the Java Platform, Standard
Edition Development Kit (http://www.oracle.com/technetwork/java/
javase/downloads/index.html).

NOTE 1 :
the installation directory for later is probably something like C:\ProgramFiles\
Java\jdkx.x.x_xx\bin.

NOTE 2 :
Replace the x.x.x xx by jdk version

2. Make sure that Windows can find the Java interpreter:

• Select Start → Computer → System Properties → Advanced sys-


tem settings → Environment Variables → System variables →
PATH.

NOTE 3 :
In Vista:
select Start → My Computer → Properties → Advanced → En-
vironment Variables → System variables → PATH

NOTE 4 :
In Windows XP:

3
biomod2: include MAXENT 3 MAXENT SOFTWARE

Select Start → Control Panel → System → Advanced → Envi-


ronment Variables → System variables → PATH

• Prepends C:\ProgramFiles\Java\jdkx.x.x_xx\bin; to the be-


ginning of the PATH variable.
• Click OK three times

3. make a test :

• Launch the command prompt via : All Programs → Accessories


→ Command Prompt. (If you already had a command prompt
window open, close it and launch a new one.)
• Check that Java is installed, type the command prompt: java
-version. If no error message returned, you can pass to next
step.

2.2 Linux and Mac OS


In most of case, java is already install on your computer. To check it, open
a terminal and simply type java -version. If no error message returned go
to next step else follow instructions given to install Java Platform, Standard
Edition Development Kit.

3 MAXENT software
To run MAXENT you need a copy of the maxent.jar file in your working
directory (where R and biomod2 will be run).

1. download MAXENT software at http://www.cs.princeton.edu/~schapire/


maxent/

2. uncompress the downloaded file

3. put a copy maxent.jar file somewhere on your hard drive (in your
working directory by default).

NOTE 5 :
If you don’t put maxent.jar file in your working directory, you will have to
fill the path_to_maxent.jar MAXENT options argument with the link to
this file.

4
biomod2: include MAXENT 4 A LITTLE TEST

4 A little test
If you have followed the previous sections, you should be able to use MAXENT
as all other models in biomod2. Let’s try it with the biomod2 data.

R input
# load the library
library(biomod2)
# load our species raster
# we consider only the presences of Myocastor coypus species
myResp.ras <- raster( system.file(
"external/species/Myocastor_coypus.img",
package="biomod2") )
# extract the presences data

# the name
myRespName <- 'Myocastor'
# the XY coordinates of the presence
myRespXY <- xyFromCell(object=myResp.ras,
cell=which(myResp.ras[]>0))
# and the presence data
myResp <- extract(x=myResp.ras, y=myRespXY)
# load the environmental raster layers (could be .img, ArcGIS
# rasters or any supported format by the raster package)

# Environmental variables extracted from Worldclim (bio_3, bio_4,


# bio_7, bio_11 & bio_12)
myExpl = stack( system.file( "external/climat/current/bio3.grd",
package="biomod2"),
system.file( "external/climat/current/bio4.grd",
package="biomod2"),
system.file( "external/climat/current/bio7.grd",
package="biomod2"),
system.file( "external/climat/current/bio11.grd",
package="biomod2"),
system.file( "external/climat/current/bio12.grd",
package="biomod2"))
myBiomodData <- BIOMOD_FormatingData(resp.var = myResp,
expl.var = myExpl,
resp.xy = myRespXY,
resp.name = myRespName,
PA.nb.rep = 2,
PA.nb.absences = 200,
PA.strategy = 'random')
# 2. Defining MAXENT Mododelling options
myBiomodOption <- BIOMOD_ModelingOptions(
MAXENT = list( path_to_maxent.jar = getwd(),
maximumiterations = 200,
visible = FALSE,
linear = TRUE,

5
biomod2: include MAXENT 4 A LITTLE TEST

quadratic = TRUE,
product = TRUE,
threshold = TRUE,
hinge = TRUE,
lq2lqptthreshold = 80,
l2lqthreshold = 10,
hingethreshold = 15,
beta_threshold = -1,
beta_categorical = -1,
beta_lqp = -1,
beta_hinge = -1,
defaultprevalence = 0.5))
# 3. Computing the models
myBiomodModelOut <- BIOMOD_Modeling(
myBiomodData,
models = c('SRE','RF','MAXENT'),
models.options = myBiomodOption,
NbRunEval=1,
DataSplit=80,
Yweights=NULL,
VarImport=3,
models.eval.meth = c('TSS','ROC'),
SaveObj = TRUE,
rescal.all.models = TRUE)
# let's have a look at different models scores
getModelsEvaluations(myBiomodModelOut)
# 4. Project our models over studied area
myBiomomodProj <- BIOMOD_Projection(modeling.output = myBiomodModelOut,
new.env = myExpl,
proj.name = 'current',
xy.new.env = myRespCoord,
selected.models = 'all',
binary.meth = 'ROC',
filtered.meth = 'TSS',
compress = 'xz',
clamping.mask = T,
do.stack=T)
# make some plots sub-selected by str.grep argument
plot(myBiomomodProj, str.grep = 'MAXENT')

You might also like