standardize_bounds: Standardize the bounds of the estimation model control file.

Description Usage Arguments Author(s) Examples

View source: R/standardize_bounds.R

Description

Function to standardize the bounds of the control file in the estimation model. This function first checks to ensure the initial values in the estimation model control file are set to the true values of the om_ctl_file and if not sets them for every parameter. Next, the function adjusts the LO and HI values in the em_ctl_file to be a fixed percentage of the initial value for every parameter.

Usage

1
2
standardize_bounds(percent_df, dir, em_ctl_file, om_ctl_file = "",
  verbose = FALSE, estimate = NULL, ...)

Arguments

percent_df

A data.frame with nine rows and three columns. The first column is the parameter. The second column is the percent of the initial parameter value LO is set to. The third column is the percent of the initial parameter value HI is set to.

dir

A path to the directory containing the model files.

em_ctl_file

A string with the name of the estimation model control file. em_ctl_file must be located in dir.

om_ctl_file

A string with the name of the operating model control file. If it is not given the part of the function which matches the OM and EM INIT values is ignored. Default is "". om_ctl_file must be located in dir.

verbose

Detailed output to command line. Default is FALSE.

estimate

A logical for which changed parameters are to be estimated. Used by SS_changepars, where in r4ss the default is FALSE, which turns all parameter estimation off. Here the default is NULL, which will leave parameter phases unchanged.

...

Any other arguments to pass to SS_changepars.

Author(s)

Christine Stawitz

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
## Not run: 
temp_path <- file.path(tempdir(), "standardize-bounds-example")
dir.create(temp_path, showWarnings = FALSE)
wd <- getwd()
setwd(temp_path)
on.exit(setwd(wd), add = TRUE)

## Set to the path and filename of the OM and EM control files
OM.ctl <- system.file("extdata", "models", "cod-om", "codOM.ctl",
  package = "ss3sim")
EM.ctl <- system.file("extdata", "models", "cod-em", "codEM.ctl",
  package = "ss3sim")
file.copy(OM.ctl, "om.ctl")
file.copy(EM.ctl, "em.ctl")

## Use SS_parlines to get the proper names for parameters for the data frame
em.pars <- r4ss::SS_parlines(ctlfile = "em.ctl")

## Set percentages to make lower and upper bounds
lo.percent<-rep(.5,11)
hi.percent<-c(500,1000,1000,rep(500,8))

##Populate data frame using EM parameter names and percentages
percent_df<-data.frame(Label=as.character(em.pars[c(1:6,17,27:30),"Label"]),
  lo=lo.percent,hi=hi.percent)

##Run function
standardize_bounds(percent_df = percent_df, dir = ".",
                   em_ctl_file = "em.ctl",
                   om_ctl_file = "om.ctl")
unlink("om.ctl")
unlink("em.ctl")
unlink(temp_path, recursive = TRUE)

## End(Not run)

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