[Biomod-commits] Biomod-commits Digest, Vol 34, Issue 28

Wilfried Thuiller wilfried.thuiller at ujf-grenoble.fr
Tue Feb 28 22:57:27 CET 2012


Dear Andreas,

You made my day! Honestly, I had a good laugh tonight. I will not answer the last part of your email to avoid being rude. 
If you are not able to understand humor from people who tried to help you for free on their spare time, better to keep going outside of the R environment. 

Having say that, I downloaded the Maxent data and now that I had the exact code you used, I simply copy-pasted your code and run BIOMOD. I am sorry to say, it worked pretty well, and the Models folder was full of the models outputs, as the Pred folder was. 

See below the copy-paste from my console.

In summary, either your computer crashed, or went out of memory but there is nothing wrong about the output BIOMOD can deliver on this species, from the exact code you wrote. 


I want to remind you that besides the manuals, which are so badly written, you have the help files in R. I agree there are probably not the best self-explanatory you can find, but still if you follow them, you should be able to find your way, as many people have done before you. 

For instance, typing 

?Models

will guide you all the way for building models, analyzing the variable importance and the response curves. 

Same for other functions such as 
?Projections
?Ensemble.Forecasting
?Biomod.Turnover





###
setwd("/Wilfried/0000/Simulations/MISC/Maxent/tutorial-data")

bradypus<- read.csv("/Wilfried/0000/Simulations/MISC/Maxent/tutorial-data/swd/bradypus_swd.csv", header=TRUE)
background<- read.csv("/Wilfried/0000/Simulations/MISC/Maxent/tutorial-data/swd/background.csv", header=TRUE)
names(bradypus)[2]<-paste("x")
names(bradypus)[3]<-paste("y")
presence_absence<- matrix(nrow = (nrow(bradypus) + nrow(background)), ncol = 1)
for (i in 1:nrow(bradypus)) {presence_absence[i,1]<- 1}
for (i in (nrow(bradypus)+1):nrow(presence_absence)) {presence_absence[i,1]<- 0}
colnames(presence_absence)<- c("Sp1")
Sp.Env<- rbind(bradypus, background)
Sp.Env<- cbind(Sp.Env, presence_absence)
Sp.Env$ecoreg = as.factor(Sp.Env$ecoreg)
Resp.Var<- Sp.Env[,18]
Resp.Var<- as.data.frame(Resp.Var)
Expl.Var <- Sp.Env[,4:17]
LatLong<- Sp.Env[, 2:3]
head(Sp.Env, 10)
summary(Sp.Env)

library(BIOMOD)

Initial.State(Response = Resp.Var, Explanatory = Expl.Var)

Models(GLM = T, TypeGLM = "poly", Test = "AIC", GBM = T, No.trees = 2000, GAM = T,Spline = 3, CTA = T, CV.tree = 50, ANN = T, CV.ann = 2, SRE = T, quant=0.025, FDA = T, MARS = T, RF = T, NbRunEval = 1, DataSplit = 80, Yweights=NULL, Roc = T, Optimized.Threshold.Roc = T, Kappa = T, TSS=T, KeepPredIndependent = T, VarImport=0,NbRepPA=1, strategy="circles", coor=LatLong, distance=2, nb.absences=1000)


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

MARS model was shut down, it cannot run on factorial variables : ecoreg
SRE model was shut down, it cannot run on factorial variables : ecoreg

----------------------------------- 
Modelling summary 
----------------------------------- 
Number of species modelled : 		1
Resp.Var

numerical variables : 			cld6190_ann, dtr6190_ann, frs6190_ann, h_dem, pre6190_ann, pre6190_l10, pre6190_l1, pre6190_l4, pre6190_l7, tmn6190_ann, tmp6190_ann, tmx6190_ann, vap6190_ann
factorial variables : 			ecoreg

number of evaluation repetitions : 	1
number of pseudo-absences runs : 	1
models selected : 			ANN, CTA, GAM, GBM, GLM, FDA, RF
total number of model runs :  		14
----------------------------------- 


#####			 Resp.Var 			#####
#####		   pseudo-absence run 1        		#####
Model=Artificial Neural Network 
	 2 Fold Cross Validation + 3 Repetitions 
Calibration and evaluation phase: Nb of cross-validations:  1 
Model=Classification tree 
	 50 Fold Cross-Validation 
Model=GAM spline 
	 3  Degrees of smoothing 
Model=Generalised Boosting Regression 
	 2000 maximum different trees and lambda Fold Cross-Validation 
Model=GLM polynomial + quadratic	 Stepwise procedure using AIC criteria 
Model=Flexible Discriminant Analysis 
Model=Breiman and Cutler's random forests for classification and regression 

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

> list.files("Models/")
 [1] "rescaling_models"      "Resp.Var_ANN_PA1"      "Resp.Var_ANN_PA1_rep1" "Resp.Var_CTA_PA1"      "Resp.Var_CTA_PA1_rep1" "Resp.Var_FDA_PA1"     
 [7] "Resp.Var_FDA_PA1_rep1" "Resp.Var_GAM_PA1"      "Resp.Var_GAM_PA1_rep1" "Resp.Var_GBM_PA1"      "Resp.Var_GBM_PA1_rep1" "Resp.Var_GLM_PA1"     
[13] "Resp.Var_GLM_PA1_rep1" "Resp.Var_RF_PA1"       "Resp.Var_RF_PA1_rep1" 

> list.files("Pred/")
[1] "Pred_Resp.Var"


 



Le 28 févr. 2012 à 19:25, Andreas Soteriades a écrit :

> Hi Wilfried,
> 
> Here's my code:
> 
> library(BIOMOD)
> bradypus<- read.csv("bradypus_swd.csv", header=TRUE)
> background<- read.csv("background.csv", header=TRUE)
> names(bradypus)[2]<-paste("x")
> names(bradypus)[3]<-paste("y")
> presence_absence<- matrix(nrow = (nrow(bradypus) + nrow(background)), ncol = 1)
> for (i in 1:nrow(bradypus)) {presence_absence[i,1]<- 1}
> for (i in (nrow(bradypus)+1):nrow(presence_absence)) {presence_absence[i,1]<- 0}
> colnames(presence_absence)<- c("Sp1")
> Sp.Env<- rbind(bradypus, background)
> Sp.Env<- cbind(Sp.Env, presence_absence)
> Sp.Env$ecoreg = as.factor(Sp.Env$ecoreg)
> Resp.Var<- Sp.Env[,18]
> Resp.Var<- as.data.frame(Resp.Var)
> Expl.Var <- Sp.Env[,4:17]
> LatLong<- Sp.Env[, 2:3]
> head(Sp.Env, 10)
> summary(Sp.Env)
> Initial.State(Response = Resp.Var, Explanatory = Expl.Var)
> 
> >>Perhaps you could copy paste the Initial.State call you made
> 
> See above
> 
> >>The first ten lines of your observed data (head(MyDate). 
> 
> 		 x                  y   cld6190_ann  dtr6190_ann  ecoreg
>  1  -65.4000 	-10.3833                   76         	       104    10
> 2   -65.3833 	-10.3833                   76                 104     10
> 3   -65.1333 	-16.8000                   57                 114     10
> 4   -63.6667 	-17.4500                   57                 112     10
> 5   -63.8500 	-17.4000                   57                 113     10
> 6   -64.4167	-16.0000                   58                 111     10
> 7   -63.1667 	-17.8000                   57                 110       8
> 8   -56.7333  	  -2.6000                   77                   82     10
> 9   -59.1333  	  -3.7000                   83                  86      10
> 10 -60.0833 	  -3.1333                  82                   85      10
> 
> frs6190_ann h_dem  pre6190_ann  pre6190_l10  pre6190_l1  pre6190_l4  pre6190_l7
> 1              2       121                  46                   41                84                54                   3
> 2              2       121                  46                   40                84                54                   3
> 3              1       211                  65                   56              129                58                 34
> 4              3       363                  36                   33                71                27                 13
> 5              3       303                  39                   35                77                29                 15
> 6              0       166                  54                   48              107                45                 23
> 7              0       430                  33                   30                61               29                  15
> 8              0        12                   60                   24                69               96                  42
> 9              0        23                   58                   30                96               95                  25
> 10            0        32                   62                   39                84               98                  29
> 
>   tmn6190_ann  tmp6190_ann  tmx6190_ann  vap6190_ann  Sp1
> 1          	192         		266         		337         		279   1
> 2          	192         		266         		337         		279   1
> 3          	140         		244        		321         		221   1
> 4          	135         		229         		307         		202   1
> 5          	134         		229         		306        		202   1
> 6          	156         		252         		326         		235   1
> 7          	153         		245         		326         		217   1
> 8          	229         		275        		 335         	306   1
> 9          	220         		271         		328         		301   1
> 10         	224         		272         		328         		300   1
> 
> 
> >>summary( MyData)
> >>I doubt there are in the good format.
> 
>  x                y            cld6190_ann   
> Min.   :-94.72   Min.   :-55.025   Min.   :32.00  
> 1st Qu.:-69.92   1st Qu.:-24.538   1st Qu.:54.00  
> Median :-62.98   Median :-11.825   Median :64.00  
> Mean   :-62.05   Mean   :-13.560   Mean   :63.15  
> 3rd Qu.:-54.12   3rd Qu.: -2.425   3rd Qu.:74.00  
> Max.   :-34.92   Max.   : 23.125   Max.   :84.00  
>                                                                                
>   dtr6190_ann        ecoreg      frs6190_ann         h_dem     
>  Min.   : 49.0   10     :4590   Min.   :  0.00   Min.   :   0  
>  1st Qu.: 98.0   9      :1781   1st Qu.:  0.00   1st Qu.: 101  
>  Median :110.0   5      :1232   Median :  1.00   Median : 249  
>  Mean   :112.4   8      : 790   Mean   : 21.04   Mean   : 579  
>  3rd Qu.:125.0   2      : 620   3rd Qu.: 11.00   3rd Qu.: 598  
>  Max.   :178.0   12     : 495   Max.   :235.00   Max.   :5610  
>                  (Other): 608                                  
>   pre6190_ann      pre6190_l10       pre6190_l1       pre6190_l4    
>  Min.   :  0.00   Min.   :  0.00   Min.   :  0.00   Min.   :  0.00  
>  1st Qu.: 23.00   1st Qu.: 16.00   1st Qu.: 23.00   1st Qu.: 21.00  
>  Median : 41.00   Median : 37.00   Median : 47.00   Median : 38.00  
>  Mean   : 41.43   Mean   : 38.96   Mean   : 50.99   Mean   : 46.93  
>  3rd Qu.: 58.00   3rd Qu.: 55.00   3rd Qu.: 81.00   3rd Qu.: 73.00  
>  Max.   :204.00   Max.   :250.00   Max.   :185.00   Max.   :188.00  
>                                                                     
>    pre6190_l7      tmn6190_ann      tmp6190_ann     tmx6190_ann   
>  Min.   :  0.00   Min.   :-110.0   Min.   :  1.0   Min.   :101.0  
>  1st Qu.:  4.00   1st Qu.:  74.0   1st Qu.:183.0   1st Qu.:296.0  
>  Median : 14.00   Median : 159.0   Median :246.0   Median :320.0  
>  Mean   : 29.75   Mean   : 128.3   Mean   :214.9   Mean   :301.6  
>  3rd Qu.: 45.00   3rd Qu.: 196.0   3rd Qu.:261.0   3rd Qu.:331.0  
>  Max.   :222.00   Max.   : 229.0   Max.   :282.0   Max.   :362.0  
>                                                                   
>   vap6190_ann         Sp1         
>  Min.   :  1.0   Min.   :0.00000  
>  1st Qu.:155.0   1st Qu.:0.00000  
>  Median :225.0   Median :0.00000  
>  Mean   :205.3   Mean   :0.01147  
>  3rd Qu.:269.0   3rd Qu.:0.00000  
>  Max.   :310.0   Max.   :1.00000 
> 
> >If you also fear this is because of the categorical variable, try without it.
> 
> But since some models in BIOMOD can handle categorical variables, then would it be wise to exclude it? Doesn't that alter the results?
> 
> > First of all, does someone have to go through the whole procedure of typing the code above for each model >and for each variable, and to use the predict() function each time? According to the tutorial ?once the models >are trained (i.e. calibrated), a standard prediction is made. Then, one of the variables is randomized and a >new prediction is made.? I thought that BIOMOD was following this procedure automatically. If yes, how? If >not, how can I load CTA, ANN (and all the rest of the models in general) the same way glm is loaded in the >code above (i.e. glm(Sp281 ~ Var1 + Var2 + Var3 + Var4 + Var5 + Var6 + Var7, data=Sp.Env))?
> 
> >>Obviously not, or I will not have spent ten years coding BIOMOD?
> 
> Ok, but this unfairly ironic reply does not answer my question: what should I do instead of following the procedure described above? You might have spent ten years coding BIOMOD but how much time have you actually spent writing the manuals? I am afraid they are quite badly written! I first tried to learn BIOMOD a year ago by reading the 2008 manuals; I struggled for 2-3 weeks before giving up. I switched to WEKA and learned how to operate the software through the command line in one day by using the manual, even though I had never programmed in Java before. Three weeks ago I downloaded MaxEnt together with the manual and it just took me some days to learn how to analyse the outputs, not to mention that it was a piece of cake to run the models.
> 
> BIOMOD is such a powerful and innovative tool, and I have always found very exciting the idea of mastering it so as to have a series of different models running my predictions silmuntaneously. I truly believe that it is much better than MaxEnt and WEKA. I have been following your scientific work since the day I found out about BIOMOD but I still haven't managed to make it work properly. The 2012 manual is as bad as those of 2008... 
> 
> There is only one simple thing I'm asking for: if you aren't really willing to upgrade the manuals, then can I please ask you to be more supportive in the mailing list? I have received incomplete answers in the past as well and that does not help neither the users nor you.
> 
> Cheers,
> 
> Andreas
> 
> _______________________________________________
> 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







-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/biomod-commits/attachments/20120228/6988db42/attachment-0001.html>


More information about the Biomod-commits mailing list