Skip to contents

Filter the out-of-sample dataset and prepare for predictions of fishing probability.

Usage

filter_outsample(
  dat,
  project,
  mod.name,
  spatial_outsample = FALSE,
  zone.dat = NULL,
  spat = NULL,
  zone.spat = NULL,
  outsample_zones = NULL,
  lon.spat = NULL,
  lat.spat = NULL,
  use.scalers = FALSE,
  scaler.func = NULL
)

Arguments

dat

Out-of-sample data

project

Name of project

mod.name

Name of saved model to use. Argument can be the name of the model or can pull the name of the saved "best" model. Leave mod.name empty to use the saved "best" model. If more than one model is saved, mod.name should be the numeric indicator of which model to use. Use table_view("modelChosen", project) to view a table of saved models.

spatial_outsample

Logical, indicate whether the data are out-of-sample spatially or not. Note that models with zone-specific coefficients (e.g., zonal logit) cannot be used to predict data that are out-of-sample spatially. spatial_outsample = FALSE can represent data out-of-sample temporally or out-of-sample based on another variable (e.g., vessel tonnage, gear type, etc.)

zone.dat

Variable in datthat identifies the individual areas or zones.

spat

Required, data file or character. spat is a spatial data file containing information on fishery management or regulatory zones boundaries. Shape, json, geojson, and csv formats are supported. geojson is the preferred format. json files must be converted into geoson. This is done automatically when the file is loaded with read_dat with is.map set to true. spat cannot, at this time, be loaded from the FishSET database.

zone.spat

Variable in spat that identifies the individual areas or zones.

outsample_zones

Vector of out-of-sample zones to filter dat. Only provided as input when running this function in the main app.

lon.spat

Required for csv files. Variable or list from spat containing longitude data. Leave as NULL if spat is a shape or json file.

lat.spat

Required for csv files. Variable or list from spat containing latitude data. Leave as NULL if spat is a shape or json file.

use.scalers

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

scaler.func

Input for create_model_input(). Function to calculate rescaling factors.

Value

Returns probability of logit model by choice

Details

This function filters the out-of-sample data. If the data is out-of-sample spatially, then set spatial_outsample = TRUE and provide a spatial file (spat) and the zone id in the spatial file zone.spat. An interactive map is used for selecting out of sample zones. If the data are not spatially out-of-sample, then just filter the data for the zones included in the selected model. Note that models with zone-specific coefficients (e.g., zonal logit) cannot predict spatial out-of-sample data. Upon successful execution of filter_outsample() the filtered dataset will be saved to an RDS file in the outputs folder. This function will overwrite the existing RDS file each time it is run.