change_em_binning: Change population and observed length composition bins in an...

Description Usage Arguments Author(s) See Also Examples

View source: R/change_em_binning.r

Description

change_em_binning alters the bin structure for the population and length composition data in an SS estimation model. It is done by taking the original length composition info from the EM ss3.dat then changing according to the user's specification. If the data file also contains conditional age-at-length data then these data will be re-binned as well.

Usage

1
2
3
change_em_binning(dat_list, outfile = NULL, bin_vector,
  lbin_method = NULL, pop_binwidth = NULL, pop_minimum_size = NULL,
  pop_maximum_size = NULL)

Arguments

dat_list

An SS data list object as read in from SS_readdat in the r4ss package. Make sure you select option section=2.

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 NULL, which leads to increased speed because writing the file takes time and computing resources.

bin_vector

A numeric vector of new length bins to substitute into the ss3.dat file.

lbin_method

A numeric value of either NULL, 1, 2, 3 to change the lbin_method for the population bin. Only supports either NULL, 1, 2 at the moment. NULL means to keep it unchanged.

pop_binwidth

*Population length bin width. Only necessary for lbin_method=2. Note that this value must be smaller than the bin width specified in length composition data len_bins or SS3 will fail (see notes in the SS3 manual).

pop_minimum_size

*Population minimum length bin value. 'Only necessary for lbin_method=2

pop_maximum_size

*Population maximum length bin value. Only necessary for lbin_method=2

Author(s)

Kotaro Ono (length-composition rebinning), Sean Anderson (conditional age-at-length rebinning)

See Also

Other change functions: change_data, change_e, change_f_par, change_f, change_o, change_retro, change_tv

Examples

 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
41
42
43
44
45
46
# Note that typically this function is used with estimation models in ss3sim,
# but it is used with an operating model data file in the following examples.
f <- system.file("extdata", "models", "cod-om", "codOM.dat", package = "ss3sim")
d <- r4ss::SS_readdat(f, version = NULL, verbose = FALSE)

# An example with lbin_method = 1
l1 <- change_em_binning(d, outfile = NULL, lbin_method = 1,
  bin_vector = seq(20, 152, by = 4))
l1$lbin_vector
head(l1$lencomp)

#An example with lbin_method = 2
new_bin_vec <- seq(min(d$lbin_vector), max(d$lbin_vector), by = 4)
# add the max value if necessary.
if(new_bin_vec[length(new_bin_vec)] != d$lbin_vector[length(d$lbin_vector)]){
  new_bin_vec <- c(new_bin_vec,
                   d$lbin_vector[length(d$lbin_vector)])
}
pop_bin_input <- 5
pop_min_size_input <- min(d$lbin_vector_pop) - 1
pop_max_size_input <- max(d$lbin_vector_pop) + 5
lbin_vec_pop <-seq(pop_min_size_input,
                   pop_max_size_input,
                   length.out = (pop_max_size_input - pop_min_size_input)/
                     pop_bin_input + 1
)
l2 <- change_em_binning(dat_list = d,
                            bin_vector = new_bin_vec,
                            lbin_method = 2,
                            #Note: need more inputs with lbin_method = 2
                            pop_binwidth = pop_bin_input,
                            pop_minimum_size = pop_min_size_input,
                            pop_maximum_size = pop_max_size_input)
l2$lbin_method
# note bin width is now the same as the input
pop_bin_input
l2$binwidth
# note the minimum size has changed based on the input:
pop_min_size_input
l2$minimum_size
# so has max
l2$maximum_size
l2$lbin_vector
#other modified components:
l2$lbin_vector_pop
head(l2$lencomp)

ss3sim documentation built on Nov. 9, 2019, 1:06 a.m.