[Biomod-commits] Psuedo-absence: PA.nb.rep = 0, and Raster as Factor

Damien Georges damien.georges2 at gmail.com
Tue Feb 12 17:11:50 CET 2013


Dear Leon,

If you give to biomod2 some input rasters defined as factor, they will 
be handled as factors.

Here an example with biomod2 dataset:

### INPUT ###
library(biomod2)
# 0. Load data & Selecting Data
# species occurances
species_occ <- 
read.csv(system.file("external/species/species_occ.csv",package="biomod2"))

# we consider only presences of MyocastorCoypus species
myRespName <- 'MyocastorCoypus'
myRespCoord <- 
species_occ[which(!is.na(species_occ[,myRespName])),c('x','y')]
myResp <- as.numeric(na.omit(species_occ[,myRespName]))

# Environemental variables extracted from BIOCLIM (bio_3, bio_4, bio_7, 
bio_11 & bio_12)
myExpl = 
raster::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"))

# transform the first layer into a categorial variable
myExpl[[1]] <- as.factor(round(myExpl[[1]]/10))
is.factor(myExpl)

myBiomodData <- BIOMOD_FormatingData(resp.var = myResp,
                                      expl.var = myExpl,
                                      resp.xy = myRespCoord,
                                      resp.name = 'myocastorXXX',
                                      PA.nb.rep = 3,
                                      PA.nb.absences = 200,
                                      PA.strategy = 'random')

myBiomodData

### OUTPUT ###


-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 
'BIOMOD.formated.data.PA' 
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

sp.name =  myocastorXXX

      59 presences,  0 true absences and  540 undifined points in dataset


      5 explanatory variables

      layer         bio_4             bio_7 bio_11             bio_12
  2      :170   Min.   :  103.2   Min.   : 54.38   Min. :-447.507   
Min.   :   0.642
  5      :113   1st Qu.: 2761.2   1st Qu.:187.52   1st Qu.:-175.966   
1st Qu.: 285.538
  3      : 84   Median : 6098.6   Median :299.11   Median : 42.438   
Median : 559.830
  4      : 56   Mean   : 7125.9   Mean   :303.07   Mean   : 2.677   
Mean   : 846.659
  6      : 54   3rd Qu.:11414.5   3rd Qu.:413.87   3rd Qu.: 183.694   
3rd Qu.:1187.911
  7      : 47   Max.   :22261.0   Max.   :713.79   Max.   : 283.000   
Max.   :5132.600
  (Other): 75


  3 Pseudo Absences dataset available ( PA1 PA2 PA3 ) with  200 absences 
in each (true abs + pseudo abs)

Here the first variable is considered a factor.

Best,

Damien.

On 12/02/2013 15:02, Wilfried Thuiller wrote:
> Dear Leon,
>
>> I have a question regarding pseudo-absence selection: Firstly, my data-set consists species presence for 238 bee species in the Netherlands. I have this data in a single table arranged as requested by biomod2.
>> Am I correct in understanding that if I set PA.nb.rep = 0, biomod2 will then take as pseudo absences only the locations where my focus species is not present but other bee species have been collected?
> Yes, as soon as they are coded in 1 and 0.
>
>> Also, I have my explanatory variables in Raster format, one of which is a categorical variable (Levels: 10,20,21,30,40,50,60,70,80,98,99):
> I will let Damien answers to that one coz I am usually not playing with categorical rasters.
>   
> However, if I may give my two cents on your analysis, I was wondering how many variables to you have? Having a factor variable with 11 levels is equivalent to have 10 variables. If you have other variables, you may go into troubles for some models. GAM for instance is not made for running over lots of variables.
>
> Cheers
> Wilfried
>
>
>
>
>
>> If I define it as.factor, will biomod then recognize it as such?
>>
>> ##Define raster as factor
>> soilF<-as.factor(raster("soil.img"))
>>
>> Thanks for your help,
>> Leon
>>
>> _______________________________________________
>> Biomod-commits mailing list
>> Biomod-commits at lists.r-forge.r-project.org
>> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/biomod-commits
> --------------------------
> Dr. Wilfried Thuiller
> Laboratoire d'Ecologie Alpine, UMR CNRS 5553
> Université Joseph Fourier
> BP53, 38041 Grenoble cedex 9, France
> tel: +33 (0)4 76 51 44 97
> fax: +33 (0)4 76 51 42 79
>
> Email: wilfried.thuiller at ujf-grenoble.fr
> Personal website: http://www.will.chez-alice.fr
> Team website: http://www-leca.ujf-grenoble.fr/equipes/emabio.htm
>
> ERC Starting Grant TEEMBIO project: http://www.will.chez-alice.fr/Research.html
> FP6 European EcoChange project: http://www.ecochange-project.eu
>
>
>
>
>
>
>
> _______________________________________________
> Biomod-commits mailing list
> Biomod-commits at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/biomod-commits



More information about the Biomod-commits mailing list