<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/stock-recruitment-graphing-questions/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://derekogle.com/fishR/2017-12-12-Stock-Recruitment-Graphing-Questions"> fishR Blog</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>A <strong>fishR</strong> user recently asked me</p>
<blockquote>
<p>In the book that you published, I frequently use the stock-recruit curve code. The interface that shows both the Ricker/Beverton-Holt figure with the recruit per spawner to spawner figure (i.e., the dynamic plot for <code>srStarts()</code>) has not been working for quite some time. Additionally, I can get the recruits versus spawner plot for the Beverton-Holt or Ricker curve with confidence bounds around the curve, but how do you do the same for the recruit per spawner to spawner curve?</p>
</blockquote>
<p>Below I answer both questions. First, however, I load required packages …</p>
<figure>
<pre><code data-lang="r"><span>library</span><span>(</span><span>FSA</span><span>)</span><span> </span><span># srStarts, srFuns</span><span><br data-jekyll-commonmark-ghpages=""></span><span>library</span><span>(</span><span>FSAdata</span><span>)</span><span> </span><span># PSalmonAK data</span><span><br data-jekyll-commonmark-ghpages=""></span><span>library</span><span>(</span><span>dplyr</span><span>)</span><span> </span><span># %>%, filter, mutate, select</span><span><br data-jekyll-commonmark-ghpages=""></span><span>library</span><span>(</span><span>nlstools</span><span>)</span><span> </span><span># nlsBoot</span></code></pre>
</figure>
<p>… and obtain the same data (in PSalmonAK.csv available from <a rel="nofollow" href="http://derekogle.com/IFAR/scripts/" target="_blank">here</a>) used in the Stock-Recruitment chapter of my <a rel="nofollow" href="http://derekogle.com/IFAR/" target="_blank"><strong>Introductory Fisheries Analyses with R</strong></a> (IFAR) book. Note that I created two new variables here: <code>retperesc</code> is the “recruits per spawner” and <code>logretperesc</code> is the natural log of the recruits per spawner variable.</p>
<figure>
<pre><code data-lang="r"><span>pinks</span><span> </span><span>&lt;-</span><span> </span><span>read.csv</span><span>(</span><span>&quot;data/PSalmonAK.csv&quot;</span><span>)</span><span> </span><span>%>%</span><span><br data-jekyll-commonmark-ghpages=""> </span><span>filter</span><span>(</span><span>!</span><span>is.na</span><span>(</span><span>esc</span><span>),</span><span>!</span><span>is.na</span><span>(</span><span>ret</span><span>))</span><span> </span><span>%>%</span><span><br data-jekyll-commonmark-ghpages=""> </span><span>mutate</span><span>(</span><span>esc</span><span>=</span><span>esc</span><span>/</span><span>1000</span><span>,</span><span>ret</span><span>=</span><span>ret</span><span>/</span><span>1000</span><span>,</span><span>logret</span><span>=</span><span>log</span><span>(</span><span>ret</span><span>),</span><span><br data-jekyll-commonmark-ghpages=""> </span><span>retperesc</span><span>=</span><span>ret</span><span>/</span><span>esc</span><span>,</span><span>logretperesc</span><span>=</span><span>log</span><span>(</span><span>retperesc</span><span>))</span><span> </span><span>%>%</span><span><br data-jekyll-commonmark-ghpages=""> </span><span>select</span><span>(</span><span>-</span><span>SST</span><span>)</span><span><br data-jekyll-commonmark-ghpages=""></span><span>headtail</span><span>(</span><span>pinks</span><span>)</span></code></pre>
</figure>
<figure>
<pre><code data-lang="text">##    year   esc    ret   logret retperesc logretperesc<br data-jekyll-commonmark-ghpages="">## 1  1960 1.418  2.446 0.894454  1.724965    0.5452066<br data-jekyll-commonmark-ghpages="">## 2  1961 2.835 14.934 2.703640  5.267725    1.6615986<br data-jekyll-commonmark-ghpages="">## 3  1962 1.957 10.031 2.305680  5.125703    1.6342676<br data-jekyll-commonmark-ghpages="">## 28 1987 4.289 18.215 2.902245  4.246911    1.4461918<br data-jekyll-commonmark-ghpages="">## 29 1988 2.892  9.461 2.247178  3.271438    1.1852298<br data-jekyll-commonmark-ghpages="">## 30 1989 4.577 23.359 3.150982  5.103561    1.6299386</code></pre>
</figure>
<h2>Dynamic Plot Issue</h2>
<p>The first question about the dynamic plot is due to a change in functionality in the <strong>FSA</strong> package since <strong>IFAR</strong> was published. The <code>dynamicPlot=</code> argument was removed because the code for that argument relied on the <strong>tcltk</strong> package, which I found difficult to reliably support. A similar, though more manual, approach is accomplished with the new <code>fixed=</code> and <code>plot=</code> arguments. For example, using <code>plot=TRUE</code> (without <code>fixed=</code>) will produces a plot of “recruits” versus “stock” with the chosen stock-recruitment model evaluated at the automatically chosen parameter starting values superimposed.</p>
<figure>
<pre><code data-lang="r"><span>svR</span><span> </span><span>&lt;-</span><span> </span><span>srStarts</span><span>(</span><span>ret</span><span>~</span><span>esc</span><span>,</span><span>data</span><span>=</span><span>pinks</span><span>,</span><span>type</span><span>=</span><span>&quot;Ricker&quot;</span><span>,</span><span>plot</span><span>=</span><span>TRUE</span><span>)</span></code></pre>
</figure>
<p><img alt="plot of chunk srStarts1" src="https://i0.wp.com/derekogle.com/fishR/figures/srStarts1-1.png?w=456" data-recalc-dims="1"></p>
<p>The user, however, can show the stock-recruitment model evaluated at manually chosen parameter starting values by including those starting values in a list that is supplied to <code>fixed=</code>. These values can be iteratively changed in subsequent calls to <code>srStarts()</code> to manually find starting values that provide a model that reasonably fits (by eye) the stock-recruit data.</p>
<figure>
<pre><code data-lang="r"><span>svR</span><span> </span><span>&lt;-</span><span> </span><span>srStarts</span><span>(</span><span>ret</span><span>~</span><span>esc</span><span>,</span><span>data</span><span>=</span><span>pinks</span><span>,</span><span>type</span><span>=</span><span>&quot;Ricker&quot;</span><span>,</span><span>plot</span><span>=</span><span>TRUE</span><span>,</span><span><br data-jekyll-commonmark-ghpages=""> </span><span>fixed</span><span>=</span><span>list</span><span>(</span><span>a</span><span>=</span><span>4</span><span>,</span><span>b</span><span>=</span><span>0.15</span><span>))</span></code></pre>
</figure>
<p><img alt="plot of chunk srStarts2" src="https://i2.wp.com/derekogle.com/fishR/figures/srStarts2-1.png?w=456" data-recalc-dims="1"></p>
<p>Note however that <code>srStarts()</code> no longer supports the simultaneously plotting of spawners versus recruits and recruits per spawner versus recruits.</p>
<h2>Plot of Recruits per Spawner versus Spawners</h2>
<p>The first way that I can imagine plotting recruits per spawners versus spawners with the fitted curve and confidence bands is to first follow the code for fitting the stock-recruit function to the stock and recruit data as described in <strong>IFAR</strong>. In this case, the stock-recruit function is fit on the log scale to adjust for a multiplicative error structure (as described in <strong>IFAR</strong>).</p>
<figure>
<pre><code data-lang="r"><span>rckr</span><span> </span><span>&lt;-</span><span> </span><span>srFuns</span><span>(</span><span>&quot;Ricker&quot;</span><span>)</span><span><br data-jekyll-commonmark-ghpages=""></span><span>srR</span><span> </span><span>&lt;-</span><span> </span><span>nls</span><span>(</span><span>logret</span><span>~</span><span>log</span><span>(</span><span>rckr</span><span>(</span><span>esc</span><span>,</span><span>a</span><span>,</span><span>b</span><span>)),</span><span>data</span><span>=</span><span>pinks</span><span>,</span><span>start</span><span>=</span><span>svR</span><span>)</span><span><br data-jekyll-commonmark-ghpages=""></span><span>bootR</span><span> </span><span>&lt;-</span><span> </span><span>nlsBoot</span><span>(</span><span>srR</span><span>)</span><span><br data-jekyll-commonmark-ghpages=""></span><span>cbind</span><span>(</span><span>estimates</span><span>=</span><span>coef</span><span>(</span><span>srR</span><span>),</span><span>confint</span><span>(</span><span>bootR</span><span>))</span></code></pre>
</figure>
<figure>
<pre><code data-lang="text">##    estimates     95% LCI   95% UCI<br data-jekyll-commonmark-ghpages="">## a 2.84924206  1.74768271 4.8435727<br data-jekyll-commonmark-ghpages="">## b 0.05516673 -0.08443862 0.2158164</code></pre>
</figure>
<p>As described in the book, the plot of spawners versus recruits is made by (i) constructing a sequence of “x” values that span the range of observed numbers of spawners, (ii) predicting the number of recruits at each spawner value using the best-fit stock-recruitment model, (iii) constructing lower and upper confidence bounds for the predicted number of recruits at each spawner value with the bootstrap results, (iv) making a schematic plot on which to put (v) a polygon for the confidence band, (vi) the raw data points, and (vii) the best-fit curve. The code below follows these steps and reproduces Figure 12.4 in the book.</p>
<figure>
<pre><code data-lang="r"><span>x</span><span> </span><span>&lt;-</span><span> </span><span>seq</span><span>(</span><span>0</span><span>,</span><span>9</span><span>,</span><span>length.out</span><span>=</span><span>199</span><span>)</span><span> </span><span># many S for prediction</span><span><br data-jekyll-commonmark-ghpages=""></span><span>pR</span><span> </span><span>&lt;-</span><span> </span><span>rckr</span><span>(</span><span>x</span><span>,</span><span>a</span><span>=</span><span>coef</span><span>(</span><span>srR</span><span>))</span><span> </span><span># predicted mean R</span><span><br data-jekyll-commonmark-ghpages=""></span><span>LCI</span><span> </span><span>&lt;-</span><span> </span><span>UCI</span><span> </span><span>&lt;-</span><span> </span><span>numeric</span><span>(</span><span>length</span><span>(</span><span>x</span><span>))</span><span><br data-jekyll-commonmark-ghpages=""><br data-jekyll-commonmark-ghpages=""></span><span>for</span><span>(</span><span>i</span><span> </span><span>in</span><span> </span><span>1</span><span>:</span><span>length</span><span>(</span><span>x</span><span>))</span><span> </span><span>{</span><span> </span><span># CIs for mean R @ each S</span><span><br data-jekyll-commonmark-ghpages=""> </span><span>tmp</span><span> </span><span>&lt;-</span><span> </span><span>apply</span><span>(</span><span>bootR</span><span>$</span><span>coefboot</span><span>,</span><span>MARGIN</span><span>=</span><span>1</span><span>,</span><span>FUN</span><span>=</span><span>rckr</span><span>,</span><span>S</span><span>=</span><span>x</span><span>[</span><span>i</span><span>])</span><span><br data-jekyll-commonmark-ghpages=""> </span><span>LCI</span><span>[</span><span>i</span><span>]</span><span> </span><span>&lt;-</span><span> </span><span>quantile</span><span>(</span><span>tmp</span><span>,</span><span>0.025</span><span>)</span><span><br data-jekyll-commonmark-ghpages=""> </span><span>UCI</span><span>[</span><span>i</span><span>]</span><span> </span><span>&lt;-</span><span> </span><span>quantile</span><span>(</span><span>tmp</span><span>,</span><span>0.975</span><span>)</span><span><br data-jekyll-commonmark-ghpages=""></span><span>}</span><span><br data-jekyll-commonmark-ghpages=""></span><span>ylmts</span><span> </span><span>&lt;-</span><span> </span><span>range</span><span>(</span><span>c</span><span>(</span><span>pR</span><span>,</span><span>LCI</span><span>,</span><span>UCI</span><span>,</span><span>pinks</span><span>$</span><span>ret</span><span>))</span><span><br data-jekyll-commonmark-ghpages=""></span><span>xlmts</span><span> </span><span>&lt;-</span><span> </span><span>range</span><span>(</span><span>c</span><span>(</span><span>x</span><span>,</span><span>pinks</span><span>$</span><span>esc</span><span>))</span><span><br data-jekyll-commonmark-ghpages=""><br data-jekyll-commonmark-ghpages=""></span><span>plot</span><span>(</span><span>ret</span><span>~</span><span>esc</span><span>,</span><span>data</span><span>=</span><span>pinks</span><span>,</span><span>xlim</span><span>=</span><span>xlmts</span><span>,</span><span>ylim</span><span>=</span><span>ylmts</span><span>,</span><span>col</span><span>=</span><span>&quot;white&quot;</span><span>,</span><span><br data-jekyll-commonmark-ghpages=""> </span><span>ylab</span><span>=</span><span>&quot;Returners (millions)&quot;</span><span>,</span><span><br data-jekyll-commonmark-ghpages=""> </span><span>xlab</span><span>=</span><span>&quot;Escapement (millions)&quot;</span><span>)</span><span><br data-jekyll-commonmark-ghpages=""></span><span>polygon</span><span>(</span><span>c</span><span>(</span><span>x</span><span>,</span><span>rev</span><span>(</span><span>x</span><span>)),</span><span>c</span><span>(</span><span>LCI</span><span>,</span><span>rev</span><span>(</span><span>UCI</span><span>)),</span><span>col</span><span>=</span><span>&quot;gray80&quot;</span><span>,</span><span>border</span><span>=</span><span>NA</span><span>)</span><span><br data-jekyll-commonmark-ghpages=""></span><span>points</span><span>(</span><span>ret</span><span>~</span><span>esc</span><span>,</span><span>data</span><span>=</span><span>pinks</span><span>,</span><span>pch</span><span>=</span><span>19</span><span>,</span><span>col</span><span>=</span><span>col2rgbt</span><span>(</span><span>&quot;black&quot;</span><span>,</span><span>1</span><span>/</span><span>2</span><span>))</span><span><br data-jekyll-commonmark-ghpages=""></span><span>lines</span><span>(</span><span>pR</span><span>~</span><span>x</span><span>,</span><span>lwd</span><span>=</span><span>2</span><span>)</span></code></pre>
</figure>
<p><img alt="plot of chunk RickerFit1" src="https://i2.wp.com/derekogle.com/fishR/figures/RickerFit1-1.png?w=456" data-recalc-dims="1"></p>
<p>These results can be modified to plot recruits per spawner versus spawners by replacing the “recruits” in the code above with “recruits per spawner.” This is simple for the actual data as <code>ret</code> is simply replaced with <code>retperesc</code>. However, the predicted number of recruits (in <code>pR</code>) and the confidence bounds (in <code>LCI</code> and <code>UCI</code>) from above must be divided by the number of spawners (in <code>x</code>). As the <code>/</code> symbol has a special meaning in R formulas, this division must be contained within <code>I()</code> as when it appears in a formula (see the <code>lines()</code> code below). Of course, the y-axis scale range must also be adjusted. Thus, a plot of recruits per spawner versus spawners is produced from the previous results with the following code.</p>
<figure>
<pre><code data-lang="r"><span>ylmts</span><span> </span><span>&lt;-</span><span> </span><span>c</span><span>(</span><span>0.7</span><span>,</span><span>7</span><span>)</span><span><br data-jekyll-commonmark-ghpages=""></span><span>plot</span><span>(</span><span>retperesc</span><span>~</span><span>esc</span><span>,</span><span>data</span><span>=</span><span>pinks</span><span>,</span><span><br data-jekyll-commonmark-ghpages=""> </span><span>xlim</span><span>=</span><span>xlmts</span><span>,</span><span>ylim</span><span>=</span><span>ylmts</span><span>,</span><span>col</span><span>=</span><span>&quot;white&quot;</span><span>,</span><span><br data-jekyll-commonmark-ghpages=""> </span><span>ylab</span><span>=</span><span>&quot;Returners/Escapement&quot;</span><span>,</span><span><br data-jekyll-commonmark-ghpages=""> </span><span>xlab</span><span>=</span><span>&quot;Escapement (millions)&quot;</span><span>)</span><span><br data-jekyll-commonmark-ghpages=""></span><span>polygon</span><span>(</span><span>c</span><span>(</span><span>x</span><span>,</span><span>rev</span><span>(</span><span>x</span><span>)),</span><span>c</span><span>(</span><span>LCI</span><span>/</span><span>x</span><span>,</span><span>rev</span><span>(</span><span>UCI</span><span>/</span><span>x</span><span>)),</span><span>col</span><span>=</span><span>&quot;gray80&quot;</span><span>,</span><span>border</span><span>=</span><span>NA</span><span>)</span><span><br data-jekyll-commonmark-ghpages=""></span><span>points</span><span>(</span><span>retperesc</span><span>~</span><span>esc</span><span>,</span><span>data</span><span>=</span><span>pinks</span><span>,</span><span>pch</span><span>=</span><span>19</span><span>,</span><span>col</span><span>=</span><span>col2rgbt</span><span>(</span><span>&quot;black&quot;</span><span>,</span><span>1</span><span>/</span><span>2</span><span>))</span><span><br data-jekyll-commonmark-ghpages=""></span><span>lines</span><span>(</span><span>I</span><span>(</span><span>pR</span><span>/</span><span>x</span><span>)</span><span>~</span><span>x</span><span>,</span><span>lwd</span><span>=</span><span>2</span><span>)</span></code></pre>
</figure>
<p><img alt="plot of chunk RickerFit2" src="https://i1.wp.com/derekogle.com/fishR/figures/RickerFit2-1.png?w=456" data-recalc-dims="1"></p>
<p>Alternatively, the Ricker stock-recruitment model could be reparameterized by dividing each side of the function by “spawners” such that the right-hand-side becomes “recruits per spawner” (this is a fairly typical reparameterization of the model). This model can be put into an R function, with model parameters then estimated with nonlinear regression similar to above. The results below show that the paramter point estimates are identical and the bootsrapped confidence intervals are similar to what was obtained above.</p>
<figure>
<pre><code data-lang="r"><span>rckr2</span><span> </span><span>&lt;-</span><span> </span><span>function</span><span>(</span><span>S</span><span>,</span><span>a</span><span>,</span><span>b</span><span>=</span><span>NULL</span><span>)</span><span> </span><span>{</span><span><br data-jekyll-commonmark-ghpages=""> </span><span>if</span><span> </span><span>(</span><span>length</span><span>(</span><span>a</span><span>)</span><span>></span><span>1</span><span>)</span><span> </span><span>{</span><span> </span><span>b</span><span> </span><span>&lt;-</span><span> </span><span>a</span><span>[[</span><span>2</span><span>]];</span><span> </span><span>a</span><span> </span><span>&lt;-</span><span> </span><span>a</span><span>[[</span><span>1</span><span>]]</span><span> </span><span>}</span><span><br data-jekyll-commonmark-ghpages=""> </span><span>a</span><span>*</span><span>exp</span><span>(</span><span>-</span><span>b</span><span>*</span><span>S</span><span>)</span><span><br data-jekyll-commonmark-ghpages=""></span><span>}</span><span><br data-jekyll-commonmark-ghpages=""></span><span>srR2</span><span> </span><span>&lt;-</span><span> </span><span>nls</span><span>(</span><span>logretperesc</span><span>~</span><span>log</span><span>(</span><span>rckr2</span><span>(</span><span>esc</span><span>,</span><span>a</span><span>,</span><span>b</span><span>)),</span><span>data</span><span>=</span><span>pinks</span><span>,</span><span>start</span><span>=</span><span>svR</span><span>)</span><span><br data-jekyll-commonmark-ghpages=""></span><span>bootR2</span><span> </span><span>&lt;-</span><span> </span><span>nlsBoot</span><span>(</span><span>srR2</span><span>)</span><span><br data-jekyll-commonmark-ghpages=""></span><span>cbind</span><span>(</span><span>estimates</span><span>=</span><span>coef</span><span>(</span><span>srR2</span><span>),</span><span>confint</span><span>(</span><span>bootR2</span><span>))</span></code></pre>
</figure>
<figure>
<pre><code data-lang="text">##    estimates     95% LCI   95% UCI<br data-jekyll-commonmark-ghpages="">## a 2.84924202  1.67734916 4.8613811<br data-jekyll-commonmark-ghpages="">## b 0.05516673 -0.08776123 0.2040402</code></pre>
</figure>
<p>With this, a second method for plotting recruits per spawner versus spawners is the same as how the main plot from the book was constructed but modified to use the results from this “new” model.</p>
<figure>
<pre><code data-lang="r"><span>x</span><span> </span><span>&lt;-</span><span> </span><span>seq</span><span>(</span><span>0</span><span>,</span><span>9</span><span>,</span><span>length.out</span><span>=</span><span>199</span><span>)</span><span> </span><span># many S for prediction</span><span><br data-jekyll-commonmark-ghpages=""></span><span>pRperS</span><span> </span><span>&lt;-</span><span> </span><span>rckr2</span><span>(</span><span>x</span><span>,</span><span>a</span><span>=</span><span>coef</span><span>(</span><span>srR2</span><span>))</span><span> </span><span># predicted mean RperS</span><span><br data-jekyll-commonmark-ghpages=""></span><span>LCI2</span><span> </span><span>&lt;-</span><span> </span><span>UCI2</span><span> </span><span>&lt;-</span><span> </span><span>numeric</span><span>(</span><span>length</span><span>(</span><span>x</span><span>))</span><span><br data-jekyll-commonmark-ghpages=""><br data-jekyll-commonmark-ghpages=""></span><span>for</span><span>(</span><span>i</span><span> </span><span>in</span><span> </span><span>1</span><span>:</span><span>length</span><span>(</span><span>x</span><span>))</span><span> </span><span>{</span><span> </span><span># CIs for mean RperS @ each S</span><span><br data-jekyll-commonmark-ghpages=""> </span><span>tmp</span><span> </span><span>&lt;-</span><span> </span><span>apply</span><span>(</span><span>bootR2</span><span>$</span><span>coefboot</span><span>,</span><span>MARGIN</span><span>=</span><span>1</span><span>,</span><span>FUN</span><span>=</span><span>rckr2</span><span>,</span><span>S</span><span>=</span><span>x</span><span>[</span><span>i</span><span>])</span><span><br data-jekyll-commonmark-ghpages=""> </span><span>LCI2</span><span>[</span><span>i</span><span>]</span><span> </span><span>&lt;-</span><span> </span><span>quantile</span><span>(</span><span>tmp</span><span>,</span><span>0.025</span><span>)</span><span><br data-jekyll-commonmark-ghpages=""> </span><span>UCI2</span><span>[</span><span>i</span><span>]</span><span> </span><span>&lt;-</span><span> </span><span>quantile</span><span>(</span><span>tmp</span><span>,</span><span>0.975</span><span>)</span><span><br data-jekyll-commonmark-ghpages=""></span><span>}</span><span><br data-jekyll-commonmark-ghpages=""></span><span>ylmts</span><span> </span><span>&lt;-</span><span> </span><span>range</span><span>(</span><span>c</span><span>(</span><span>pRperS</span><span>,</span><span>LCI2</span><span>,</span><span>UCI2</span><span>,</span><span>pinks</span><span>$</span><span>retperesc</span><span>))</span><span><br data-jekyll-commonmark-ghpages=""></span><span>xlmts</span><span> </span><span>&lt;-</span><span> </span><span>range</span><span>(</span><span>c</span><span>(</span><span>x</span><span>,</span><span>pinks</span><span>$</span><span>esc</span><span>))</span><span><br data-jekyll-commonmark-ghpages=""><br data-jekyll-commonmark-ghpages=""></span><span>plot</span><span>(</span><span>retperesc</span><span>~</span><span>esc</span><span>,</span><span>data</span><span>=</span><span>pinks</span><span>,</span><span>xlim</span><span>=</span><span>xlmts</span><span>,</span><span>ylim</span><span>=</span><span>ylmts</span><span>,</span><span>col</span><span>=</span><span>&quot;white&quot;</span><span>,</span><span><br data-jekyll-commonmark-ghpages=""> </span><span>ylab</span><span>=</span><span>&quot;Returners/Escapement&quot;</span><span>,</span><span><br data-jekyll-commonmark-ghpages=""> </span><span>xlab</span><span>=</span><span>&quot;Escapement (millions)&quot;</span><span>)</span><span><br data-jekyll-commonmark-ghpages=""></span><span>polygon</span><span>(</span><span>c</span><span>(</span><span>x</span><span>,</span><span>rev</span><span>(</span><span>x</span><span>)),</span><span>c</span><span>(</span><span>LCI2</span><span>,</span><span>rev</span><span>(</span><span>UCI2</span><span>)),</span><span>col</span><span>=</span><span>&quot;gray80&quot;</span><span>,</span><span>border</span><span>=</span><span>NA</span><span>)</span><span><br data-jekyll-commonmark-ghpages=""></span><span>points</span><span>(</span><span>retperesc</span><span>~</span><span>esc</span><span>,</span><span>data</span><span>=</span><span>pinks</span><span>,</span><span>pch</span><span>=</span><span>19</span><span>,</span><span>col</span><span>=</span><span>col2rgbt</span><span>(</span><span>&quot;black&quot;</span><span>,</span><span>1</span><span>/</span><span>2</span><span>))</span><span><br data-jekyll-commonmark-ghpages=""></span><span>lines</span><span>(</span><span>pRperS</span><span>~</span><span>x</span><span>,</span><span>lwd</span><span>=</span><span>2</span><span>)</span></code></pre>
</figure>
<p><img alt="plot of chunk RickerFit3" src="https://i2.wp.com/derekogle.com/fishR/figures/RickerFit3-1.png?w=456" data-recalc-dims="1"></p>
<p>The two methods described above for plotting recruits per spawner versuse spawners are identical for the best-fit curve and nearly identical for the confidence bounds (slight differences likely due to the randomness inherent in bootstrapping). Thus, the two methods produce nearly the same visual.</p>
<figure>
<pre><code data-lang="r"><span>plot</span><span>(</span><span>retperesc</span><span>~</span><span>esc</span><span>,</span><span>data</span><span>=</span><span>pinks</span><span>,</span><span>xlim</span><span>=</span><span>xlmts</span><span>,</span><span>ylim</span><span>=</span><span>ylmts</span><span>,</span><span>col</span><span>=</span><span>&quot;white&quot;</span><span>,</span><span><br data-jekyll-commonmark-ghpages=""> </span><span>ylab</span><span>=</span><span>&quot;Returners/Escapement&quot;</span><span>,</span><span><br data-jekyll-commonmark-ghpages=""> </span><span>xlab</span><span>=</span><span>&quot;Escapement (millions)&quot;</span><span>)</span><span><br data-jekyll-commonmark-ghpages=""></span><span>polygon</span><span>(</span><span>c</span><span>(</span><span>x</span><span>,</span><span>rev</span><span>(</span><span>x</span><span>)),</span><span>c</span><span>(</span><span>LCI</span><span>/</span><span>x</span><span>,</span><span>rev</span><span>(</span><span>UCI</span><span>/</span><span>x</span><span>)),</span><span>col</span><span>=</span><span>col2rgbt</span><span>(</span><span>&quot;red&quot;</span><span>,</span><span>1</span><span>/</span><span>5</span><span>),</span><span>border</span><span>=</span><span>NA</span><span>)</span><span><br data-jekyll-commonmark-ghpages=""></span><span>lines</span><span>(</span><span>I</span><span>(</span><span>pR</span><span>/</span><span>x</span><span>)</span><span>~</span><span>x</span><span>,</span><span>lwd</span><span>=</span><span>6</span><span>,</span><span>col</span><span>=</span><span>&quot;red&quot;</span><span>)</span><span><br data-jekyll-commonmark-ghpages=""></span><span>polygon</span><span>(</span><span>c</span><span>(</span><span>x</span><span>,</span><span>rev</span><span>(</span><span>x</span><span>)),</span><span>c</span><span>(</span><span>LCI2</span><span>,</span><span>rev</span><span>(</span><span>UCI2</span><span>)),</span><span>col</span><span>=</span><span>col2rgbt</span><span>(</span><span>&quot;blue&quot;</span><span>,</span><span>1</span><span>/</span><span>5</span><span>),</span><span>border</span><span>=</span><span>NA</span><span>)</span><span><br data-jekyll-commonmark-ghpages=""></span><span>lines</span><span>(</span><span>pRperS</span><span>~</span><span>x</span><span>,</span><span>lwd</span><span>=</span><span>2</span><span>,</span><span>col</span><span>=</span><span>&quot;blue&quot;</span><span>)</span><span><br data-jekyll-commonmark-ghpages=""></span><span>points</span><span>(</span><span>retperesc</span><span>~</span><span>esc</span><span>,</span><span>data</span><span>=</span><span>pinks</span><span>,</span><span>pch</span><span>=</span><span>19</span><span>,</span><span>col</span><span>=</span><span>col2rgbt</span><span>(</span><span>&quot;black&quot;</span><span>,</span><span>1</span><span>/</span><span>2</span><span>))</span></code></pre>
</figure>
<p><img alt="plot of chunk RickerFit4" src="https://i0.wp.com/derekogle.com/fishR/figures/RickerFit4-1.png?w=456" data-recalc-dims="1"></p>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://derekogle.com/fishR/2017-12-12-Stock-Recruitment-Graphing-Questions"> fishR Blog</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/nPtYeaaw0yk" height="1"></a></div>