Abel
Abel

Reputation: 51

Running Maxent in R

Sorry if this question has come up before but I would like to ask if anyone knows what goes into each of the arguments in maxent() from the dismo package? I have searched the various R forum sites and the R help page itself but I couldn't understand how to put in my arguments. I have a sample of my data frame for the predictor variables here

library(dismo)
system.file("java", package="dismo")

bio_14  bio_19  bio_3   bio_5   forest_cover
9       125     67      329     1
9       125     67      329     1
9       124     68      329     3
10      126     67      319     3

Each row is either a background or presence point. What I don't understand after that is what goes into the p and a arguments in the maxent() formula. Does the p argument contain x and y coordinates and the 3rd column indicating 1 (presence) and 0 (absence)? Or does column containing the 1s and 0s go into the a argument instead? forest_cover is a categorical variable.

DataM<-read.csv("Maxent dataset.csv", header=T)
DataM<-data.frame(DataM)
parg<-read.csv("maxent p arg.csv", header=T)
aarg<-read.csv("maxent a arg.csv", header=T)
DataM[,'forest_cover'] = as.factor(DataM[,'forest_cover'])

#p
x           y
328206.7075 1257255.387
328759.7075 1256632.385
323102.7012 1256404.391
323029.7117 1267187.402



#a
pb
1
1
1
0


#Final code
    maxent1<-maxent(x=DataM, p=parg, a=aarg, factors='forest_cover')

    Error in maxent(x = DataM, p = parg, a = aarg, factors = "forest_cover") : 
  unused arguments (x = DataM, p = parg, a = aarg, factors = "forest_cover")

Please do tell me if I should be moving some of the stuff around and if they are in the right data frames. Thanks in advance

Upvotes: 3

Views: 4607

Answers (2)

Simon
Simon

Reputation: 1111

I don't know if this will help but my code looks like the following. You can set your arguments as below. If you open maxent.jar and click the help button in the MaxEnt GUI, you will get a list of arguments. Simply type in the name of the argument and set its value and it should then work.

  `xx<-maxent(x=expl,p=spp.coords$garmani, args=c(
  'maximumbackground=10000',
  'defaultprevalence=1.00',
  'betamultiplier=0.5',
  'pictures=true',
  'randomtestpoints=30',
  'linear=true',
  'quadratic=true',
  'product=true',
  'threshold=true',
  'hinge=true',
  'threads=2',
  'responsecurves=false',
  'jackknife=false',
  'askoverwrite=false'
))`

EDIT: I should add that 'x' is my raster stack of covariates (in this case BioClim layers) and 'p' is simply a list containing xy coordinates (in that order) for my species.

Upvotes: 3

Abel
Abel

Reputation: 51

Ran the maxent in R in the following way

maxent(predictors, parg, aarg)

where

predictors: stack of environmental variables

parg: coordinates of presence localities (x and y coordinates in separate columns)

aarg: coordinates of background points (x and y coordinates in separate columns)

Upvotes: 1

Related Questions