Skip to contents

Subroutine to run chosen discrete choice model. Function pulls necessary data generated in make_model_design and loops through model design choices and expected catch cases. Output is saved to the FishSET database.

Usage

discretefish_subroutine(
  project,
  run = "new",
  select.model = FALSE,
  explorestarts = TRUE,
  breakearly = TRUE,
  space = NULL,
  dev = NULL,
  use.scalers = FALSE,
  scaler.func = NULL,
  CV = FALSE
)

Arguments

project

String, name of project.

run

String, how models should be run. 'new' will only run models that exist in the model design file but not in the model output table. 'all' will run all models in the model design file, replacing existing model output. The third option is to enter a vector of model names to run (use model_names() to see current model names). If the specified model already has output it will be replaced.

select.model

Return an interactive data table that allows users to select and save table of best models based on measures of fit.

explorestarts

Logical, should starting parameters value space be explored? Set to TRUE if unsure of the number of starting parameter values to include or of reasonable starting parameters values. Better starting parameter values can help with model convergence.

breakearly

Logical, if explorestarts = TRUE, should the first set of starting parameter values that returns a valid (numeric) loglikelihood value be returned (TRUE) or should the entire parameter space be considered and the set of starting parameter values that return the lowest loglikelihood value be returned (FALSE).

space

Specify if explorestarts = TRUE. List of length 1 or length equal to the number of models to be evaluated. space is the number of starting value permutations to test (the size of the space to explore). The greater the dev argument, the larger the space argument should be.

dev

Specify if explorestarts = TRUE. List of length 1 or length equal to the number of models to be evaluated. dev refers to how far to deviate from the average parameter values when exploring (random normal deviates). The less certain the average parameters are, the greater the dev argument should be.

use.scalers

Logical, should data be normalized? Defaults to FALSE. Rescaling factors are the mean of the numeric vector unless specified with scaler.func.

scaler.func

Function to calculate rescaling factors. Can be a generic function, such as mean, or a user-defined function. User-defined functions must be specified as scaler.fun = function(x, FUN = sd) 2*FUN(x). This example returns two times the standard deviation of x.

CV

Logical, CV = TRUE when running discretefish_subroutine for k-fold cross validation, and the default value is CV = FALSE.

Value

OutLogit:[outmat1 se1 EPM2] (coefs, ses, tstats)optoutput:optimization information
seoumat2:sesMCM:Model Comparison metrics

Details

Runs through model design choices generated by make_model_design and stored as `ModelInputData` in FishSET database. Data matrix is created in create_model_input. Required data, optional data, and details on likelihood functions are outlined in make_model_design.

Likelihood-specific initial parameter estimates:

  1. Conditional logit likelihood (logit_c)
    Starting parameter values takes the order of: c([alternative-specific parameters], [travel-distance parameters]). The alternative-specific parameters and travel-distance parameters are of length (# of alternative-specific variables) and (# of travel-distance variables) respectively.

  2. Zonal logit with area specific constants (logit_zonal)
    Starting parameters takes the order of: c([average-catch parameters], [travel-distance parameters]). The average-catch and travel-distance parameters are of length (# of average-catch variables)*(k-1) and (# of travel-distance variables) respectively, where (k) equals the number of alternative fishing choices.

  3. Full information model with Dahl's correction function (logit_correction)
    Starting parameter values takes the order of: c([marginal utility from catch], [catch-function parameters], [polynomial starting parameters], [travel-distance parameters], [catch sigma]). The number of polynomial interaction terms is currently set to 2, so given the chosen degree 'polyn' there should be "(((polyn+1)*2)+2)*(k)" polynomial starting parameters, where (k) equals the number of alternative fishing choices. The marginal utility from catch and catch sigma are of length equal to unity respectively. The catch-function and travel-distance parameters are of length (# of catch variables)*(k) and (# of cost variables) respectively.

  4. Expected profit model with normal catch function (epm_normal)
    Starting parameters values take the order of: c([catch-function parameters], [travel-distance parameters], [catch sigma(s)], [scale parameter]). The catch-function and travel-distance parameters are of length (# of catch-function variables)*(k) and (# of travel-distance variables) respectively, where (k) equals the number of alternative fishing choices. The catch sigma(s) are either of length equal to unity or length (k) if the analyst is estimating location-specific catch sigma parameters. The scale parameter is of length equal to unity.

  5. Expected profit model with Weibull catch function (epm_weibull)
    Starting parameter values takes the order of: c([catch-function parameters], [travel-distance parameters], [catch sigma(s)], [scale parameter]). The catch-function and travel-distance parameters are of length (# of catch-function variables)*(k) and (# of travel-distance variables) respectively, where (k) equals the number of alternative fishing choices. The catch sigma(s) are either of length equal to unity or length (k) if the analyst is estimating location-specific catch sigma parameters. The scale parameter is of length equal to unity.

  6. Expected profit model with log-normal catch function (epm_lognormal)
    Starting parameter values takes the order of: c([catch-function parameters], [travel-distanceparameters], [catch sigma(s)], [scale parameter]). The catch-function and travel-distance parameters are of length (# of catch-function variables)*(k) and (# of travel-distance variables) respectively, where (k) equals the number of alternative fishing choices. The catch sigma(s) are either of length equal to unity or length (k) if the analyst is estimating location-specific catch sigma parameters. The scale parameter is of length equal to unity.


Model output are saved to the FishSET database and can be loaded to the console with:

model_out_view:model output including optimization information, standard errors, coefficients, and t- statistics.model_params:model estimates and standard error
model_fit:model comparison metricsglobalcheck_view:model error message

For obtaining catch, choice, distance, and otherdat data generated from make_model_design function. ModelInputData table will be pulled from FishSET database.

Examples

if (FALSE) {
results <- discretefish_subroutine("pcod", run = 'all', select.model = TRUE)
}