Split your data into a list of data frames, e.g., dplyr::split(data, common_name) and then use purrr::map() on the resulting list with .f = run_sdmtmb.

run(data, family, formula, dir_main = getwd(), n_knots = 500, ...)

Arguments

data

The data object being passed in

family

The name of the family used for the response variable

formula

The formula used in the model

dir_main

The name of the main directory

n_knots

The number of knots to specify for the SPDE mesh

...

Extra arguments

Value

A list of sdmTMB lists, where each element in the list is the returned object from sdmTMB::sdmTMB() when fitting data to a model and of the class sdmTMB. The list of lists is because purrr::map2() is used to split the input data by species and survey/source in case your data contain combinations of these two categories in a long data frame.