Skip to content

Commit

Permalink
Change instances of log to natural log or ln (#244)
Browse files Browse the repository at this point in the history
* change instances of log to natural log or ln
* Add log to a glossary separate from list of acronyms
  • Loading branch information
e-perl-NOAA authored Aug 15, 2024
1 parent 7204d9b commit 38ec129
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 29 deletions.
2 changes: 1 addition & 1 deletion 12runningSS3.tex
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@

The optimizer in \gls{admb} is designed to run until the maximum absolute gradient (mag) is small enough (e.g., 1e-05), after which it quits and does the uncertainty calculations. But if run for longer it cannot appreciably decrease this mag. In many cases it is interesting or advisable to get closer to the mode to confirm convergence of the model.

A new feature as of \gls{admb} 12.3 called ``-hess\_step'' takes Newton steps to update the \gls{mle} using the information in the Hessian calculated as MLE\textsubscript{new} = MLE-(inverse~Hessian)*(gradient), where the Hessian and gradient are calculated from the original \gls{mle}. If the mag improves then this corroborates the optimizer has converged and that the negative log-likelihood surface is approximately quadratic at the mode as assumed in the asymptotic uncertainty calculations. The downside is the high computational cost due to the extra matrix calculations.
A new feature as of \gls{admb} 12.3 called ``-hess\_step'' takes Newton steps to update the \gls{mle} using the information in the Hessian calculated as MLE\textsubscript{new} = MLE-(inverse~Hessian)*(gradient), where the Hessian and gradient are calculated from the original \gls{mle}. If the mag improves then this corroborates the optimizer has converged and that the negative log likelihood surface is approximately quadratic at the mode as assumed in the asymptotic uncertainty calculations. The downside is the high computational cost due to the extra matrix calculations.

The feature is used by optimizing normally, and then from the command line running \texttt{-hess\_step} for defaults (recommended), \texttt{-hess\_step N}, or \texttt{-hess\_step\_tol eps} where N and eps are the maximum number of steps to take and the tolerance (i.e., a very small number like 1e-10) after which to stop. When running the Hessian first and then the \texttt{-hess\_step}, \gls{admb} will prompt you to run it with -binp \texttt{ss.bar}.

Expand Down
2 changes: 1 addition & 1 deletion 13output.tex
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
\endhead

1 & DEFINITIONS & Split into variables: \$nseasons, \$seasfracs, \$seasdurations, and \$FleetNames & List of definitions (e.g., fleet names, model start year) assigned in the data and control files. \Bstrut\\
2 & LIKELIHOOD & \$likelihoods\_used and \$likelihoods\_by\_fleet & Final values of the negative log(likelihood) are presented. \Bstrut\\
2 & LIKELIHOOD & \$likelihoods\_used and \$likelihoods\_by\_fleet & Final values of the negative log likelihood are presented. \Bstrut\\
3 & Input\_Variance\_Adjustment & NA & The matrix of input variance adjustments is output here because these values affect the log likelihood calculations. \Bstrut\\
4 & Parm\_devs\_detail & \$Parm\_devs\_detail & \multirow{1}{1cm}[-0.25cm]{\parbox{9.5cm}{Details about parameter deviations, if used in the model. Will be missing if no parameter deviations were used. Shows controlling parameters \gls{sd} and Rho as well as statistics of time series of deviations. The statistics include the mean, \gls{rmse}, var, est\_rho (estimated autocorrelation), and D-W (Durbin-Watson) statistic.}} \Bstrut\\
& \textit{Parameter deviations detail} & & \\
Expand Down
4 changes: 2 additions & 2 deletions 15special.tex
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,9 @@

\begin{figure}[ht]
\begin{center}
\includegraphics[alt={The shape of the symmetric beta prior across alternative standard deviation values and the change in the negative log-likelihood.},scale = 0.6]{SymetricBeta}\\
\includegraphics[alt={The shape of the symmetric beta prior across alternative standard deviation values and the change in the negative log likelihood.},scale = 0.6]{SymetricBeta}\\
\end{center}
\caption{The shape of the symmetric beta prior across alternative standard deviation values and the change in the negative log-likelihood.}
\caption{The shape of the symmetric beta prior across alternative standard deviation values and the change in the negative log likelihood.}
\end{figure}


Expand Down
6 changes: 3 additions & 3 deletions 6starter.tex
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@
& 4 = $X*B_{endyr}$. & Relative to spawning biomass in the model end year. \\
& 5 = $X*Dynamic~B_{0}$ & Relative to the calculated dynamic $B_{0}$. \\
& use tens and hundreds digits to invoke multi-year trailing average & \\
& append 0.1 to invoke log(ratio) & \Bstrut\\
& append 0.1 to invoke ln(ratio) & \Bstrut\\

\hline
1.0 & Fraction (X) for depletion denominator & Value for use in the calculation of the ratio for $SB_{y}/(X*SB_{0})$. \Tstrut\Bstrut\\
Expand Down Expand Up @@ -257,13 +257,13 @@

\hline
% \pagebreak
1 & $F\text{\_std}$ scaling: & \multirow{1}{1cm}[-0.25cm]{\parbox{12.5cm}{$F\text{\_std}$ is typically reported as a ratio to the value of an equivalent $F$ calculation that would occur at the benchmark level of fishing. Here the user selects the denominator for that ratio. This ratio can be presented as a multi-year trailing average in $F$ or as a log(ratio). For example, 122.1 would do a 12-year trailing average of the ratio using $F_{MSY}$ and present the result as the log(ratio).}} \Tstrut\\
1 & $F\text{\_std}$ scaling: & \multirow{1}{1cm}[-0.25cm]{\parbox{12.5cm}{$F\text{\_std}$ is typically reported as a ratio to the value of an equivalent $F$ calculation that would occur at the benchmark level of fishing. Here the user selects the denominator for that ratio. This ratio can be presented as a multi-year trailing average in $F$ or as a ln(ratio). For example, 122.1 would do a 12-year trailing average of the ratio using $F_{MSY}$ and present the result as the ln(ratio).}} \Tstrut\\
& 0 = not relative, report raw values; & \\
& 1 = use $F\text{\_std}$ value relative to $SPR_{TARGET}$; & \\
& 2 = use $F\text{\_std}$ value relative to $F_{MSY}$; and & \\
& 3 = use $F\text{\_std}$ value relative to $F_{B_{TARGET}}$. & \\
& use tens and hundreds digits to invoke multi-year averaged $F\text{\_std}$ & \\
& append 0.1 to the integer to invoke log(ratio) & \Bstrut\\
& append 0.1 to the integer to invoke ln(ratio) & \Bstrut\\

% \hline
\pagebreak
Expand Down
2 changes: 1 addition & 1 deletion 7forecast.tex
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@

%\pagebreak
\hline
0 \Tstrut & Implementation Error & \multirow{1}{1cm}[-0.2cm]{\parbox{12cm}{The standard deviation of the log of the ratio between the realized catch and the target catch in the forecast. (set value > 0.0 to cause implementation error deviations to be an estimated parameter that will add variance to forecast).}} \Bstrut\\
0 \Tstrut & Implementation Error & \multirow{1}{1cm}[-0.2cm]{\parbox{12cm}{The standard deviation of the natural log of the ratio between the realized catch and the target catch in the forecast. (set value > 0.0 to cause implementation error deviations to be an estimated parameter that will add variance to forecast).}} \Bstrut\\
& & \Bstrut\\
& & \Bstrut\\

Expand Down
12 changes: 6 additions & 6 deletions 8data.tex
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@
\item 1 = biomass;
\item 2 = $F$; and
\begin{itemize}
\item Note the $F$ option can only be used for a fishing fleet and not for a survey, even if the survey selectivity is mirrored to a fishing fleet. The values of these effort data are interpreted as proportional to the level of the fishery $F$ values. No adjustment is made for differentiating between continuous $F$ values versus exploitation rate values coming from Pope's approximation. A normal error structure is recommended so that the input effort data are compared directly to the model's calculated $F$, rather than to $log(F)$. The resultant proportionality constant has units of 1/Q where Q is the catchability coefficient. For more information see the section on \hypertarget{PredEffort}{Predator effort}.
\item Note the $F$ option can only be used for a fishing fleet and not for a survey, even if the survey selectivity is mirrored to a fishing fleet. The values of these effort data are interpreted as proportional to the level of the fishery $F$ values. No adjustment is made for differentiating between continuous $F$ values versus exploitation rate values coming from Pope's approximation. A normal error structure is recommended so that the input effort data are compared directly to the model's calculated $F$, rather than to $ln(F)$. The resultant proportionality constant has units of 1/Q where Q is the catchability coefficient. For more information see the section on \hypertarget{PredEffort}{Predator effort}.
\end{itemize}
\item \hypertarget{SpecialSurvey}{} $>=$ 30 = Special survey types. These options bypass the calculation of survey selectivity so the no selectivity parameter are required and age/length selectivity pattern should be set as 0. A catchability parameter line in the control file will be required for each special survey. Special survey types 31, 32, and 36 relate to recruitment deviations. Before v.3.30.22, the expected value for observations before recdev\_start or after recdev\_end were null. With v.3.30.22, expected values are now based on recruitment deviations for all years and suggestions are included in \texttt{warnings.sso} if observations occur outside the range of active recruitment deviations. The expected values for these types are:
\begin{itemize}
Expand Down Expand Up @@ -441,10 +441,10 @@
\begin{itemize}
\item -1 = normal error;
\item 0 = log-normal error; and
\item > 0 = Student's t-distribution in log space with \gls{df} equal to this value. For \gls{df} > 30, results will be nearly identical to that for log-normal distribution. A \gls{df} value of about 4 gives a fat-tail to the distribution. The \gls{se} values entered in the data file must be the \gls{se} in $log_{e}$ space.
\item > 0 = Student's t-distribution in natural log space with \gls{df} equal to this value. For \gls{df} > 30, results will be nearly identical to that for log-normal distribution. A \gls{df} value of about 4 gives a fat-tail to the distribution. The \gls{se} values entered in the data file must be the \gls{se} in $ln_{e}$ space.
\end{itemize}

Abundance indices typically assumed to have a log-normal error structure with units of \gls{se} of $log_{e}$(index). If the variance of the observations is available only as a \gls{cv} (\gls{se} of the observation divided by the mean value of the observation in natural space), then the value of standard error in log space can be calculated as $\sqrt{(log_e(1+(CV)^2))}$.
Abundance indices typically assumed to have a log-normal error structure with units of \gls{se} of $ln_{e}$(index). If the variance of the observations is available only as a \gls{cv} (\gls{se} of the observation divided by the mean value of the observation in natural space), then the value of standard error in natural log space can be calculated as $\sqrt{(ln_e(1+(CV)^2))}$.

For the normal error structure, the entered values for \gls{se} are interpreted directly as a \gls{se} in arithmetic space and not as a \gls{cv}. Thus switching from a log-normal to a normal error structure forces the user to provide different values for the \gls{se} input in the data file.

Expand Down Expand Up @@ -535,7 +535,7 @@
\item > 0 = \gls{df} for Student's t-distribution used to scale mean body weight deviations. Value of error in data file is interpreted as \gls{cv} of the observation;
\item 0 = normal distribution, value of error in data file is interpreted as \gls{cv} of the observation;
\item -1 = normal distribution, value of error in data file is interpreted as \gls{se} of the observation;
\item -2 = log-normal distribution, value of error in data file is interpreted as \gls{se} of the observation in log space; and
\item -2 = log-normal distribution, value of error in data file is interpreted as \gls{se} of the observation in natural log space; and
\item -3 = truncated normal distribution (new with v.3.30, needs further testing), value of error in data file is interpreted as \gls{se} of the observation. This is a good option for low observed discard rates.
\end{itemize}

Expand Down Expand Up @@ -733,9 +733,9 @@
\myparagraph{Additional information on Dirichlet Parameter Number and Effective Sample Sizes}
If the Dirichlet-multinomial error distribution is selected, indicate here which of a list of Dirichlet-multinomial parameters will be used for this fleet. So each fleet could use a unique Dirichlet-multinomial parameter, or all could share the same, or any combination of unique and shared. The requested number of Dirichlet-multinomial parameters are specified as parameter lines in the control file immediately after the selectivity parameter section. Please note that age-compositions Dirichlet-multinomial parameters are continued after length-compositions, so a model with one fleet and both data types would presumably require two new Dirichlet-multinomial parameters.

The Dirichlet estimates the effective sample size as $N_{eff}=\frac{1}{1+\theta}+\frac{N\theta}{1+\theta}$ where $\theta$ is the estimated parameter and $N$ is the input sample size. Stock Synthesis estimates the log of the Dirichlet-multinomial parameter such that $\hat{\theta}_{\text{fishery}} = e^{-0.6072} = 0.54$ where assuming $N=100$ for the fishery would result in an effective sample size equal to 35.7.
The Dirichlet estimates the effective sample size as $N_{eff}=\frac{1}{1+\theta}+\frac{N\theta}{1+\theta}$ where $\theta$ is the estimated parameter and $N$ is the input sample size. Stock Synthesis estimates the natural log of the Dirichlet-multinomial parameter such that $\hat{\theta}_{\text{fishery}} = e^{-0.6072} = 0.54$ where assuming $N=100$ for the fishery would result in an effective sample size equal to 35.7.

This formula for effective sample size implies that, as the Stock Synthesis parameter $ln(DM\text{\_theta})$ goes to large values (i.e., 20), then the adjusted sample size will converge to the input sample size. In this case, small changes in the value of the $ln(DM\text{\_theta})$ parameter has no action, and the derivative of the negative log-likelihood is zero with respect to the parameter, which means the Hessian will be singular and cannot be inverted. To avoid this non-invertible Hessian when the $ln(DM\text{\_theta})$ parameter becomes large, turn it off while fixing it at the high value. This is equivalent to turning off down-weighting of fleets where evidence suggests that the input sample sizes are reasonable.
This formula for effective sample size implies that, as the Stock Synthesis parameter $ln(DM\text{\_theta})$ goes to large values (i.e., 20), then the adjusted sample size will converge to the input sample size. In this case, small changes in the value of the $ln(DM\text{\_theta})$ parameter has no action, and the derivative of the negative log likelihood is zero with respect to the parameter, which means the Hessian will be singular and cannot be inverted. To avoid this non-invertible Hessian when the $ln(DM\text{\_theta})$ parameter becomes large, turn it off while fixing it at the high value. This is equivalent to turning off down-weighting of fleets where evidence suggests that the input sample sizes are reasonable.

For additional information about the Dirichlet-multinomial please see \citet{thorson-model-based-2017} and the detailed \hyperlink{DataWeight}{Data Weighting} section.

Expand Down
10 changes: 5 additions & 5 deletions 9control.tex
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
1 & LO & Minimum value for the parameter \Tstrut\\
2 & HI & Maximum value for the parameter \Tstrut\\
3 \Tstrut & INIT & Initial value for the parameter. If the phase (described below) for the parameter is negative the parameter is fixed at this value. If the \texttt{ss3.par} file is read, it overwrites these INIT values.\\
4 \Tstrut & PRIOR & Expected value for the parameter. This value is ignored if the prior type is 0 (no prior) or 1 (symmetric beta). If the selected prior type (described below) is log-normal, this value is entered in log space. \\
4 \Tstrut & PRIOR & Expected value for the parameter. This value is ignored if the prior type is 0 (no prior) or 1 (symmetric beta). If the selected prior type (described below) is log-normal, this value is entered in natural log space. \\
5 \Tstrut & PRIOR \gls{sd} & \gls{sd} for the prior, used to calculate likelihood of the current parameter value. This value is ignored if prior type is 0. The \gls{sd} is in regular space regardless of the prior type. \\
6 \Tstrut & \hyperlink{PriorDescrip}{PRIOR TYPE} & 0 = none; \\
& & 1 = symmetric beta; \\
Expand Down Expand Up @@ -515,7 +515,7 @@
The Richards model has $b$ < 0, the von Bertalanffy model has $b$ = 1. The general case of $b$ > 0 was called the ``generalized von Bertalanffy'' by \citet{schnute1981growth}. The Gompertz model has $b$ = 0, where the equation is undefined as written above and must be replaced with:

\begin{equation}
L_t = y_1e\Big[log(y_2/y-1)\frac{1-e^{-k(t-A_1)}}{1-e{-k(A_2-A_1)}}\Big]
L_t = y_1e\Big[ln(y_2/y-1)\frac{1-e^{-k(t-A_1)}}{1-e{-k(A_2-A_1)}}\Big]
\end{equation}

Thus, if $b$ will be estimated as a free parameter, it might be necessary to include options for constraining it to different ranges.
Expand Down Expand Up @@ -1157,7 +1157,7 @@ \subsubsection{Predator Fleet Mortality}
\endfoot
\endlastfoot

8.5 & $ln(R_{0})$ & Log of virgin recruitment level. \Tstrut\Bstrut\\
8.5 & $ln(R_{0})$ & Natural log of virgin recruitment level. \Tstrut\Bstrut\\
\hline

0.60 \Tstrut & Steepness & Steepness of spawner recruitment relationship, bound by 0.2 and 1.0 for the Beverton-Holt. \Bstrut\\
Expand Down Expand Up @@ -1283,7 +1283,7 @@ \subsubsection{Predator Fleet Mortality}
& & -3: bias adjustment set to 0 for all model and forecast years. \\

\Tstrut & 0 & Period For Recruitment Cycles: \\
& & Use this when the model is configured to model seasons as years and there is a need to impose a periodicity to the expected recruitment level. If value is >0, then read that number of full parameter lines below define the recruitment cycle. See more information on setting up seasons as years model in the \hyperlink{continuous-seasonal-recruitment-sec}{continuous seasonal recruitment section}. \\
& & Use this when the model is configured to model seasons as years and there is a need to impose a periodicity to the expected recruitment level. If value is > 0, then read that number of full parameter lines below define the recruitment cycle. See more information on setting up seasons as years model in the \hyperlink{continuous-seasonal-recruitment-sec}{continuous seasonal recruitment section}. \\

\Tstrut & -5 & Minimum Recruitment Deviation: Min value for recruitment deviation. \\
& & Negative phase = Default value. \\
Expand Down Expand Up @@ -1394,7 +1394,7 @@ \subsubsection{Predator Fleet Mortality}
\item Applying the Pope’s method to get a harvest rate for each fleet in the current season;
\item Converting that harvest rate to the equivalent $F_{hyb}$. This is exact with one fleet and approximate with multiple fleets;
\item Adjusting those $F_{hyb}$ values over a fixed number of iterations (2-4) using the ratio of observed to calculated catch for each fleet; and
\item Proceeding with those $F_{hyb}$ values into subsequent model steps. $F_{par}$ and $F_{hyb}$ values are used in the same Baranov catch equation and a catch log-likelihood is calculated based on the observed retained catch and the annual standard error of the catch.
\item Proceeding with those $F_{hyb}$ values into subsequent model steps. $F_{par}$ and $F_{hyb}$ values are used in the same Baranov catch equation and a catch log likelihood is calculated based on the observed retained catch and the annual standard error of the catch.
\end{enumerate}

Some notes:
Expand Down
10 changes: 8 additions & 2 deletions SS330_User_Manual.tex
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,14 @@
\date{January 31, 2024}

% ==== Glossary ========================================================
\usepackage{glossaries}
\usepackage[xindy,acronym]{glossaries}
\setacronymstyle{long-short}
\glsdisablehyper
\makenoidxglossaries
\loadglsentries{ss3_glossaries.tex}

\begin{document}
\glsaddall
% ====== Title Page ===================================================
\maketitle
\begin{figure}[ht]
Expand Down Expand Up @@ -219,9 +220,14 @@
%========= Section 16: Essays
\input{16essays}
%========= Glossary
\hypertarget{Glossary}{}
\addcontentsline{toc}{section}{Glossary}
\printnoidxglossary[type=main,title=\protect\hyperlink{Glossary}{Glossary},nonumberlist]

\hypertarget{Acronyms}{}
\addcontentsline{toc}{section}{List of Acronyms}
\printnoidxglossary[title=\protect\hyperlink{Acronyms}{List of Acronyms},nonumberlist]
\printnoidxglossary[type=\acronymtype,title=\protect\hyperlink{Acronyms}{List of Acronyms},nonumberlist]

%========= Reference Section
\newpage
\bibliography{SS3}
Expand Down
Loading

0 comments on commit 38ec129

Please sign in to comment.