Thanks Nicolas,<br><br>but it seems that the response.plot function is not recognized in the new Biomod. I'm sorry I'm a bit confused but I don't really understand if response curves are produced in the new Biomod<br>
<br>thanks <br><br>Anne-Laure<br><br><div class="gmail_quote">2012/7/3 Nico Davin <span dir="ltr"><<a href="mailto:nicolasdavin@hotmail.com" target="_blank">nicolasdavin@hotmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">



<div><div dir="ltr">
Dear Anne-Laure, <div><br></div><div><br></div><div>Normally you use the function </div><div><span style="font-size:10pt">>response.plot()</span></div><div><br></div><div>I do not know if this would help; but few months ago Wilfred gave a code to plot the response curves and more especially overlay the response curve of all the model.</div>
<div><br></div><div>For the importance of each variable, I don't know.</div><div><br></div><div>Please find bellow the forwarded mail from Wilfred.</div><div><br></div><div>I hope this help,</div><div>Nico</div><div><br>
</div><div><br></div><div><br><br><p style="text-align:justify"><b><span style="font-size:7.5pt;font-family:"Verdana","sans-serif";color:rgb(127,127,127)" lang="EN-GB">Nicolas Davin
</span></b></p>

<p><span style="font-size:7.5pt;font-family:"Verdana","sans-serif";color:rgb(127,127,127)" lang="EN-GB">PhD. student
<br>
</span><span style="font-size:7.5pt;font-family:"Verdana","sans-serif";color:rgb(127,127,127)"><img src="" alt="Description: Description: Logo ncb_naturalis_klein_72dpi" height="14" width="101"></span><b><span style="font-size:7.5pt;font-family:"Verdana","sans-serif";color:rgb(127,127,127)" lang="EN-GB"></span></b></p>


<p><b><span style="font-size:7.5pt;font-family:"Verdana","sans-serif";color:rgb(127,127,127)" lang="EN-GB">t</span></b><span style="font-size:5pt;font-family:"Verdana","sans-serif";color:rgb(127,127,127)" lang="EN-GB"> </span><span style="font-size:7.5pt;font-family:"Verdana","sans-serif";color:rgb(127,127,127)" lang="EN-GB"><a href="tel:%2B31-71527-3570" value="+31715273570" target="_blank">+31-71527-3570</a></span></p>


<span style="font-size:7.5pt;font-family:"Verdana","sans-serif";color:rgb(127,127,127)" lang="EN-GB">Netherlands Centre for Biodiversity Naturalis,<br>
P.O. Box 9514, 2300 RA Leiden, The Netherlands<br>
visiting address: Einsteinweg 2, Room C120<br>
</span><span style="font-size:10pt;font-family:"Tahoma","sans-serif""><a href="https://vstpst.leidenuniv.nl/exchweb/bin/redir.asp?URL=http://www.ncbnaturalis.nl/" target="_blank"><span style="font-size:7.5pt;font-family:"Verdana","sans-serif";color:rgb(127,127,127)" lang="EN-GB">www.ncbnaturalis.nl</span></a></span><br>
<br><div><div></div><hr>From: <a href="mailto:wilfried.thuiller@ujf-grenoble.fr" target="_blank">wilfried.thuiller@ujf-grenoble.fr</a><br>Date: Wed, 7 Mar 2012 08:48:28 +0100<br>To: <a href="mailto:emilie.roy-dufresne@mail.mcgill.ca" target="_blank">emilie.roy-dufresne@mail.mcgill.ca</a><br>
CC: <a href="mailto:biomod-commits@r-forge.wu-wien.ac.at" target="_blank">biomod-commits@r-forge.wu-wien.ac.at</a><br>Subject: Re: [Biomod-commits] overlay response curve plot<br><br><div>Dear Emilie, dear all,</div><div>
<br></div><div>I have patched the response curve function to overlay the response curves for all selected models. </div><div>This is really cool actually! The results are quite nice. </div><div>Please find attached the new function. Once BIOMOD is loaded, source this one.</div>
<div><br></div><div>source("PATH/response.plot.R")</div><div><br></div><div>Compared to the former function, there is one argument more: plot=TRUE/FALSE</div><div>If you put plot=TRUE, this is the same than the former one</div>
<div>If you put plot=FALSE, a 3-D array object is returned. This 3-D array contains:</div><div><br></div><div>First dimension: the same number of rows than the original data</div><div>Second dimension: 2 columns: The first one is the explanatory variable to plot, the second one, the probability of occurrence to plot</div>
<div>Third dimension: The set of environmental variables for which the response.plot was asked to run. </div><div><br></div><div>I have tried with the following code: </div><div><br></div><div>### Only three models are selected (GLM, FDA and RandomForest)</div>
<div><div style="margin-right:0px;margin-bottom:0px;margin-left:0px;font:normal normal normal 13px/normal Courier;color:rgb(0,113,40)"><span style="color:#042299">Initial.State(</span>Response<span style="color:#042299">=</span>Sp.Env<span style="color:#042299">[,</span><span style="color:#2b6fb8">12</span><span style="color:#042299">:</span><span style="color:#2b6fb8">13</span><span style="color:#042299">],</span><span style="color:#000000"> </span>Explanatory<span style="color:#042299">=</span>Sp.Env<span style="color:#042299">[,</span><span style="color:#2b6fb8">4</span><span style="color:#042299">:</span><span style="color:#2b6fb8">10</span><span style="color:#042299">])</span></div>
<div style="margin-right:0px;margin-bottom:0px;margin-left:0px;font:normal normal normal 13px/normal Courier;color:rgb(0,113,40)"><span style="color:#042299">Models(</span>GLM<span style="color:#000000"> </span><span style="color:#042299">=</span><span style="color:#000000"> </span><span style="color:#db224a">TRUE</span><span style="color:#042299">,</span><span style="color:#000000"> </span>TypeGLM<span style="color:#000000"> </span><span style="color:#042299">=</span><span style="color:#000000"> </span><span style="color:#b0140c">"quad"</span><span style="color:#042299">,</span><span style="color:#000000"> </span>Test<span style="color:#000000"> </span><span style="color:#042299">=</span><span style="color:#000000"> </span><span style="color:#b0140c">"AIC"</span><span style="color:#042299">,</span><span style="color:#000000"> </span>FDA<span style="color:#000000"> </span><span style="color:#042299">=</span><span style="color:#000000"> </span><span style="color:#db224a">TRUE</span><span style="color:#042299">,</span><span style="color:#000000"> </span>RF<span style="color:#000000"> </span><span style="color:#042299">=</span><span style="color:#000000"> </span><span style="color:#db224a">TRUE</span><span style="color:#042299">,</span><span style="color:#000000"> </span>NbRunEval<span style="color:#000000"> </span><span style="color:#042299">=</span><span style="color:#000000"> </span><span style="color:#2b6fb8">0</span><span style="color:#042299">,</span><span style="color:#000000"> </span>Roc<span style="color:#042299">=</span><span style="color:#db224a">T</span><span style="color:#042299">)</span></div>
<div style="margin-right:0px;margin-bottom:0px;margin-left:0px;font:normal normal normal 13px/normal Courier;min-height:16px"><br></div><div style="margin-right:0px;margin-bottom:0px;margin-left:0px;font:normal normal normal 13px/normal Courier;min-height:16px">
### Load back all models for the first species. </div><div style="margin-right:0px;margin-bottom:0px;margin-left:0px;font:normal normal normal 13px/normal Courier;color:rgb(4,34,153)">LoadModels(<span style="color:#007128">Sp</span>=<span style="color:#2b6fb8">1</span>,<span style="color:#000000"> </span><span style="color:#007128">PA</span>=<span style="color:#b0140c">'all'</span>,<span style="color:#000000"> </span><span style="color:#007128">rep</span>=<span style="color:#2b6fb8">1</span>,<span style="color:#000000"> </span><span style="color:#007128">models</span>=<span style="color:#b0140c">'all'</span>)</div>
<div style="margin-right:0px;margin-bottom:0px;margin-left:0px;font:normal normal normal 13px/normal Courier;min-height:16px"><br></div><div style="margin-right:0px;margin-bottom:0px;margin-left:0px;font:normal normal normal 13px/normal Courier;min-height:16px">
### Save the object return by the new response.plot function</div><div style="margin-right:0px;margin-bottom:0px;margin-left:0px;font:normal normal normal 13px/normal Courier;color:rgb(0,113,40)">GLM.RC<span style="color:#000000"> </span><span style="color:#042299"><-</span><span style="color:#000000"> </span><span style="color:#042299">response.plot(</span>Sp290_GLM_full<span style="color:#042299">,</span><span style="color:#000000"> </span>Sp.Env<span style="color:#042299">[,</span><span style="color:#2b6fb8">4</span><span style="color:#042299">:</span><span style="color:#2b6fb8">10</span><span style="color:#042299">],</span><span style="color:#000000"> </span>plot<span style="color:#042299">=</span><span style="color:#db224a">F</span><span style="color:#042299">)</span></div>
<div style="margin-right:0px;margin-bottom:0px;margin-left:0px;font:normal normal normal 13px/normal Courier;color:rgb(0,113,40)">FDA.RC<span style="color:#000000"> </span><span style="color:#042299"><-</span><span style="color:#000000"> </span><span style="color:#042299">response.plot(</span>Sp290_FDA_full<span style="color:#042299">,</span><span style="color:#000000"> </span>Sp.Env<span style="color:#042299">[,</span><span style="color:#2b6fb8">4</span><span style="color:#042299">:</span><span style="color:#2b6fb8">10</span><span style="color:#042299">],</span><span style="color:#000000"> </span>plot<span style="color:#042299">=</span><span style="color:#db224a">F</span><span style="color:#042299">)</span></div>
<div style="margin-right:0px;margin-bottom:0px;margin-left:0px;font:normal normal normal 13px/normal Courier;color:rgb(0,113,40)">RF.RC<span style="color:#000000"> </span><span style="color:#042299"><-</span><span style="color:#000000"> </span><span style="color:#042299">response.plot(</span>Sp290_RF_full<span style="color:#042299">,</span><span style="color:#000000"> </span>Sp.Env<span style="color:#042299">[,</span><span style="color:#2b6fb8">4</span><span style="color:#042299">:</span><span style="color:#2b6fb8">10</span><span style="color:#042299">],</span><span style="color:#000000"> </span>plot<span style="color:#042299">=</span><span style="color:#db224a">F</span><span style="color:#042299">)</span></div>
<div style="margin-right:0px;margin-bottom:0px;margin-left:0px;font:normal normal normal 13px/normal Courier;min-height:16px"><br></div><div style="margin-right:0px;margin-bottom:0px;margin-left:0px;font:normal normal normal 13px/normal Courier;min-height:16px">
### plot the response for GLM for the first variable (the 1 for the third dimension)</div><div style="margin-right:0px;margin-bottom:0px;margin-left:0px;font:normal normal normal 13px/normal Courier;color:rgb(4,34,153)">plot(<span style="color:#007128">GLM.RC</span>[,<span style="color:#2b6fb8">1</span>,<span style="color:#2b6fb8">1</span>],<span style="color:#000000"> </span><span style="color:#007128">GLM.RC</span>[,<span style="color:#2b6fb8">2</span>,<span style="color:#2b6fb8">1</span>],<span style="color:#000000">  </span><span style="color:#007128">type</span>=<span style="color:#b0140c">"l"</span>,<span style="color:#000000"> </span><span style="color:#007128">ylim</span>=c(<span style="color:#2b6fb8">0</span>,<span style="color:#2b6fb8">1</span>),<span style="color:#000000"> </span><span style="color:#007128">xlab</span>=colnames(<span style="color:#007128">GLM.RC</span>[,<span style="color:#2b6fb8">1</span>,])[<span style="color:#2b6fb8">1</span>],<span style="color:#000000"> </span><span style="color:#007128">ylab</span>=<span style="color:#b0140c">"Probability of occurrence"</span>)</div>
<div style="margin-right:0px;margin-bottom:0px;margin-left:0px;font:normal normal normal 13px/normal Courier;color:rgb(4,34,153)">### then add the lines for the two other models with different colors</div><div style="margin-right:0px;margin-bottom:0px;margin-left:0px;font:normal normal normal 13px/normal Courier;color:rgb(4,34,153)">
lines(<span style="color:#007128">FDA.RC</span>[,<span style="color:#2b6fb8">1</span>,<span style="color:#2b6fb8">1</span>],<span style="color:#000000"> </span><span style="color:#007128">FDA.RC</span>[,<span style="color:#2b6fb8">2</span>,<span style="color:#2b6fb8">1</span>],<span style="color:#000000"> </span><span style="color:#007128">col</span>=<span style="color:#b0140c">'blue'</span>)</div>
<div style="margin-right:0px;margin-bottom:0px;margin-left:0px;font:normal normal normal 13px/normal Courier;color:rgb(4,34,153)">lines(<span style="color:#007128">RF.RC</span>[,<span style="color:#2b6fb8">1</span>,<span style="color:#2b6fb8">1</span>],<span style="color:#000000"> </span><span style="color:#007128">RF.RC</span>[,<span style="color:#2b6fb8">2</span>,<span style="color:#2b6fb8">1</span>],<span style="color:#000000"> </span><span style="color:#007128">col</span>=<span style="color:#b0140c">'red'</span>)</div>
<div style="margin-right:0px;margin-bottom:0px;margin-left:0px;font:normal normal normal 13px/normal Courier;color:rgb(4,34,153)">### load the gplots package to make nice and user-friendly legends.</div><div style="margin-right:0px;margin-bottom:0px;margin-left:0px;font:normal normal normal 13px/normal Courier;color:rgb(4,34,153)">
library(<span style="color:#007128">plots</span>)</div><div style="margin-right:0px;margin-bottom:0px;margin-left:0px;font:normal normal normal 13px/normal Courier;color:rgb(4,34,153)">### add a legend</div><div style="margin-right:0px;margin-bottom:0px;margin-left:0px;font:normal normal normal 13px/normal Courier;color:rgb(176,20,12)">
<span style="color:#042299">smartlegend(</span><span style="color:#007128">x</span><span style="color:#042299">=</span>"left"<span style="color:#042299">,</span><span style="color:#007128">y</span><span style="color:#042299">=</span>"top"<span style="color:#042299">,</span><span style="color:#000000"> </span><span style="color:#007128">inset</span><span style="color:#000000"> </span><span style="color:#042299">=</span><span style="color:#000000"> </span><span style="color:#2b6fb8">0</span><span style="color:#042299">,</span><span style="color:#000000"> </span><span style="color:#042299">c(</span>"GLM"<span style="color:#042299">,</span><span style="color:#000000"> </span>"FDA"<span style="color:#042299">,</span><span style="color:#000000"> </span>"RF"<span style="color:#042299">),</span><span style="color:#000000"> </span><span style="color:#007128">fill</span><span style="color:#000000"> </span><span style="color:#042299">=</span><span style="color:#000000"> </span><span style="color:#042299">c(</span>"black"<span style="color:#042299">,</span><span style="color:#000000"> </span>"blue"<span style="color:#042299">,</span><span style="color:#000000"> </span>"red"<span style="color:#042299">))</span></div>
<div style="margin-right:0px;margin-bottom:0px;margin-left:0px;font:normal normal normal 13px/normal Courier;min-height:16px"><br></div><div style="margin-right:0px;margin-bottom:0px;margin-left:0px;font:normal normal normal 13px/normal Courier;min-height:16px">
<br></div><div style="margin-right:0px;margin-bottom:0px;margin-left:0px;font:normal normal normal 13px/normal Courier;min-height:16px">#### the same but with all variables plotted in the same plot window. </div><div style="margin-right:0px;margin-bottom:0px;margin-left:0px;font:normal normal normal 13px/normal Courier;color:rgb(4,34,153)">
library(<span style="color:#007128">gplots</span>)</div><div style="margin-right:0px;margin-bottom:0px;margin-left:0px;font:normal normal normal 13px/normal Courier;color:rgb(4,34,153)">par(<span style="color:#007128">mfrow</span>=c(<span style="color:#2b6fb8">3</span>,<span style="color:#2b6fb8">3</span>))</div>
<div style="margin-right:0px;margin-bottom:0px;margin-left:0px;font:normal normal normal 13px/normal Courier;color:rgb(4,34,153)"><span style="color:#db224a">for</span>(<span style="color:#007128">i</span><span style="color:#000000"> </span><span style="color:#db224a">in</span><span style="color:#000000"> </span><span style="color:#2b6fb8">1</span>:ncol(<span style="color:#007128">Sp.Env</span>[,<span style="color:#2b6fb8">4</span>:<span style="color:#2b6fb8">10</span>])){</div>
<p style="font:13.0px Courier;min-height:16.0px"><span style="white-space:pre-wrap">    </span><br></p><div style="margin-right:0px;margin-bottom:0px;margin-left:0px;font:normal normal normal 13px/normal Courier;color:rgb(4,34,153)">
<span style="color:#000000"><span style="white-space:pre-wrap"> </span></span>plot(<span style="color:#007128">GLM.RC</span>[,<span style="color:#2b6fb8">1</span>,<span style="color:#007128">i</span>],<span style="color:#000000"> </span><span style="color:#007128">GLM.RC</span>[,<span style="color:#2b6fb8">2</span>,<span style="color:#007128">i</span>],<span style="color:#000000">  </span><span style="color:#007128">type</span>=<span style="color:#b0140c">"l"</span>,<span style="color:#000000"> </span><span style="color:#007128">ylim</span>=c(<span style="color:#2b6fb8">0</span>,<span style="color:#2b6fb8">1</span>),<span style="color:#000000"> </span><span style="color:#007128">xlab</span>=colnames(<span style="color:#007128">GLM.RC</span>[,<span style="color:#2b6fb8">1</span>,])[<span style="color:#007128">i</span>],<span style="color:#000000"> </span><span style="color:#007128">ylab</span>=<span style="color:#b0140c">"Probability of occurrence"</span>)</div>
<div style="margin-right:0px;margin-bottom:0px;margin-left:0px;font:normal normal normal 13px/normal Courier;color:rgb(4,34,153)"><span style="color:#000000"><span style="white-space:pre-wrap">       </span></span>lines(<span style="color:#007128">FDA.RC</span>[,<span style="color:#2b6fb8">1</span>,<span style="color:#007128">i</span>],<span style="color:#000000"> </span><span style="color:#007128">FDA.RC</span>[,<span style="color:#2b6fb8">2</span>,<span style="color:#007128">i</span>],<span style="color:#000000"> </span><span style="color:#007128">col</span>=<span style="color:#b0140c">'blue'</span>)</div>
<div style="margin-right:0px;margin-bottom:0px;margin-left:0px;font:normal normal normal 13px/normal Courier;color:rgb(4,34,153)"><span style="color:#000000"><span style="white-space:pre-wrap">       </span></span>lines(<span style="color:#007128">RF.RC</span>[,<span style="color:#2b6fb8">1</span>,<span style="color:#007128">i</span>],<span style="color:#000000"> </span><span style="color:#007128">RF.RC</span>[,<span style="color:#2b6fb8">2</span>,<span style="color:#007128">i</span>],<span style="color:#000000"> </span><span style="color:#007128">col</span>=<span style="color:#b0140c">'red'</span>)</div>
<div style="margin-right:0px;margin-bottom:0px;margin-left:0px;font:normal normal normal 13px/normal Courier;color:rgb(176,20,12)"><span style="color:#000000"><span style="white-space:pre-wrap">      </span></span><span style="color:#042299">smartlegend(</span><span style="color:#007128">x</span><span style="color:#042299">=</span>"left"<span style="color:#042299">,</span><span style="color:#007128">y</span><span style="color:#042299">=</span>"top"<span style="color:#042299">,</span><span style="color:#000000"> </span><span style="color:#007128">inset</span><span style="color:#000000"> </span><span style="color:#042299">=</span><span style="color:#000000"> </span><span style="color:#2b6fb8">0</span><span style="color:#042299">,</span><span style="color:#000000"> </span><span style="color:#042299">c(</span>"GLM"<span style="color:#042299">,</span><span style="color:#000000"> </span>"FDA"<span style="color:#042299">,</span><span style="color:#000000"> </span>"RF"<span style="color:#042299">),</span><span style="color:#000000"> </span><span style="color:#007128">fill</span><span style="color:#000000"> </span><span style="color:#042299">=</span><span style="color:#000000"> </span><span style="color:#042299">c(</span>"black"<span style="color:#042299">,</span><span style="color:#000000"> </span>"blue"<span style="color:#042299">,</span><span style="color:#000000"> </span>"red"<span style="color:#042299">),</span><span style="color:#007128">cex</span><span style="color:#042299">=</span><span style="color:#2b6fb8">0.6</span><span style="color:#042299">)</span></div>
<div style="margin-right:0px;margin-bottom:0px;margin-left:0px;font:normal normal normal 13px/normal Courier;min-height:16px"><br></div><div style="margin-right:0px;margin-bottom:0px;margin-left:0px;font:normal normal normal 13px/normal Courier;min-height:16px">
<br></div><p style="font:13.0px Courier;min-height:16.0px"><span style="white-space:pre-wrap">      </span><br></p><p style="font:13.0px Courier;min-height:16.0px"><span style="white-space:pre-wrap">   </span><br></p><div style="margin-right:0px;margin-bottom:0px;margin-left:0px;font:normal normal normal 13px/normal Courier;color:rgb(4,34,153)">
}</div></div><div><br></div><div><br></div><div>Hope it helps. This is very likely that we will replace the former response.plot function by this new one. Thanks Emilie for the question! ;-)</div><div><br></div><div>Best</div>
<div>Wilfried</div><div><br></div><div></div><br><div></div><br>_______________________________________________
Biomod-commits mailing list
<a href="mailto:Biomod-commits@lists.r-forge.r-project.org" target="_blank">Biomod-commits@lists.r-forge.r-project.org</a>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/biomod-commits" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/biomod-commits</a></div></div>                                     </div></div>
</blockquote></div><br>