project_wham | R Documentation |
Provides projections/forecasts for an existing (already fit) WHAM model.
project_wham(
model,
proj.opts = list(n.yrs = 3, use.last.F = TRUE, use.avg.F = FALSE, use.FXSPR = FALSE,
use.FMSY = FALSE, cont.ecov = TRUE, use.last.ecov = FALSE, percentFXSPR = 100,
percentFMSY = 100),
n.newton = 3,
do.sdrep = TRUE,
MakeADFun.silent = FALSE,
save.sdrep = TRUE,
check.version = TRUE,
TMB.bias.correct = FALSE,
TMB.jointPrecision = FALSE
)
model |
a previously fit wham model |
proj.opts |
a named list with the following components:
|
n.newton |
integer, number of additional Newton steps after optimization. Passed to |
do.sdrep |
T/F, calculate standard deviations of model parameters? See |
MakeADFun.silent |
T/F, Passed to silent argument of |
save.sdrep |
T/F, save the full |
check.version |
T/F check whether version WHAM and TMB for fitted model match that of the version of WHAM using for projections. Default = |
TMB.bias.correct |
T/F whether to use the bias.correct feature of TMB::sdreport. Default = |
TMB.jointPrecision |
T/F whether to return the joint precision matrix for the fixed and random effects from TMB::sdreport. Default = |
WHAM implements five options for handling fishing mortality in the projections.
Exactly one of these must be specified in proj.opts
:
Use last year F (default). Set proj.opts$use.last.F = TRUE
. WHAM will use F in the terminal model year for projections.
Use average F. Set proj.opts$use.avg.F = TRUE
. WHAM will use F averaged over proj.opts$avg.yrs
for projections (as is done for M-, maturity-, and weight-at-age).
Use F at X% SPR. Set proj.opts$use.FXSPR = TRUE
. WHAM will calculate F at X% SPR.
Specify F. Provide proj.opts$proj.F
, an F vector with length = n.yrs
.
Specify catch. Provide proj.opts$proj.catch
, a vector of aggregate catch with length = n.yrs
. WHAM will calculate F to get specified catch.
proj.opts$avg.yrs
controls which years the following will be averaged over in the projections:
Maturity-at-age
Weight-at-age
Natural mortality-at-age
Fishing mortality-at-age (if proj.opts$use.avgF = TRUE
)
If fitting a model with recruitment estimated freely in each year, i.e. as fixed effects as in ASAP, WHAM handles recruitment
in the projection years similarly to using the empirical cumulative distribution function. WHAM does this by calculating the mean
and standard deviation of log(R) over all model years (default) or a specified subset of years (proj.opts$avg.rec.yrs
). WHAM then
treats recruitment in the projections as a random effect with this mean and SD, i.e. log(R) ~ N(meanlogR, sdlogR).
WHAM implements four options for handling the environmental covariate(s) in the projections.
Exactly one of these must be specified in proj.opts
if ecov
is in the model:
Set $cont.ecov = TRUE
. WHAM will estimate the ecov process in projection years (i.e. continue the random walk / AR1 process).
Set $use.last.ecov = TRUE
. WHAM will use ecov value from the terminal year (of population model) for projections.
Provide $avg.yrs.ecov
, a vector specifying which years to average over the environmental covariate(s) for projections.
ecov
Provide $proj.ecov
, a matrix of user-specified environmental covariate(s) to use for projections. Dimensions must be # projection years (proj.opts$n.yrs
) x # ecovs (ncols(ecov$mean)
).
If the original model fit the ecov in years beyond the population model, WHAM will use the already-fit
ecov values for the projections. If the ecov model extended at least proj.opts$n.yrs
years
beyond the population model, then none of the above need be specified.
a projected WHAM model with additional output if specified:
$rep
List of derived quantity estimates (see examples)
$sdrep
Parameter estimates (and standard errors if do.sdrep=TRUE
)
$peels
Retrospective analysis (if do.retro=TRUE
)
$osa
One-step-ahead residuals (if do.osa=TRUE
)
fit_wham
, fit_tmb
## Not run:
data("input4_SNEMAYT") # load SNEMA yellowtail flounder input data and model settings
mod <- fit_wham(input4_SNEMAYT) # using default values (do.proj=T)
mod2 <- fit_wham(input4_SNEMAYT, do.retro=F, do.osa=F, do.proj=F) # fit model without projections, retro analysis, or OSA residuals
mod_proj <- project_wham(mod2) # add projections to previously fit model, using default values: use.lastF = TRUE, n.yrs = 3, avg.yrs = last 5 years
names(mod_proj$rep) # list of derived quantities
tail(mod_proj$rep$SSB, 3) # get 3-year projected SSB estimates (weight, not numbers)
x = summary(mod_proj$sdrep)
unique(rownames(x)) # list of estimated parameters and derived quanitites with SE
x = x[rownames(x) == "log_SSB",] # SSB estimates with SE
ssb.mat = exp(cbind(x, x[,1] + qnorm(0.975)*cbind(-x[,2],x[,2])))/1000 # calculate 95% CI
colnames(ssb.mat) <- c("SSB","SSB_se","SSB_lower","SSB_upper")
tail(ssb.mat, 3) # 3-year projected SSB estimates with SE and 95% CI
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.