<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";
        color:black;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";
        color:black;}
span.EmailStyle17
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:Consolas;
        color:black;}
span.EmailStyle20
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body bgcolor="white" lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="color:#1F497D">Thanks Dave,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">We will probably use a reparameterization like this when we do the analysis. Right now I am trying to get the function coding structure sorted out before I write too much code.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">If you have a growth curve that is quite linear for the first few ages and then bends over quickly, that would be useful. We have been applying the Richards curve, but I think we might need to do better. The
 issue is that the asymptotic length is quite important when fitting to length composition data, but we often don’t have much age (or tagging) data for old fish. So, the asymptotic length is controlled by the shape of the growth curve and the fit to the young
 and intermediate aged fish. <o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">Regards,  <o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">Mark <o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext"> dave fournier [mailto:davef@otter-rsch.com]
<br>
<b>Sent:</b> Friday, June 27, 2014 11:11 AM<br>
<b>To:</b> Mark Maunder; developers@admb-project.org<br>
<b>Cc:</b> Alexandre Aires-Da-Silva; Carolina Minte-Vera<br>
<b>Subject:</b> Re: [Developers] Template functions and documentation<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">On 06/27/2014 11:04 AM, Mark Maunder wrote:<br>
<br>
Its hard to believe that Schnute and I figured out how to do this properly almost 34 years ago<br>
using punch cards on a machine with 18K user memory.  Someone really should figure out how to teach<br>
people the importance of parameterizing nonlinear models in a stable fashion.<br>
<br>
      <br>
<br>
<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal">Hi developers,<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">I am in the process or putting together a model that will be used to evaluate several growth equations so I thought I better try to use the ADMB project “approved” approach for writing the functions. Below is a template function and documentation
 for the von Bertalanffy growth equation. I would appreciate any advice on doing this “correctly”.<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">Thanks,<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">Mark<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">/**<o:p></o:p></p>
<p class="MsoNormal">\defgroup CONTRIB Contributed libraries<o:p></o:p></p>
<p class="MsoNormal">*/<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">/**<o:p></o:p></p>
<p class="MsoNormal">\ingroup CONTRIB <o:p></o:p></p>
<p class="MsoNormal">\defgroup CAPAM CAPAM created functions<o:p></o:p></p>
<p class="MsoNormal">*/<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">#include <admodel.h><o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">/**  von Bertalanffy growth equation; constant objects.<o:p></o:p></p>
<p class="MsoNormal">  \ingroup CAPAM<o:p></o:p></p>
<p class="MsoNormal">  \brief Calculate the length from a given age based on the von Bertalanffy equation. Written by Mark Maunder.<o:p></o:p></p>
<p class="MsoNormal">  \param age age of individual, \f$a\f$.<o:p></o:p></p>
<p class="MsoNormal">  \param Linf asymptotic length, \f$L_inf\f$.<o:p></o:p></p>
<p class="MsoNormal">  \param K growth rate, \f$K\f$.<o:p></o:p></p>
<p class="MsoNormal">  \param t0 age at zero length, \f$t_0\f$.<o:p></o:p></p>
<p class="MsoNormal">  \return length predicted length of individual. \f$L_inf*(1-exp(-K*(a-t0)))\f$.<o:p></o:p></p>
<p class="MsoNormal">  */<o:p></o:p></p>
<p class="MsoNormal">   <o:p></o:p></p>
<p class="MsoNormal">template <typename type1, typename type1> <o:p></o:p></p>
<p class="MsoNormal">//can have multiple types so that they are used below in variable definitions, they can differ between function calls, but remain the same within a function call
<o:p></o:p></p>
<p class="MsoNormal">//type1 is probably a long<o:p></o:p></p>
<p class="MsoNormal">//type2 is probably a dvariable (either a model parameter (Linf K t0) or a derived variable (length))
<o:p></o:p></p>
<p class="MsoNormal">//may need a type3, which is a dvar_vector if age and length are vectors, where type 1 will be a vector<o:p></o:p></p>
<p class="MsoNormal">type1 vonB(const type1 &age, const type2 &Linf, const type2 &K, const type2 &t0)<o:p></o:p></p>
<p class="MsoNormal">{<o:p></o:p></p>
<p class="MsoNormal">  type2 length = Linf*(1.-mfexp(-K*(age-t0)));<o:p></o:p></p>
<p class="MsoNormal">  return (length);<o:p></o:p></p>
<p class="MsoNormal">}  <o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">//is length a bad word to use<o:p></o:p></p>
<p class="MsoNormal">//do we use ingroup for both groups and subgroups in doxygen documentation<o:p></o:p></p>
<p class="MsoNormal">//should we use mfexp?<o:p></o:p></p>
<p class="MsoNormal">//what if age and length are vectors, but age is a vector and length is a dvar_vector, do we need to overload the type with one with three variable types<o:p></o:p></p>
<p class="MsoNormal">//I couldn't work out how to put in the detailed description<o:p></o:p></p>
<p class="MsoNormal">//The equations did not work on my computer <o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman","serif""><br>
<br>
<br>
<o:p></o:p></span></p>
<pre>_______________________________________________<o:p></o:p></pre>
<pre>Developers mailing list<o:p></o:p></pre>
<pre><a href="mailto:Developers@admb-project.org">Developers@admb-project.org</a><o:p></o:p></pre>
<pre><a href="http://lists.admb-project.org/mailman/listinfo/developers">http://lists.admb-project.org/mailman/listinfo/developers</a><o:p></o:p></pre>
</blockquote>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman","serif""><o:p> </o:p></span></p>
</div>
</body>
</html>