Description Usage Arguments Value Which arguments to specifiy in case files Author(s) See Also Examples
This function creates an index of abundance sampled from the expected
available biomass for given fleets in given years. Let B_y
be the biomass
from the operating model for year y. Then the sampled value is calculated as:
B_y*exp(rnorm(1, 0, sds_obs)-sds_obs^2/2)
. The second term
adjusts the random samples so that their expected value is B_y
(i.e. the
log-normal bias correction).
If used with run_ss3sim
the case file should be named
index
. A suggested (default) case letter is D
for data.
1 2 | sample_index(dat_list, outfile = NULL, fleets, years, sds_obs,
make_plot = FALSE)
|
dat_list |
An SS data list object as read in from
|
outfile |
A character string specifying the file name to use
when writing the information to the disk. The string must include
the proper file extension. No file is written using the default value
of |
fleets |
*A vector of integers specifying which fleets to include.
The order of the fleets pertains to the input order of other arguments.
An entry of |
years |
*A list the same length as |
sds_obs |
*A list the same length as |
make_plot |
A logical switch for whether to make a crude plot showing the results. Useful for testing and exploring the function. |
A modified .dat
file if !is.null(outfile)
. A list object
containing the modified .dat
file is returned invisibly.
All function argument descriptions that start with an asterisk (*) will be passed
through the case files to run_ss3sim
. If one of these arguments
is not specified in a case file, then a value of NULL
will be passed,
which may or may not be an appropriate value. Other arguments will be ignored
if specified.
Cole Monnahan, Kotaro Ono
Other sampling functions: clean_data
,
sample_agecomp
,
sample_calcomp
, sample_lcomp
,
sample_mlacomp
,
sample_wtatage
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | ## Not run:
# Find the example data location:
d <- system.file("extdata", package = "ss3sim")
f_in <- file.path(d, "example-om", "ss3_expected_values.dat")
dat_list <- r4ss::SS_readdat(f_in, version = NULL, verbose = FALSE)
# Note the initial expected values for the index data:
dat_list$CPUE # Only has expected values for fleet 2 in every other year from
# 76 to 100, so can only sample from fleet 2 during every other year between
# 76 and 100
sam_yrs <- seq(76, 100, by = 2)
ex1 <- sample_index(dat_list,
outfile = NULL,
fleets = 2,
years = list(sam_yrs),
sds_obs=list(seq(.001, .1,
length.out = length(sam_yrs))))
ex1$CPUE
# could sample from less years, but not more:
ex2 <- sample_index(dat_list,
outfile = NULL,
fleets = 2,
years = list(sam_yrs[c(-1, -2)]),
sds_obs=list(seq(.001, .1,
length.out = length(sam_yrs[c(-1, -2)]))))
ex2$CPUE
# Also, sd can be fixed across years:
ex3 <- sample_index(dat_list,
outfile = NULL,
fleets = 2,
years = list(sam_yrs),
sds_obs=list(0.01))
ex3$CPUE
# If fleet 1 also had expected values in the index that you wanted to sample:
# ex4 <- sample_index(dat_list,
# outfile = NULL,
# fleets = c(1,2),
# years = list(sam_yrs, sam_yrs),
# sds_obs=list(0.01, 0.01))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.