A convenience wrapper that takes the outputs from run_sdmtmb(), diagnose(),
and calc_index_areas() when run with dir = NULL and writes them all to
disk in the same directory structure as the original indexwc code.
save_index_outputs(
fit,
diagnostics,
indices,
dir = getwd(),
dir_main = lifecycle::deprecated(),
overwrite = FALSE
)An sdmTMB model object returned by run_sdmtmb() with dir = NULL
A list returned by diagnose() with dir = NULL
A list returned by calc_index_areas() with dir = NULL
A string specifying a path where results will be saved. The
default is your current working directory. A subdirectory structure will be
created based on the species, survey, and model family. If NULL, the fitted
object is returned with nothing saved to disk
Deprecated. A string specifying a path where results will be saved. The
default is your current working directory. A subdirectory structure will be
created based on the species, survey, and model family. If NULL, the fitted
object is returned with nothing saved to disk
Logical. If TRUE, existing files will be overwritten. Default is FALSE
This function recreates the file structure that would have been created if you had
run run_sdmtmb(), diagnose(), and calc_index_areas() with directory arguments
specified from the start.
The directory structure created is:
dir/
└── species_name/
└── survey_name/
└── family_name/
├── data/
│ ├── data.rdata
│ └── fit.rds
├── diagnostics/
│ ├── mesh.png
│ ├── sanity_data_frame.csv
│ ├── aic_nll.txt
│ ├── run_diagnostics_and_estimates.rdata
│ ├── qq.png
│ ├── residuals_1_*.png
│ ├── residuals_2_*.png (if delta model)
│ ├── anisotropy.png
│ ├── fixed_effects.png
│ ├── density_*.png
│ ├── data_with_residuals.rdata
│ └── predictions.rdata
└── index/
├── est_by_area.csv
├── index_coastwide.png (if Coastwide calculated)
└── index_all_areas.pngrun_sdmtmb(), fit the model
diagnose(), run diagnostics
calc_index_areas(), calculate indices
if (FALSE) { # \dontrun{
# Pull and format data
my_data <- pull_and_format_data(
configuration_to_run = configuration[1,]
)
# Fit model without saving
fit <- run_sdmtmb(
data = my_data$data_filtered,
family = my_data$family,
formula = my_data$formula
)
# Run diagnostics without saving
diag <- diagnose(
fit = fit
)
# Calculate indices without saving
index <- calc_index_areas(
data = fit$data,
fit = fit,
boundaries = "Coastwide"
)
# Now save everything to disk
paths <- save_index_outputs(
fit = fit,
diagnostics = diag,
indices = index,
dir = fit$dir
)
} # }