First stage regression model for catch.
Usage
catch_lm(
dat,
project,
catch.formula,
zoneID = NULL,
exp.name = NULL,
new.name = NULL,
date,
output = "matrix"
)Arguments
- dat
Primary data containing information on hauls or trips. Table in FishSET database contains the string 'MainDataTable'.
- project
String, name of project.
- catch.formula
A formula object specifying the linear model.See
stats::lm().- zoneID
zone ID Variable in
datthat identifies the individual zones or areas. Required if merging expected catch intodatusingexp.name, or when creating a new expected catch matrix andexp.nameisNULL(seeoutputbelow).- exp.name
Name(s) of expected catch matrix to merge into
dat.- new.name
Optional, string. When
output = 'matrix',new.namewill become the name of the new expected catch matrix saved to the FishSET DB expected catch list. Whenoutput = 'dataset',new.namewill become the name of the new expected catch variable added to the primary dataset.- date
Date variable from
datused to create expected catch matrix.- output
Whether to output
datwith the expected catch variable added ('dataset') or to save an expected catch matrix to the expected catch FishSET DB table ('matrix'). Defaults tooutput = 'matrix'.
Value
catch_lm() has two output options: dataset and matrix. When
output == 'dataset', the primary dataset will be returned with the fitted
values from the model added as a new column. The new column is named using
new.name.
When output == 'matrix' an expected catch matrix is created and saved to
the FishSET DB expected catch list (it is not outputted to the console).
There are two ways to create an expected catch matrix: by using an existing
expected catch matrix in catch.formula, or by using a zone-identifier
column (i.e. zoneID) in the catch.formula. For example, if you have
created an expected catch matrix named 'user1' using create_expectations(),
catch.formula could equal catch ~ vessel_length * user1. In this case
exp.name would equal 'user1'. Alternatively, you could create an expected
catch matrix by specifying catch.formula as catch ~ vessel_length * zone.
In this case, exp.name = NULL and zoneID = 'zone'.
Details
catch_lm() can merge an expected catch matrix into the primary dataset
before running the linear model. This is done using by passing exp.name
and zoneID to merge_expected_catch() and is for convenience; users can
do this separately using merge_expected_catch() if desired, just make sure
to leave exp.name empty before running catch_lm(). Merging expected catch
in a separate step is useful for creating tables and plots before running
a first stage linear regression.
