<!-- Generated by pkgdown: do not edit by hand -->
<!DOCTYPE html>
<html lang="en">
  <head>
  <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Creates a function for a specific parameterization of a common stock-recruitment function . — stockRecruitment • FSA</title>

<!-- favicons -->
<link rel="icon" type="image/png" sizes="16x16" href="../favicon-16x16.png">
<link rel="icon" type="image/png" sizes="32x32" href="../favicon-32x32.png">
<link rel="apple-touch-icon" type="image/png" sizes="180x180" href="../apple-touch-icon.png" />
<link rel="apple-touch-icon" type="image/png" sizes="120x120" href="../apple-touch-icon-120x120.png" />
<link rel="apple-touch-icon" type="image/png" sizes="76x76" href="../apple-touch-icon-76x76.png" />
<link rel="apple-touch-icon" type="image/png" sizes="60x60" href="../apple-touch-icon-60x60.png" />

<!-- jquery -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
<!-- Bootstrap -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.4.0/spacelab/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous" />


<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha256-nuL8/2cJ5NDSSwnKD8VqreErSWHtnEP9E7AySL+1ev4=" crossorigin="anonymous"></script>

<!-- bootstrap-toc -->
<link rel="stylesheet" href="../bootstrap-toc.css">
<script src="../bootstrap-toc.js"></script>

<!-- Font Awesome icons -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/all.min.css" integrity="sha256-mmgLkCYLUQbXn0B1SRqzHar6dCnv9oZFPEC1g1cwlkk=" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/v4-shims.min.css" integrity="sha256-wZjR52fzng1pJHwx4aV2AO3yyTOXrcDW7jBpJtTwVxw=" crossorigin="anonymous" />

<!-- clipboard.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js" integrity="sha256-inc5kl9MA1hkeYUt+EC3BhlIgyp/2jDIyBLS6k3UxPI=" crossorigin="anonymous"></script>

<!-- headroom.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/headroom.min.js" integrity="sha256-AsUX4SJE1+yuDu5+mAVzJbuYNPHj/WroHuZ8Ir/CkE0=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/jQuery.headroom.min.js" integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4=" crossorigin="anonymous"></script>

<!-- pkgdown -->
<link href="../pkgdown.css" rel="stylesheet">
<script src="../pkgdown.js"></script>




<meta property="og:title" content="Creates a function for a specific parameterization of a common stock-recruitment function . — stockRecruitment" />
<meta property="og:description" content="Creates a function for a specific parameterization of a &amp;#8220;Beverton-Holt&amp;#8221;, &amp;#8220;Ricker&amp;#8221;,  &amp;#8220;Shepherd&amp;#8221;, or &amp;#8220;Saila-Lorda&amp;#8221; stock-recruitment function. Use srFunShow() to see the equations of each function." />
<meta property="og:image" content="http://derekogle.com/FSA/logo.png" />




<!-- mathjax -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script>

<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->



  </head>

  <body data-spy="scroll" data-target="#toc">
    <div class="container template-reference-topic">
      <header>
      <div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
  <div class="container">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <span class="navbar-brand">
        <a class="navbar-link" href="../index.html">FSA</a>
        <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.8.32.9000</span>
      </span>
    </div>

    <div id="navbar" class="navbar-collapse collapse">
      <ul class="nav navbar-nav">
        <li>
  <a href="../reference/index.html">Reference</a>
</li>
<li>
  <a href="../news/index.html">News</a>
</li>
      </ul>
      <ul class="nav navbar-nav navbar-right">
        <li>
  <a href="../index.html">
    <span class="fas fa-home fa-2x"></span>
     
  </a>
</li>
<li>
  <a href="https://github.com/droglenc/FSA">
    <span class="fas fa-github fa-2x"></span>
     
  </a>
</li>
      </ul>
      
    </div><!--/.nav-collapse -->
  </div><!--/.container -->
</div><!--/.navbar -->

      

      </header>

<div class="row">
  <div class="col-md-9 contents">
    <div class="page-header">
    <h1>Creates a function for a specific parameterization of a common stock-recruitment function .</h1>
    <small class="dont-index">Source: <a href='https://github.com/droglenc/FSA/blob/master/R/stockRecruitment.R'><code>R/stockRecruitment.R</code></a></small>
    <div class="hidden name"><code>stockRecruitment.Rd</code></div>
    </div>

    <div class="ref-description">
    <p>Creates a function for a specific parameterization of a &#8220;Beverton-Holt&#8221;, &#8220;Ricker&#8221;,  &#8220;Shepherd&#8221;, or &#8220;Saila-Lorda&#8221; stock-recruitment function. Use <code>srFunShow()</code> to see the equations of each function.</p>
    </div>

    <pre class="usage"><span class='fu'>srFuns</span><span class='op'>(</span>
  type <span class='op'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span><span class='op'>(</span><span class='st'>"BevertonHolt"</span>, <span class='st'>"Ricker"</span>, <span class='st'>"Shepherd"</span>, <span class='st'>"SailaLorda"</span>, <span class='st'>"independence"</span><span class='op'>)</span>,
  param <span class='op'>=</span> <span class='fl'>1</span>,
  simple <span class='op'>=</span> <span class='cn'>FALSE</span>,
  msg <span class='op'>=</span> <span class='cn'>FALSE</span>
<span class='op'>)</span>

<span class='fu'>srFunShow</span><span class='op'>(</span>
  type <span class='op'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span><span class='op'>(</span><span class='st'>"BevertonHolt"</span>, <span class='st'>"Ricker"</span>, <span class='st'>"Shepherd"</span>, <span class='st'>"SailaLorda"</span><span class='op'>)</span>,
  param <span class='op'>=</span> <span class='fl'>1</span>,
  plot <span class='op'>=</span> <span class='cn'>FALSE</span>,
  <span class='va'>...</span>
<span class='op'>)</span></pre>

    <h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2>
    <table class="ref-arguments">
    <colgroup><col class="name" /><col class="desc" /></colgroup>
    <tr>
      <th>type</th>
      <td><p>A string that indicates the type of stock-recruitment function.</p></td>
    </tr>
    <tr>
      <th>param</th>
      <td><p>A single numeric that indicates the parameterization of the stock-recruitment function.</p></td>
    </tr>
    <tr>
      <th>simple</th>
      <td><p>A logical that indicates whether the user should be allowed to send all parameter values in the first parameter argument (<code>=FALSE</code>; default) or whether all individual parameters must be specified (<code>=TRUE</code>).</p></td>
    </tr>
    <tr>
      <th>msg</th>
      <td><p>A logical that indicates whether a message about the function and parameter definitions should be output (<code>=TRUE</code>) or not (<code>=FALSE</code>; default).</p></td>
    </tr>
    <tr>
      <th>plot</th>
      <td><p>A logical that indicates whether the growth function expression should be shown as an equation in a simple plot.</p></td>
    </tr>
    <tr>
      <th>...</th>
      <td><p>Not implemented.</p></td>
    </tr>
    </table>

    <h2 class="hasAnchor" id="value"><a class="anchor" href="#value"></a>Value</h2>

    <p><code>srFuns</code> returns a function that can be used to predict recruitment given a vector of stock sizes and values for the function parameters. The result should be saved to an object that can then be used as a function name. When the resulting function is used, the parameters are ordered as shown when the definitions of the parameters are printed after the function is called (assuming that <code>msg=TRUE</code>). The values for both/all parameters can be included as a vector of length two/three in the first parameter argument. If <code>simple=FALSE</code> then the values for all parameters can be included as a vector in the first parameter argument. If <code>simple=TRUE</code> then all parameters must be declared individually in each function. The resulting function is somewhat easier to read when <code>simple=TRUE</code>.</p>
<p><code>srFunShow</code> returns an expression that can be use with <code><a href='https://rdrr.io/r/grDevices/plotmath.html'>plotmath</a></code> to show the function equation in a pretty format. See examples.</p>
    <h2 class="hasAnchor" id="ifar-chapter"><a class="anchor" href="#ifar-chapter"></a>IFAR Chapter</h2>

    <p>13-Recruitment.</p>
    <h2 class="hasAnchor" id="references"><a class="anchor" href="#references"></a>References</h2>

    <p>Ogle, D.H. 2016. <a href='http://derekogle.com/IFAR/'>Introductory Fisheries Analyses with R</a>. Chapman &amp; Hall/CRC, Boca Raton, FL.</p> 
<p>Beverton, R.J.H. and S.J. Holt. 1957. On the dynamics of exploited fish populations, Fisheries Investigations (Series 2), volume 19. United Kingdom Ministry of Agriculture and Fisheries, 533 pp.</p>
<p>Iles, T.C. 1994. A review of stock-recruitment relationships with reference to flatfish populations. Netherlands Journal of Sea Research 32:399-420.</p>
<p>Quinn II, T.J. and R.B. Deriso. 1999. Quantitative Fish Dynamics. Oxford University Press.</p>
<p>Ricker, W.E. 1954. Stock and recruitment. Journal of the Fisheries Research Board of Canada 11:559-623.</p>
<p>Ricker, W.E. 1975. Computation and interpretation of biological statistics of fish populations. Technical Report Bulletin 191, Bulletin of the Fisheries Research Board of Canada. [Was (is?) from http://www.dfo-mpo.gc.ca/Library/1485.pdf.]</p>
<p>Shepherd, J. 1982. A versatile new stock-recruitment relationship for fisheries and construction of sustainable yield curves. Journal du Conseil International pour l'Exploration de la Mar 40:67-75.</p>
    <h2 class="hasAnchor" id="see-also"><a class="anchor" href="#see-also"></a>See also</h2>

    <div class='dont-index'><p>See <code><a href='srStarts.html'>srStarts</a></code> for related functionality.</p></div>
    <h2 class="hasAnchor" id="author"><a class="anchor" href="#author"></a>Author</h2>

    <p>Derek H. Ogle, <a href='mailto:derek@derekogle.com'>derek@derekogle.com</a>, thanks to Gabor Grothendieck for a hint about using <code><a href='https://rdrr.io/r/base/get.html'>get()</a></code>.</p>

    <h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
    <pre class="examples"><div class='input'><span class='co'>## See the formulae</span>
<span class='co'>## Simple Examples</span>
<span class='co'># show what a message looks like with the function definition</span>
<span class='fu'>srFuns</span><span class='op'>(</span><span class='st'>"Ricker"</span>,msg<span class='op'>=</span><span class='cn'>TRUE</span><span class='op'>)</span>
</div><div class='output co'>#&gt; <span class='message'>You have chosen the first parameterization of the 'Ricker' S-R function.</span>
#&gt; <span class='message'></span>
#&gt; <span class='message'>  E[R|S] = a*S*exp(-b*S)</span>
#&gt; <span class='message'></span>
#&gt; <span class='message'>  where a = the density-independent slope near S=0.</span>
#&gt; <span class='message'>        b = density-dependent parameter.</span></div><div class='output co'>#&gt; function(S,a,b=NULL) {
#&gt;     if (length(a)&gt;1) { b &lt;- a[[2]]; a &lt;- a[[1]] }
#&gt;     a*S*exp(-b*S)
#&gt;   }
#&gt; &lt;bytecode: 0x000000001b49d7b8&gt;
#&gt; &lt;environment: 0x000000001cbb0f18&gt;</div><div class='input'>
<span class='co'># create some dummy stock data</span>
<span class='va'>stock</span> <span class='op'>&lt;-</span> <span class='fu'><a href='https://rdrr.io/r/base/seq.html'>seq</a></span><span class='op'>(</span><span class='fl'>0.01</span>,<span class='fl'>1000</span>,length.out<span class='op'>=</span><span class='fl'>199</span><span class='op'>)</span>

<span class='co'># Beverton-Holt #1 parameterization</span>
<span class='op'>(</span> <span class='va'>bh1</span> <span class='op'>&lt;-</span> <span class='fu'>srFuns</span><span class='op'>(</span><span class='op'>)</span> <span class='op'>)</span>
</div><div class='output co'>#&gt; function(S,a,b=NULL) {
#&gt;     if (length(a)&gt;1) { b &lt;- a[[2]]; a &lt;- a[[1]] }
#&gt;     a*S/(1+b*S)
#&gt;   }
#&gt; &lt;bytecode: 0x000000000a920c18&gt;
#&gt; &lt;environment: 0x000000001c84f798&gt;</div><div class='input'><span class='fu'><a href='https://rdrr.io/r/graphics/plot.default.html'>plot</a></span><span class='op'>(</span><span class='fu'>bh1</span><span class='op'>(</span><span class='va'>stock</span>,a<span class='op'>=</span><span class='fl'>0.5</span>,b<span class='op'>=</span><span class='fl'>0.01</span><span class='op'>)</span><span class='op'>~</span><span class='va'>stock</span>,type<span class='op'>=</span><span class='st'>"l"</span>,lwd<span class='op'>=</span><span class='fl'>2</span>,ylab<span class='op'>=</span><span class='st'>"Recruits"</span>,xlab<span class='op'>=</span><span class='st'>"Spawners"</span>,ylim<span class='op'>=</span><span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span><span class='op'>(</span><span class='fl'>0</span>,<span class='fl'>50</span><span class='op'>)</span><span class='op'>)</span>
</div><div class='input'>
<span class='co'># Ricker #1 parameterization</span>
<span class='op'>(</span> <span class='va'>r1</span> <span class='op'>&lt;-</span> <span class='fu'>srFuns</span><span class='op'>(</span><span class='st'>"Ricker"</span><span class='op'>)</span> <span class='op'>)</span>
</div><div class='output co'>#&gt; function(S,a,b=NULL) {
#&gt;     if (length(a)&gt;1) { b &lt;- a[[2]]; a &lt;- a[[1]] }
#&gt;     a*S*exp(-b*S)
#&gt;   }
#&gt; &lt;bytecode: 0x000000001b49d7b8&gt;
#&gt; &lt;environment: 0x000000001c3f26c0&gt;</div><div class='input'><span class='fu'><a href='https://rdrr.io/r/graphics/lines.html'>lines</a></span><span class='op'>(</span><span class='fu'>r1</span><span class='op'>(</span><span class='va'>stock</span>,a<span class='op'>=</span><span class='fl'>0.5</span>,b<span class='op'>=</span><span class='fl'>0.005</span><span class='op'>)</span><span class='op'>~</span><span class='va'>stock</span>,lwd<span class='op'>=</span><span class='fl'>2</span>,col<span class='op'>=</span><span class='st'>"red"</span><span class='op'>)</span>
</div><div class='input'>
<span class='co'># Shephered parameterization</span>
<span class='op'>(</span> <span class='va'>s1</span> <span class='op'>&lt;-</span> <span class='fu'>srFuns</span><span class='op'>(</span><span class='st'>"Shepherd"</span><span class='op'>)</span> <span class='op'>)</span>
</div><div class='output co'>#&gt; function(S,a,b=NULL,c=NULL) {
#&gt;     if (length(a)&gt;1) { c &lt;- a[[3]]; b &lt;- a[[2]]; a &lt;- a[[1]] }
#&gt;     a*S/(1+(b*S)^c)
#&gt;   }
#&gt; &lt;bytecode: 0x000000000a8fc9b8&gt;
#&gt; &lt;environment: 0x000000001b9b4e88&gt;</div><div class='input'><span class='fu'><a href='https://rdrr.io/r/graphics/lines.html'>lines</a></span><span class='op'>(</span><span class='fu'>s1</span><span class='op'>(</span><span class='va'>stock</span>,a<span class='op'>=</span><span class='fl'>0.5</span>,b<span class='op'>=</span><span class='fl'>0.005</span>,c<span class='op'>=</span><span class='fl'>2.5</span><span class='op'>)</span><span class='op'>~</span><span class='va'>stock</span>,lwd<span class='op'>=</span><span class='fl'>2</span>,col<span class='op'>=</span><span class='st'>"blue"</span><span class='op'>)</span>
</div><div class='input'>
<span class='co'># Saila-Lorda parameterization</span>
<span class='op'>(</span> <span class='va'>sl1</span> <span class='op'>&lt;-</span> <span class='fu'>srFuns</span><span class='op'>(</span><span class='st'>"SailaLorda"</span><span class='op'>)</span> <span class='op'>)</span>
</div><div class='output co'>#&gt; function(S,a,b=NULL,c=NULL) {
#&gt;     if (length(a)&gt;1) { c &lt;- a[[3]]; b &lt;- a[[2]]; a &lt;- a[[1]] }
#&gt;     a*(S^c)*exp(-b*S)
#&gt;   }
#&gt; &lt;bytecode: 0x00000000222bf958&gt;
#&gt; &lt;environment: 0x000000001b3c75f8&gt;</div><div class='input'><span class='fu'><a href='https://rdrr.io/r/graphics/lines.html'>lines</a></span><span class='op'>(</span><span class='fu'>sl1</span><span class='op'>(</span><span class='va'>stock</span>,a<span class='op'>=</span><span class='fl'>0.5</span>,b<span class='op'>=</span><span class='fl'>0.005</span>,c<span class='op'>=</span><span class='fl'>1.05</span><span class='op'>)</span><span class='op'>~</span><span class='va'>stock</span>,lwd<span class='op'>=</span><span class='fl'>2</span>,col<span class='op'>=</span><span class='st'>"salmon"</span><span class='op'>)</span>
</div><div class='img'><img src='stockRecruitment-1.png' alt='' width='700' height='433' /></div><div class='input'>
<span class='co'>## Examples of fitting stock-recruitment functions</span>
<span class='co'># Fitting the Beverton-Holt #1 parameterization with multiplicative errors</span>
<span class='va'>bh1s</span> <span class='op'>&lt;-</span> <span class='fu'><a href='srStarts.html'>srStarts</a></span><span class='op'>(</span><span class='va'>recruits</span><span class='op'>~</span><span class='va'>stock</span>,data<span class='op'>=</span><span class='va'>CodNorwegian</span><span class='op'>)</span>
<span class='va'>fit1</span> <span class='op'>&lt;-</span> <span class='fu'><a href='https://rdrr.io/r/stats/nls.html'>nls</a></span><span class='op'>(</span><span class='fu'><a href='https://rdrr.io/r/base/Log.html'>log</a></span><span class='op'>(</span><span class='va'>recruits</span><span class='op'>)</span><span class='op'>~</span><span class='fu'><a href='https://rdrr.io/r/base/Log.html'>log</a></span><span class='op'>(</span><span class='fu'>bh1</span><span class='op'>(</span><span class='va'>stock</span>,<span class='va'>a</span>,<span class='va'>b</span><span class='op'>)</span><span class='op'>)</span>,data<span class='op'>=</span><span class='va'>CodNorwegian</span>,start<span class='op'>=</span><span class='va'>bh1s</span><span class='op'>)</span>
<span class='fu'><a href='https://rdrr.io/r/base/summary.html'>summary</a></span><span class='op'>(</span><span class='va'>fit1</span>,correlation<span class='op'>=</span><span class='cn'>TRUE</span><span class='op'>)</span>
</div><div class='output co'>#&gt; 
#&gt; Formula: log(recruits) ~ log(bh1(stock, a, b))
#&gt; 
#&gt; Parameters:
#&gt;   Estimate Std. Error t value Pr(&gt;|t|)
#&gt; a  37.3342   132.0150   0.283     0.78
#&gt; b   0.4876     1.8099   0.269     0.79
#&gt; 
#&gt; Residual standard error: 0.7486 on 22 degrees of freedom
#&gt; 
#&gt; Correlation of Parameter Estimates:
#&gt;   a   
#&gt; b 1.00
#&gt; 
#&gt; Number of iterations to convergence: 6 
#&gt; Achieved convergence tolerance: 7.103e-06
#&gt; </div><div class='input'><span class='fu'><a href='https://rdrr.io/r/graphics/plot.default.html'>plot</a></span><span class='op'>(</span><span class='va'>recruits</span><span class='op'>~</span><span class='va'>stock</span>,data<span class='op'>=</span><span class='va'>CodNorwegian</span>,pch<span class='op'>=</span><span class='fl'>19</span>,xlim<span class='op'>=</span><span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span><span class='op'>(</span><span class='fl'>0</span>,<span class='fl'>200</span><span class='op'>)</span><span class='op'>)</span>
</div><div class='input'><span class='fu'><a href='https://rdrr.io/r/graphics/curve.html'>curve</a></span><span class='op'>(</span><span class='fu'>bh1</span><span class='op'>(</span><span class='va'>x</span>,a<span class='op'>=</span><span class='fu'><a href='https://rdrr.io/r/stats/coef.html'>coef</a></span><span class='op'>(</span><span class='va'>fit1</span><span class='op'>)</span><span class='op'>[</span><span class='fl'>1</span><span class='op'>]</span>,b<span class='op'>=</span><span class='fu'><a href='https://rdrr.io/r/stats/coef.html'>coef</a></span><span class='op'>(</span><span class='va'>fit1</span><span class='op'>)</span><span class='op'>[</span><span class='fl'>2</span><span class='op'>]</span><span class='op'>)</span>,from<span class='op'>=</span><span class='fl'>0</span>,to<span class='op'>=</span><span class='fl'>200</span>,col<span class='op'>=</span><span class='st'>"red"</span>,lwd<span class='op'>=</span><span class='fl'>3</span>,add<span class='op'>=</span><span class='cn'>TRUE</span><span class='op'>)</span>
</div><div class='input'>
<span class='co'># Fitting the Ricker #3 parameterization with multiplicative errors</span>
<span class='va'>r3</span> <span class='op'>&lt;-</span> <span class='fu'>srFuns</span><span class='op'>(</span><span class='st'>"Ricker"</span>,param<span class='op'>=</span><span class='fl'>3</span><span class='op'>)</span>
<span class='va'>r3s</span> <span class='op'>&lt;-</span> <span class='fu'><a href='srStarts.html'>srStarts</a></span><span class='op'>(</span><span class='va'>recruits</span><span class='op'>~</span><span class='va'>stock</span>,data<span class='op'>=</span><span class='va'>CodNorwegian</span>,type<span class='op'>=</span><span class='st'>"Ricker"</span>,param<span class='op'>=</span><span class='fl'>3</span><span class='op'>)</span>
<span class='va'>fit2</span> <span class='op'>&lt;-</span> <span class='fu'><a href='https://rdrr.io/r/stats/nls.html'>nls</a></span><span class='op'>(</span><span class='fu'><a href='https://rdrr.io/r/base/Log.html'>log</a></span><span class='op'>(</span><span class='va'>recruits</span><span class='op'>)</span><span class='op'>~</span><span class='fu'><a href='https://rdrr.io/r/base/Log.html'>log</a></span><span class='op'>(</span><span class='fu'>r3</span><span class='op'>(</span><span class='va'>stock</span>,<span class='va'>a</span>,<span class='va'>Rp</span><span class='op'>)</span><span class='op'>)</span>,data<span class='op'>=</span><span class='va'>CodNorwegian</span>,start<span class='op'>=</span><span class='va'>r3s</span><span class='op'>)</span>
<span class='fu'><a href='https://rdrr.io/r/base/summary.html'>summary</a></span><span class='op'>(</span><span class='va'>fit2</span>,correlation<span class='op'>=</span><span class='cn'>TRUE</span><span class='op'>)</span>
</div><div class='output co'>#&gt; 
#&gt; Formula: log(recruits) ~ log(r3(stock, a, Rp))
#&gt; 
#&gt; Parameters:
#&gt;    Estimate Std. Error t value Pr(&gt;|t|)    
#&gt; a     5.919      1.246   4.751 9.64e-05 ***
#&gt; Rp  118.597     16.102   7.365 2.26e-07 ***
#&gt; ---
#&gt; Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#&gt; 
#&gt; Residual standard error: 0.5866 on 22 degrees of freedom
#&gt; 
#&gt; Correlation of Parameter Estimates:
#&gt;    a   
#&gt; Rp 0.89
#&gt; 
#&gt; Number of iterations to convergence: 0 
#&gt; Achieved convergence tolerance: 1.391e-08
#&gt; </div><div class='input'><span class='fu'><a href='https://rdrr.io/r/graphics/curve.html'>curve</a></span><span class='op'>(</span><span class='fu'>r3</span><span class='op'>(</span><span class='va'>x</span>,a<span class='op'>=</span><span class='fu'><a href='https://rdrr.io/r/stats/coef.html'>coef</a></span><span class='op'>(</span><span class='va'>fit2</span><span class='op'>)</span><span class='op'>[</span><span class='fl'>1</span><span class='op'>]</span>,Rp<span class='op'>=</span><span class='fu'><a href='https://rdrr.io/r/stats/coef.html'>coef</a></span><span class='op'>(</span><span class='va'>fit2</span><span class='op'>)</span><span class='op'>[</span><span class='fl'>2</span><span class='op'>]</span><span class='op'>)</span>,from<span class='op'>=</span><span class='fl'>0</span>,to<span class='op'>=</span><span class='fl'>200</span>,col<span class='op'>=</span><span class='st'>"blue"</span>,lwd<span class='op'>=</span><span class='fl'>3</span>,add<span class='op'>=</span><span class='cn'>TRUE</span><span class='op'>)</span>
</div><div class='img'><img src='stockRecruitment-2.png' alt='' width='700' height='433' /></div><div class='input'>
<span class='co'>#############################################################################</span>
<span class='co'>## Create expressions of the functions</span>
<span class='co'>#############################################################################</span>
<span class='co'># Simple example</span>
<span class='fu'>srFunShow</span><span class='op'>(</span><span class='op'>)</span>
</div><div class='output co'>#&gt; expression(R == frac(aS, 1 + bS))</div><div class='input'><span class='fu'>srFunShow</span><span class='op'>(</span>plot<span class='op'>=</span><span class='cn'>TRUE</span><span class='op'>)</span>
</div><div class='output co'>#&gt; expression(R == frac(aS, 1 + bS))</div><div class='input'><span class='fu'>srFunShow</span><span class='op'>(</span><span class='st'>"BevertonHolt"</span>,<span class='fl'>1</span>,plot<span class='op'>=</span><span class='cn'>TRUE</span><span class='op'>)</span>
</div><div class='img'><img src='stockRecruitment-3.png' alt='' width='700' height='433' /></div><div class='output co'>#&gt; expression(R == frac(aS, 1 + bS))</div><div class='input'>
<span class='co'># Get and save the expression</span>
<span class='op'>(</span> <span class='va'>tmp</span> <span class='op'>&lt;-</span> <span class='fu'>srFunShow</span><span class='op'>(</span><span class='st'>"BevertonHolt"</span>,<span class='fl'>1</span><span class='op'>)</span> <span class='op'>)</span>
</div><div class='output co'>#&gt; expression(R == frac(aS, 1 + bS))</div><div class='input'><span class='co'># Use expression as title on a plot</span>
<span class='fu'><a href='https://rdrr.io/r/graphics/plot.default.html'>plot</a></span><span class='op'>(</span><span class='fu'>bh1</span><span class='op'>(</span><span class='va'>stock</span>,a<span class='op'>=</span><span class='fl'>0.5</span>,b<span class='op'>=</span><span class='fl'>0.01</span><span class='op'>)</span><span class='op'>~</span><span class='va'>stock</span>,type<span class='op'>=</span><span class='st'>"l"</span>,ylim<span class='op'>=</span><span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span><span class='op'>(</span><span class='fl'>0</span>,<span class='fl'>50</span><span class='op'>)</span>,
     ylab<span class='op'>=</span><span class='st'>"Recruits"</span>,xlab<span class='op'>=</span><span class='st'>"Spawners"</span>,main<span class='op'>=</span><span class='va'>tmp</span><span class='op'>)</span>
</div><div class='input'><span class='co'># Put expression in the main plot</span>
<span class='fu'><a href='https://rdrr.io/r/graphics/text.html'>text</a></span><span class='op'>(</span><span class='fl'>800</span>,<span class='fl'>10</span>,<span class='va'>tmp</span><span class='op'>)</span>
</div><div class='img'><img src='stockRecruitment-4.png' alt='' width='700' height='433' /></div><div class='input'><span class='co'># Put multiple expressions on a plot</span>
<span class='va'>op</span> <span class='op'>&lt;-</span> <span class='fu'><a href='https://rdrr.io/r/graphics/par.html'>par</a></span><span class='op'>(</span>mar<span class='op'>=</span><span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span><span class='op'>(</span><span class='fl'>0.1</span>,<span class='fl'>0.1</span>,<span class='fl'>0.1</span>,<span class='fl'>0.1</span><span class='op'>)</span><span class='op'>)</span>
<span class='fu'><a href='https://rdrr.io/r/graphics/plot.default.html'>plot</a></span><span class='op'>(</span><span class='fl'>0</span>,type<span class='op'>=</span><span class='st'>"n"</span>,xlab<span class='op'>=</span><span class='st'>""</span>,ylab<span class='op'>=</span><span class='st'>""</span>,xlim<span class='op'>=</span><span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span><span class='op'>(</span><span class='fl'>0</span>,<span class='fl'>1</span><span class='op'>)</span>,ylim<span class='op'>=</span><span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span><span class='op'>(</span><span class='fl'>0</span>,<span class='fl'>3</span><span class='op'>)</span>,xaxt<span class='op'>=</span><span class='st'>"n"</span>,yaxt<span class='op'>=</span><span class='st'>"n"</span><span class='op'>)</span>
</div><div class='input'><span class='fu'><a href='https://rdrr.io/r/graphics/text.html'>text</a></span><span class='op'>(</span><span class='fl'>0</span>,<span class='fl'>2.5</span>,<span class='st'>"Beverton-Holt #1:"</span>,pos<span class='op'>=</span><span class='fl'>4</span><span class='op'>)</span>
</div><div class='input'><span class='fu'><a href='https://rdrr.io/r/graphics/text.html'>text</a></span><span class='op'>(</span><span class='fl'>0.5</span>,<span class='fl'>2.5</span>,<span class='fu'>srFunShow</span><span class='op'>(</span><span class='st'>"BevertonHolt"</span>,<span class='fl'>1</span><span class='op'>)</span><span class='op'>)</span>
</div><div class='input'><span class='fu'><a href='https://rdrr.io/r/graphics/text.html'>text</a></span><span class='op'>(</span><span class='fl'>0</span>,<span class='fl'>1.5</span>,<span class='st'>"Ricker #2:"</span>,pos<span class='op'>=</span><span class='fl'>4</span><span class='op'>)</span>
</div><div class='input'><span class='fu'><a href='https://rdrr.io/r/graphics/text.html'>text</a></span><span class='op'>(</span><span class='fl'>0.5</span>,<span class='fl'>1.5</span>,<span class='fu'>srFunShow</span><span class='op'>(</span><span class='st'>"Ricker"</span>,<span class='fl'>2</span><span class='op'>)</span><span class='op'>)</span>
</div><div class='input'><span class='fu'><a href='https://rdrr.io/r/graphics/text.html'>text</a></span><span class='op'>(</span><span class='fl'>0</span>,<span class='fl'>0.5</span>,<span class='st'>"Shepherd:"</span>,pos<span class='op'>=</span><span class='fl'>4</span><span class='op'>)</span>
</div><div class='input'><span class='fu'><a href='https://rdrr.io/r/graphics/text.html'>text</a></span><span class='op'>(</span><span class='fl'>0.5</span>,<span class='fl'>0.5</span>,<span class='fu'>srFunShow</span><span class='op'>(</span><span class='st'>"Shepherd"</span><span class='op'>)</span><span class='op'>)</span>
</div><div class='img'><img src='stockRecruitment-5.png' alt='' width='700' height='433' /></div><div class='input'><span class='fu'><a href='https://rdrr.io/r/graphics/par.html'>par</a></span><span class='op'>(</span><span class='va'>op</span><span class='op'>)</span>
</div></pre>
  </div>
  <div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">
    <nav id="toc" data-toggle="toc" class="sticky-top">
      <h2 data-toc-skip>Contents</h2>
    </nav>
  </div>
</div>


      <footer>
      <div class="copyright">
  <p>Developed by Derek Ogle, Jason Doll, Powell Wheeler, Alexis Dinno.</p>
</div>

<div class="pkgdown">
  <p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.6.1.</p>
</div>

      </footer>
   </div>

  


  </body>
</html>


