Nico Tartini
Nico Tartini

Reputation: 11

Biomod2 generation of pseudo-absences

I have started working in species distribution and I'm not at ease on the subject yet. I'm using biomod2 package in R, with several rasters to apply to species with presence-only data. My aim it to generate a pseudoabsence model. I tried to follow tutorials but they're not usable for me (either not clear or relying on input data frames that cannot be accessed). I'll thus also accept suggestions for good tutorials.

I have, for now:

1) generated the explanatory model:

myExpl = stack(Raster_vaud_srad1,
    Raster_vaud_srad2,
    Raster_vaud_srad3,
    Raster_vaud_srad4,
    Raster_vaud_srad5,
    Raster_vaud_srad6,
    Raster_vaud_srad7,
    Raster_vaud_srad8,
    Raster_vaud_srad9,
    Raster_vaud_srad10,
    Raster_vaud_srad11,
    Raster_vaud_srad12,
    Raster_vaud_slope,
    Raster_vaud_topos,
    Raster_vaud_topo,
    Raster_vaud_aspval,
    Raster_vaud_GDD_mod,
    Raster_vaud_mind_mod,
    layers=NULL)

    plot(myExpl)

2) extracted all the geographic dataset coordinates

 species_presence<-read.table(file.choose(),sep=";",dec=".",h=T)

    Y<-sample(c(30000:60000),100,replace=F)
    Y<-sample(c(70000:250000),100,replace=F)
    coordinates<-dataframe(x,y)# with te real data i used this code: na.omit(unic(prova_aquilegia[,c(4,5)]))
    Presence<-c(rep(1,length(X)))
    SpecNames<-"Species"

3) created the pseudoabsences

myBiomodData <- BIOMOD_FormatingData(resp.var = Presence, expl.var =
myExpl, resp.xy = coordinates, resp.name = SpecNames, PA.nb.rep= 1,
PA.nb.absences = 13414,  PA.strategy="random", PA.dist.min=200) ## for
PA.nb.absence I used the number of points of the rasters

Here is the error I get on step 3:

Error in sample.int(length(x), size, replace, prob) :    invalid first argument In addition: Warning
messages: 1: In if (nbTrueAbs >= nb.points) { :   the condition has
length > 1 and only the first element will be used 2: In if ((nb.repet
== 0 | nb.points <= 0) & strategy != "user.defined") { :   the condition has length > 1 and only the first element will be used 3: In
if (nb.cells <= nb.points) { :   the condition has length > 1 and only
the first element will be used

I expected to have generated the pseudoabsences but I start to think I may missing some steps.

I'll appreciate any input.

Cross posted on: CrossValidated.

Upvotes: 1

Views: 710

Answers (1)

Jo&#227;o
Jo&#227;o

Reputation: 1

You can't produce pseudo-absence points with minimal/maximal distance using the factor ´random'. You must change random to disk in your script.

Upvotes: 0

Related Questions