test_surveys | R Documentation |
This function allows a series of sampling design settings to be set and tested on the simulated population. True population values are compared to stratified estimates of abundance.
test_surveys(
sim,
surveys = expand_surveys(),
keep_details = 1,
n_sims = 1,
n_loops = 100,
cores = 2,
export_dir = NULL,
length_group = "inherit",
alk_scale = "division",
progress = TRUE,
...
)
resume_test(export_dir = NULL, ...)
sim |
Simulation from |
surveys |
A data.frame or data.table with a sequence of surveys and their settings
with a format like the data.table returned by |
keep_details |
Survey and stratified analysis details are dropped here to minimize object
size. This argument allows the user to keep the details of one
survey by specifying the survey number in the data.frame supplied to |
n_sims |
Number of times to simulate a survey over the simulated population. Requesting a large number of simulations here may max out your RAM. |
n_loops |
Number of times to run the |
cores |
Number of cores to use in parallel. More cores should speed up the process. |
export_dir |
Directory for exporting results as they are generated. Main use of the export
is to allow this process to pick up where |
length_group |
Size of the length frequency bins for both abundance at length calculations
and age-length-key construction. By default this value is inherited from
the value defined in |
alk_scale |
Spatial scale at which to construct and apply age-length-keys: "division" or "strat". |
progress |
Display progress bar and messages? |
... |
Arguments passed on to
|
Depending on the settings, test_surveys
may take a long time to run.
The resume_test
function is for resuming partial runs of test_surveys
.
Note that progress bar time estimates will be biased here by previous completions.
test_loop
is a helper function used in both test_surveys
and
resume_test
. CAUTION: while the dots construct is available in the resume_test
function, be careful adding arguments as it will change the simulation settings
if the arguments added were not specified in the initial test_surveys
run.
Adds a table of survey designs tested. Also adds details and summary
stats of stratified estimate error to the sim
list, ending with
"_strat_error"
or "_strat_error_stats"
. Error statistics
includes mean error ("ME"
), mean absolute error ("MAE"
),
mean squared error ("MSE"
), and root mean squared error ("RMSE"
).
Also adds a sample size summary table ("samp_totals"
) to the list.
Survey and stratified analysis details are not kept to minimize object size.
pop <- sim_abundance(ages = 1:20, years = 1:5) %>%
sim_distribution(grid = make_grid(res = c(10, 10)))
surveys <- expand_surveys(set_den = c(1, 2) / 1000,
lengths_cap = c(100, 500),
ages_cap = c(5, 20))
## This call runs 25 simulations of 8 different surveys over the same
## population, and then runs a stratified analysis and compares true vs
## estimated values. (Note: total number of simulations are low to decrease
## computation time for the example)
tests <- test_surveys(pop, surveys = surveys, keep_details = 1,
n_sims = 5, n_loops = 5, cores = 1)
library(plotly)
tests$total_strat_error %>%
filter(survey == 8, sim %in% 1:50) %>%
group_by(sim) %>%
plot_ly(x = ~year) %>%
add_lines(y = ~I_hat, alpha = 0.5, name = "estimated") %>%
add_lines(y = ~I, color = I("black"), name = "true") %>%
layout(xaxis = list(title = "Year"),
yaxis = list(title = "Abundance index"))
plot_total_strat_fan(tests, surveys = 1:8)
plot_length_strat_fan(tests, surveys = 1:8)
plot_age_strat_fan(tests, surveys = 1:8)
plot_age_strat_fan(tests, surveys = 1:8, select_by = "age")
plot_error_surface(tests, plot_by = "rule")
plot_error_surface(tests, plot_by = "samples")
plot_survey_rank(tests, which_strat = "length")
plot_survey_rank(tests, which_strat = "age")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.