From 31ea94b611844a557947b11ac758531abb83005b Mon Sep 17 00:00:00 2001 From: timjmiller Date: Thu, 9 Feb 2023 13:23:08 -0500 Subject: [PATCH] fix bug in parameter estimate table --- R/par_tables_fn.R | 14 +++++++------- man/prepare_projection.Rd | 6 +++--- man/project_wham.Rd | 8 ++++---- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/R/par_tables_fn.R b/R/par_tables_fn.R index e062aabe..d33a42b4 100644 --- a/R/par_tables_fn.R +++ b/R/par_tables_fn.R @@ -13,8 +13,8 @@ par_tables_fn = function(mod, do.tex=FALSE, do.html=FALSE, od) } if(type == "expit") { #Delta-method: V(lo + (hi-lo)/(1 + exp(-x))) ~ ((hi-lo) * p * (1-p))^2 * V(x) p = 1/(1 + exp(- k * par)) - dm.se = k * abs(hi-lo)*p*(1-p)*se - return(c(dm.se, lo + (hi-lo)/(1+ exp(-ci)))) + dm.se = abs(k) * abs(hi-lo)*p*(1-p)*se + return(c(dm.se, lo + (hi-lo)/(1+ exp(-k * ci)))) } } data = mod$env$data @@ -161,7 +161,7 @@ par_tables_fn = function(mod, do.tex=FALSE, do.html=FALSE, od) fe.vals = c(fe.vals, exp(pars$log_NAA_sigma[1])) fe.cis = rbind(fe.cis, ci(pars$log_NAA_sigma[1], sd$log_NAA_sigma[1], type = "exp")) fe.names = c(fe.names, paste("NAA residual AR1 $\\rho$", "year")) - fe.vals = c(fe.vals, -1 + 2/(1 + exp(-pars$trans_NAA_rho[2]))) + fe.vals = c(fe.vals, -1 + 2/(1 + exp(- 2 * pars$trans_NAA_rho[2]))) fe.cis = rbind(fe.cis, ci(pars$trans_NAA_rho[2], sd$trans_NAA_rho[2], lo = -1, hi = 1, type = "expit", k = 2)) } @@ -216,12 +216,12 @@ par_tables_fn = function(mod, do.tex=FALSE, do.html=FALSE, od) if(data$selblock_models[i] %in% c(2,4)) modify = " $\\rho$ for $a_{50}$ and 1/slope" if(data$selblock_models[i] == 3) modify = " AR1 $\\rho$ for double-logistic pars" fe.names = c(fe.names, paste0("Block ", i , ": Selectivity RE", modify)) - fe.vals = c(fe.vals, -1 + 2/(1 + exp(-pars$sel_repars[i,2]))) + fe.vals = c(fe.vals, -1 + 2/(1 + exp(- 2 * pars$sel_repars[i,2]))) fe.cis = rbind(fe.cis, ci(pars$sel_repars[i,2], sd$sel_repars[i,2], lo = -1, hi = 1, type = "expit", k = 2)) } if(data$selblock_models_re[i] %in% c(4,5)) { fe.names = c(fe.names, paste0("Block ", i , ": Selectivity RE AR1 $\\rho$ (year)")) - fe.vals = c(fe.vals, -1 + 2/(1 + exp(-pars$sel_repars[i,3]))) + fe.vals = c(fe.vals, -1 + 2/(1 + exp(- 2 * pars$sel_repars[i,3]))) fe.cis = rbind(fe.cis, ci(pars$sel_repars[i,3], sd$sel_repars[i,3], lo = -1, hi = 1, type = "expit", k = 2)) } } @@ -346,12 +346,12 @@ par_tables_fn = function(mod, do.tex=FALSE, do.html=FALSE, od) fe.cis = rbind(fe.cis, ci(pars$M_repars[1], sd$M_repars[1], type = "exp")) if(data$M_re_model %in% c(3,5)){ fe.names = c(fe.names, "M RE AR1 $\\rho$ (age)") - fe.vals = c(fe.vals, exp(pars$M_repars[2])) + fe.vals = c(fe.vals, -1 + 2/(1 + exp(- 2 * pars$M_repars[2]))) fe.cis = rbind(fe.cis, ci(pars$M_repars[2], sd$M_repars[2], lo = -1, hi = 1, type = "expit", k = 2)) } if(data$M_re_model %in% c(4,5)) { fe.names = c(fe.names, "M RE AR1 $\\rho$ (year)") - fe.vals = c(fe.vals, exp(pars$M_repars[3])) + fe.vals = c(fe.vals, -1 + 2/(1 + exp(- 2 * pars$M_repars[3]))) fe.cis = rbind(fe.cis, ci(pars$M_repars[3], sd$M_repars[3], lo = -1, hi = 1, type = "expit", k = 2)) } } diff --git a/man/prepare_projection.Rd b/man/prepare_projection.Rd index 6ab674ce..23ba2345 100644 --- a/man/prepare_projection.Rd +++ b/man/prepare_projection.Rd @@ -14,7 +14,7 @@ prepare_projection(model, proj.opts) \item \code{$n.yrs} (integer), number of years to project/forecast. Default = \code{3}. \item \code{$use.last.F} (T/F), use terminal year F for projections. Default = \code{TRUE}. \item \code{$use.avg.F} (T/F), use average of F over certain years for projections. Default = \code{FALSE}. Years to average over determined by $avg.yrs defined below. - \item \code{$use.FXSPR} (T/F), calculate and use F at X% SPR for projections. Default = \code{FALSE}. + \item \code{$use.FXSPR} (T/F), calculate and use F at X\% SPR for projections. Default = \code{FALSE}. \item \code{$use.FMSY} (T/F), calculate and use FMSY for projections. Default = \code{FALSE}. \item \code{$proj.F} (vector), user-specified fishing mortality for projections. Length must equal \code{n.yrs}. \item \code{$proj.catch} (vector), user-specified aggregate catch for projections. Length must equal \code{n.yrs}. @@ -25,9 +25,9 @@ prepare_projection(model, proj.opts) \item \code{$proj.ecov} (matrix), user-specified environmental covariate(s) for projections. \code{n.yrs x n.ecov}. \item \code{$cont.Mre} (T/F), continue M random effects (i.e. AR1_y or 2D AR1) for projections. Default = \code{TRUE}. If \code{FALSE}, M will be averaged over \code{$avg.yrs} (which defaults to last 5 model years). \item \code{$avg.rec.yrs} (vector), specify which years to calculate the CDF of recruitment for use in projections. Default = all model years. Only used when recruitment is estimated as fixed effects (SCAA). - \item \code{$percentFXSPR} (scalar), percent of F_XSPR to use for calculating catch in projections, only used if $use.FXSPR = TRUE. For example, GOM cod uses F = 75% F_40%SPR, so \code{proj.opts$percentFXSPR = 75}. Default = 100. + \item \code{$percentFXSPR} (scalar), percent of F_XSPR to use for calculating catch in projections, only used if $use.FXSPR = TRUE. For example, GOM cod uses F = 75\% F_40\%SPR, so \code{proj.opts$percentFXSPR = 75}. Default = 100. \item \code{$percentFMSY} (scalar), percent of F_MSY to use for calculating catch in projections, only used if $use.FMSY = TRUE. - \item \code{$proj_F_opt} (vector), integers specifying how to configure each year of the projection: 1: use terminal F, 2: use average F, 3: use F at X% SPR, 4: use specified F, 5: use specified catch, 6: use Fmsy. Overrides any of the above specifications. + \item \code{$proj_F_opt} (vector), integers specifying how to configure each year of the projection: 1: use terminal F, 2: use average F, 3: use F at X\% SPR, 4: use specified F, 5: use specified catch, 6: use Fmsy. Overrides any of the above specifications. \item \code{$proj_Fcatch} (vector), catch or F values to use each projection year: values are not used when using Fmsy, FXSPR, terminal F or average F. Overrides any of the above specifications of proj.F or proj.catch. }} } diff --git a/man/project_wham.Rd b/man/project_wham.Rd index 46e96bf1..1a9151ad 100644 --- a/man/project_wham.Rd +++ b/man/project_wham.Rd @@ -25,7 +25,7 @@ project_wham( \item \code{$n.yrs} (integer), number of years to project/forecast. Default = \code{3}. \item \code{$use.last.F} (T/F), use terminal year F for projections. Default = \code{TRUE}. \item \code{$use.avg.F} (T/F), use average of F over certain years for projections. Default = \code{FALSE}. Years to average over determined by $avg.yrs defined below. - \item \code{$use.FXSPR} (T/F), calculate and use F at X% SPR for projections. Default = \code{FALSE}. + \item \code{$use.FXSPR} (T/F), calculate and use F at X\% SPR for projections. Default = \code{FALSE}. \item \code{$use.FMSY} (T/F), calculate and use FMSY for projections. Default = \code{FALSE}. \item \code{$proj.F} (vector), user-specified fishing mortality for projections. Length must equal \code{n.yrs}. \item \code{$proj.catch} (vector), user-specified aggregate catch for projections. Length must equal \code{n.yrs}. @@ -36,9 +36,9 @@ project_wham( \item \code{$proj.ecov} (matrix), user-specified environmental covariate(s) for projections. \code{n.yrs x n.ecov}. \item \code{$cont.Mre} (T/F), continue M random effects (i.e. AR1_y or 2D AR1) for projections. Default = \code{TRUE}. If \code{FALSE}, M will be averaged over \code{$avg.yrs} (which defaults to last 5 model years). \item \code{$avg.rec.yrs} (vector), specify which years to calculate the CDF of recruitment for use in projections. Default = all model years. Only used when recruitment is estimated as fixed effects (SCAA). - \item \code{$percentFXSPR} (scalar), percent of F_XSPR to use for calculating catch in projections, only used if $use.FXSPR = TRUE. For example, GOM cod uses F = 75% F_40%SPR, so \code{proj.opts$percentFXSPR = 75}. Default = 100. + \item \code{$percentFXSPR} (scalar), percent of F_XSPR to use for calculating catch in projections, only used if $use.FXSPR = TRUE. For example, GOM cod uses F = 75\% F_40\%SPR, so \code{proj.opts$percentFXSPR = 75}. Default = 100. \item \code{$percentFMSY} (scalar), percent of F_MSY to use for calculating catch in projections, only used if $use.FMSY = TRUE. - \item \code{$proj_F_opt} (vector), integers specifying how to configure each year of the projection: 1: use terminal F, 2: use average F, 3: use F at X% SPR, 4: use specified F, 5: use specified catch, 6: use Fmsy. Overrides any of the above specifications. + \item \code{$proj_F_opt} (vector), integers specifying how to configure each year of the projection: 1: use terminal F, 2: use average F, 3: use F at X\% SPR, 4: use specified F, 5: use specified catch, 6: use Fmsy. Overrides any of the above specifications. \item \code{$proj_Fcatch} (vector), catch or F values to use each projection year: values are not used when using Fmsy, FXSPR, terminal F or average F. Overrides any of the above specifications of proj.F or proj.catch. }} @@ -68,7 +68,7 @@ Exactly one of these must be specified in \code{proj.opts}: \itemize{ \item Use last year F (default). Set \code{proj.opts$use.last.F = TRUE}. WHAM will use F in the terminal model year for projections. \item Use average F. Set \code{proj.opts$use.avg.F = TRUE}. WHAM will use F averaged over \code{proj.opts$avg.yrs} for projections (as is done for M-, maturity-, and weight-at-age). - \item Use F at X% SPR. Set \code{proj.opts$use.FXSPR = TRUE}. WHAM will calculate F at X% SPR. + \item Use F at X\% SPR. Set \code{proj.opts$use.FXSPR = TRUE}. WHAM will calculate F at X\% SPR. \item Specify F. Provide \code{proj.opts$proj.F}, an F vector with length = \code{n.yrs}. \item Specify catch. Provide \code{proj.opts$proj.catch}, a vector of aggregate catch with length = \code{n.yrs}. WHAM will calculate F to get specified catch. }