# 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))
# }
Run the code above in your browser using DataLab