From 865ca3d304c2d5eddcf044fe3d3776ada42b07aa Mon Sep 17 00:00:00 2001 From: timjmiller Date: Mon, 2 May 2022 12:36:14 -0400 Subject: [PATCH] fix selectivity for N1_model = 1 option. Fix infinte residual plot issue for Ecov --- NEWS.md | 4 ++++ R/wham_plots_tables.R | 8 ++++++-- src/wham_v0.cpp | 4 ++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/NEWS.md b/NEWS.md index 2c19fb26..11424fc5 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,10 @@ wham 1.0.6.9000 ========================= +### Bug fixes + +* Fix age of full selection for N1_model = 1 [issue 56][https://github.com/timjmiller/wham/issues/56]. + wham 1.0.6 (2022-04-08) ========================= diff --git a/R/wham_plots_tables.R b/R/wham_plots_tables.R index 51bdb97b..4f489109 100644 --- a/R/wham_plots_tables.R +++ b/R/wham_plots_tables.R @@ -171,7 +171,7 @@ plot.osa.residuals <- function(mod, do.tex=FALSE, do.png=FALSE, fontfam="", res= # set plot lims using max residual for any component (easier to compare if all the same) ylim.max <- max(abs(range(resids, na.rm=TRUE))) if(is.infinite(ylim.max)) { - cat("Infinite osa residuals for catch proportions at age in fleet ", f, ", so using +/-10 for range of y axis \n") + cat("Infinite osa residuals for catch proportions at age in fleet ", f, ", so using +/-10 for range \n") ylim.max = 10 } ylims <- c(-ylim.max, ylim.max) @@ -333,7 +333,7 @@ plot.osa.residuals <- function(mod, do.tex=FALSE, do.png=FALSE, fontfam="", res= # set plot lims using max residual for any component (easier to compare if all the same) ylim.max <- max(abs(range(resids, na.rm=TRUE))) if(is.infinite(ylim.max)) { - cat("Infinite osa residuals for proportions at age in index ", f, ", so using +/-10 for range of y axis \n") + cat("Infinite osa residuals for proportions at age in index ", f, ", so using +/-10 for range \n") ylim.max = 10 } ylims <- c(-ylim.max, ylim.max) @@ -427,6 +427,10 @@ plot.osa.residuals <- function(mod, do.tex=FALSE, do.png=FALSE, fontfam="", res= # set plot lims using max residual for any component (easier to compare if all the same) ylim.max <- max(abs(range(dat$residual, na.rm=TRUE))) + if(is.infinite(ylim.max)) { + cat("Infinite osa residuals for Environmental observations in series ", f, ", so using +/-10 for range of y axis \n") + ylim.max = 10 + } ylims <- c(-ylim.max, ylim.max) # 1. trend vs. year diff --git a/src/wham_v0.cpp b/src/wham_v0.cpp index 4dde6f42..40944eb9 100644 --- a/src/wham_v0.cpp +++ b/src/wham_v0.cpp @@ -715,8 +715,8 @@ Type objective_function::operator() () if(a==0) NAA(0,0) = exp(log_N1_pars(0)); else { - if(a == n_ages-1) NAA(0,a) = NAA(0,a-1)/(1.0 + exp(-MAA(0,a) - exp(log_N1_pars(1)) * FAA_tot(0,a)/FAA_tot(0,n_ages-1))); - else NAA(0,a) = NAA(0,a-1)* exp(-MAA(0,a) - exp(log_N1_pars(1)) * FAA_tot(0,a)/FAA_tot(0,n_ages-1)); + if(a == n_ages-1) NAA(0,a) = NAA(0,a-1)/(1.0 + exp(-MAA(0,a) - exp(log_N1_pars(1)) * FAA_tot(0,a)/FAA_tot(0,which_F_age(0)-1))); + else NAA(0,a) = NAA(0,a-1)* exp(-MAA(0,a) - exp(log_N1_pars(1)) * FAA_tot(0,a)/FAA_tot(0,which_F_age(0)-1)); } } SSB(0) += NAA(0,a) * waa(waa_pointer_ssb-1,0,a) * mature(0,a) * exp(-ZAA(0,a)*fracyr_SSB(0));