View source: R/modelFitFunction.R
bycatchFit | R Documentation |
Produces model-based estimates of bycatch and annual abundance index, as specified in bycatchSetup
bycatchFit(
setupObj,
selectCriteria = "BIC",
DoCrossValidation = FALSE,
DredgeCrossValidation = FALSE,
ResidualTest = TRUE,
CIval = 0.05,
VarCalc = "Simulate",
useParallel = TRUE,
nSims = 10,
baseDir = getwd(),
plotValidation = FALSE,
trueVals = NULL,
trueCols = NULL,
doReport = TRUE
)
setupObj |
An object produced by |
selectCriteria |
Character. Model selection criteria. Options are AICc, AIC and BIC |
DoCrossValidation |
Specify whether to run a 10 fold cross-validation (TRUE or FALSE). This may not work with a small or unbalanced dataset |
DredgeCrossValidation |
DredgeCrossValidation specifies whether to use information criteria to find the best model in cross validation, using the dredge function, or just keep the same model formula. Do not use dredge for very large datasets, as the run will be slow. |
ResidualTest |
Logical. Specify whether to exclude models that fail the DHARMa residuals test. |
CIval |
Specify confidence interval for total bycatch estimates. Should be the alpha level, e.g. 0.05 for 95% |
VarCalc |
Character. Options are: "Simulate","DeltaMethod", or "None". Variance calculation method. Simulate will not work with a large number of sample units in the logbook data. The delta method for variance calculation is not implemented for the delta-lognormal or delta-gamma methods. |
useParallel |
Logical. Whether to conduct the analysis using parallel processing. Only initialized when more that two cores are available. |
nSims |
Number of simulations used to calculate confidence intervals. Ignored if |
baseDir |
Character. A directory to save output. Defaults to current working directory. |
plotValidation |
Logical. Validation. If you have true values of the total bycatch (for example in a simulation study). Make PlotValidation true and fill out the rest of the specification. |
trueVals |
The data set that contains the true simulated total catches by year. |
trueCols |
The column of the true simulated catches that contains true bycatch by year |
doReport |
Logical. Create a markdown report of the analysis |
## Not run:
library(BycatchEstimator)
#-------------------------------------------------
#Step 1. Run the setup file and review data inputs
setupObj<-bycatchSetup(
modelTry = c("Lognormal","Delta-Lognormal","Delta-Gamma","TMBnbinom1","TMBnbinom2","TMBtweedie"),
obsdat = LLSIM_BUM_Example_observer,
logdat = LLSIM_BUM_Example_logbook,
yearVar = "Year",
obsEffort = "hooks",
logEffort = "hooks",
logUnsampledEffort = "unsampledEffort",
includeObsCatch = TRUE,
matchColumn = "trip",
factorNames = c("Year","fleet","area","season"),
EstimateIndex = TRUE,
EstimateBycatch = TRUE,
logNum = NA,
sampleUnit = "trips",
complexModel = formula(y~Year+fleet+hbf+area+season+Year:area),
simpleModel = formula(y~Year+fleet+area),
indexModel = formula(y~Year+area),
baseDir = getwd(),
runName = "LLSIMBUMtrip2022Aprilobs05mc",
runDescription = "LLSIm BUM by trip, with 5% observer coverage including observed catch in totals April 17 2022",
common = c("Swordfish","Blue marlin")[2],
sp = c("Xiphias gladius","Makaira nigricans")[2],
obsCatch = c("SWO","BUM")[2],
catchUnit = "number",
catchType = "catch"
)
-------------
#Step 2. Model Fitting
bycatchFit(
setupObj = setupObj,
selectCriteria = "BIC",
DoCrossValidation = TRUE,
DredgeCrossValidation = FALSE,
ResidualTest = FALSE,
CIval = 0.05,
VarCalc = "Simulate",
useParallel = TRUE,
nSims = 1000,
baseDir = getwd(),
plotValidation = FALSE,
trueVals = NULL,
trueCols = NULL
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.