<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Dear Pep,</div><div><br></div><div><blockquote type="cite"><div>In that huge DF many species are recorded, so I though creating a litle loop so I could go species by species and therefore would not load a huge dataset (Question 1- Is that making any sense?). In each species model, presences and absences are equaled, so we keep prevalence constant, and the strategy of PseudoA selection is SRE. (see script below)<br></div></blockquote><div><br></div><div>It does make sense to run BIOMOD species by species. This what I am usually doing when using grid systems.&nbsp;</div><br><blockquote type="cite"><div>For the first species (only 4500 presences) R retrieves this memory error when computing RF, which I cannot understand for a DF of 9000 rows (P+A), and I even the number of repetitions is set to 1.<br><br>Secondly, I checked that BIOMOD creates an object: Biomod.PA.data with 40000 records aprox. I assume that these are the presences and the ALL absences selected outside the SurfaceRange (strategy selected), and later on BIOMOD will select the number of absences indicated (=Number of Presences in this case). Question 2- Is this correct or is it loading ALL absences outside the range? (maybe that's why it retrieves an error.) <br></div></blockquote><div><br></div><div><div>However, it will much more powerful to also create a workspace and data folder to store the results for each species.&nbsp;</div><div>From what I understand from your code, everything will be re-written at each iteration.&nbsp;</div></div><br><blockquote type="cite"><div>Question 3- Any suggestion?<br></div></blockquote><div><br></div><div>Yes indeed.&nbsp;</div><div>First of all, I would rather use random pseudo-absence instead of SRE and select a large number of pseudo-absence. BIOMOD will automatically make sure that the weighted sum of 1 equals the weighted sum of 0 (weighted prevalence = 0.5). We are preparing a MS with virtual data to show that this is a much better solution than using SRE or anything else.&nbsp;</div><div><br></div><div>In the case where most of your species have less than 5000 occurrences, selected 20000 absences and it should work rather well.&nbsp;</div><br><blockquote type="cite"><div><br># i corresponds to the column where the species Presence or Absence is located<br><br>for (i in "spColumID") {<br><br>Initial.State (Response=Sp.Env[,i], Explanatory=Sp.Env[,c(250,248,251,199,164,181)],IndependentResponse=NULL, IndependentExplanatory=NULL,sp.name=names[i])<br><br>Models(GLM = T, TypeGLM = "quad", Test = "AIC", GBM = T, No.trees = 3000, GAM = T, Spline=2, CTA = T, CV.tree = 50, ANN = T, CV.ann = 2, SRE = F, FDA = T, MARS = T, RF = T, NbRunEval = 1, DataSplit = 70, Yweights=NULL, Roc=T, Optimized.Threshold.Roc=T, Kappa=T, TSS=T, KeepPredIndependent = F, VarImport=5, NbRepPA=1, strategy="sre", coor=Coor, distance=2, nb.absences=sum(Sp.Env[,i]))<br><br>}<br></div></blockquote><div><br></div><div>Depending on which OS you are on, there are different solutions. With MacOS or Unic, you could use R in batch mode.&nbsp;</div><div>On Windows, what you wrote is fine excepted that you re-write everything on the same .RData which is not what you want to do (it explains the confusion with the number of records).&nbsp;</div><div><br></div><div>First of all, you should create a folder for each species in the loop, then run BIOMOD in this folder, and then once Models is finished, removed everything from the workspce to make sure you are using some data from the previous run.&nbsp;</div><div><br></div><div>It could be simply something along these lines, probably to adapt a bit with for your data and OS.&nbsp;</div><div><br></div><div><br></div><div><br></div><div>setwd("YOUR FOLDER WHERE YOU WANT TO STORE THE RESULS")<br><br>path&nbsp;=&nbsp;getwd()<br><br>for&nbsp;(i&nbsp;in&nbsp;"spColumID") {<br><br>#Create a folder you store the results for each species separately.<br>dir.create(paste(path,&nbsp;"/",&nbsp;names[i],&nbsp;sep=""))</div><div><br>#Set the workspace in this folder<br>setwd(paste(path,&nbsp;"/",&nbsp;names[i],&nbsp;sep=""))<br><br>Initial.State&nbsp;(Response=Sp.Env[,i],&nbsp;Explanatory=Sp.Env[,c(250,248,251,199,164,181)],IndependentResponse=NULL,&nbsp;IndependentExplanatory=NULL,<a href="http://sp.name">sp.name</a>=names[i])<br><br>Models(GLM&nbsp;=&nbsp;T,&nbsp;TypeGLM&nbsp;=&nbsp;"quad",&nbsp;Test&nbsp;=&nbsp;"AIC",&nbsp;GBM&nbsp;=&nbsp;T,&nbsp;No.trees&nbsp;=&nbsp;3000,&nbsp;GAM&nbsp;=&nbsp;T,&nbsp;Spline=2,&nbsp;CTA&nbsp;=&nbsp;T,&nbsp;CV.tree&nbsp;=&nbsp;50,&nbsp;ANN&nbsp;=&nbsp;T,&nbsp;CV.ann&nbsp;=&nbsp;2,&nbsp;SRE&nbsp;=&nbsp;F,&nbsp;FDA&nbsp;=&nbsp;T,&nbsp;MARS&nbsp;=&nbsp;T,&nbsp;RF&nbsp;=&nbsp;T,&nbsp;NbRunEval&nbsp;=&nbsp;1,&nbsp;DataSplit&nbsp;=&nbsp;70,&nbsp;Yweights=NULL,&nbsp;Roc=T,&nbsp;Optimized.Threshold.Roc=T,&nbsp;Kappa=T,&nbsp;TSS=T,&nbsp;KeepPredIndependent&nbsp;=&nbsp;F,&nbsp;VarImport=5,&nbsp;NbRepPA=1,&nbsp;strategy="sre",&nbsp;coor=Coor,&nbsp;distance=2,&nbsp;nb.absences=sum(Sp.Env[,i]))<br><br>#keep the files you want to keep in a vector before deleting everything<br>t=&nbsp;c("path",&nbsp;"Sp.Env",&nbsp;"names")<br>Rem&nbsp;=&nbsp;ls()<br><br>#Delete everything but the object in t.<br>rm(list=(Rem[is.na(match(Rem,&nbsp;t))]))<br><br>}<br><br></div><div><br></div><div><br></div><div>Hope it helps,</div><div>Best</div><div>Wilfried</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><br><blockquote type="cite"><div><br><br>Thank you very much in advance for reading such a long post with 3 Questions!<br><br>Pep<br><br><br>_______________________________________________<br>Biomod-commits mailing list<br><a href="mailto:Biomod-commits@lists.r-forge.r-project.org">Biomod-commits@lists.r-forge.r-project.org</a><br>https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/biomod-commits<br></div></blockquote></div><br><div>
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><span class="Apple-style-span" style="font-size: 12px; "><div>--------------------------</div><div>Dr. Wilfried Thuiller</div><div>Laboratoire d'Ecologie Alpine, UMR CNRS 5553</div><div>Université Joseph Fourier</div><div>BP53, 38041 Grenoble cedex 9, France</div><div>tel: +33 (0)4 76 51 44 97</div><div>fax: +33 (0)4 76 51 42 79</div><div><br></div><div>Email:&nbsp;<a href="mailto:wilfried.thuiller@ujf-grenoble.fr">wilfried.thuiller@ujf-grenoble.fr</a><br>Home page:&nbsp;<a href="http://www.will.chez-alice.fr/">http://www.will.chez-alice.fr</a><br>Website:&nbsp;<a href="http://www-leca.ujf-grenoble.fr/equipes/tde.htm">http://www-leca.ujf-grenoble.fr/equipes/tde.htm</a><br><br>FP6 European MACIS project:&nbsp;<a href="http://www.macis-project.net/">http://www.macis-project.net</a><br>FP6 European EcoChange project:&nbsp;<a href="http://www.ecochange-project.eu/">http://www.ecochange-project.eu</a></div><div><br></div></span></div></div><br class="Apple-interchange-newline"></div><br class="Apple-interchange-newline"><br class="Apple-interchange-newline">
</div>
<br></body></html>