SS_RunJitter: Iteratively apply the jitter option in SS

View source: R/SS_RunJitter.R

SS_RunJitterR Documentation

Iteratively apply the jitter option in SS

Description

Iteratively run a Stock Synthesis model with different jittered starting parameter values based on the jitter fraction. Output files are renamed in the format Report1.sso, Report2.sso, etc.

Usage

SS_RunJitter(
  mydir,
  model = "ss",
  extras = "-nohess",
  Njitter,
  Intern = TRUE,
  systemcmd = FALSE,
  printlikes = TRUE,
  verbose = FALSE,
  jitter_fraction = NULL,
  init_values_src = NULL
)

Arguments

mydir

Directory where model files are located.

model

Name of the Stock Synthesis model file (which has the .exe for on Windows) in mydir without the extension (if any), e.g., "ss" or "ss_win".

extras

Additional command line arguments passed to the executable. The default, "-nohess", runs each jittered model without the hessian.

Njitter

Number of jitters, or a vector of jitter iterations. If length(Njitter) > 1 only the iterations specified will be ran, else 1:Njitter will be executed.

Intern

Show command line info in R console or keep hidden. The default, TRUE, keeps the executable hidden.

systemcmd

Option to switch between 'shell' and 'system'. The default, FALSE, facilitates using the shell command on Windows.

printlikes

A logical value specifying if the likelihood values should be printed to the console.

verbose

A logical value specifying if output should be printed to the screen.

jitter_fraction

The value, typically 0.1, used to define a uniform distribution in cumulative normal space to generate new initial parameter values. The default of NULL forces the user to specify the jitter_fraction in the starter file, and this value must be greater than zero and will not be overwritten.

init_values_src

Either zero or one, specifying if the initial values to jitter should be read from the control file or from the par file, respectively. The default is NULL, which will leave the starter file unchanged.

Value

A vector of likelihoods for each jitter iteration.

Author(s)

James T. Thorson, Kelli F. Johnson, Ian G. Taylor

Examples

## Not run: 
#### Run jitter from par file with arbitrary, but common, choice of 0.1
modeldir <- tail(dir(system.file("extdata", package = "r4ss"), full.names = TRUE), 1)
numjitter <- 25
jit.likes <- SS_RunJitter(
  mydir = modeldir, Njitter = numjitter,
  jitter_fraction = 0.1, init_value_src = 1
)

#### Read in results using other r4ss functions
# (note that un-jittered model can be read using keyvec=0:numjitter)
profilemodels <- SSgetoutput(dirvec = modeldir, keyvec = 1:numjitter, getcovar = FALSE)
# summarize output
profilesummary <- SSsummarize(profilemodels)
# Likelihoods
profilesummary[["likelihoods"]][1, ]
# Parameters
profilesummary[["pars"]]

## End(Not run)


r4ss documentation built on May 28, 2022, 1:11 a.m.