standardize_bounds {ss3sim}R Documentation

Standardize the bounds of the estimation model control file.

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

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

## 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)

[Package ss3sim version 1.0.3 Index]