Loops over a subset of control file to change parameter lines.
Current initial value, lower and upper bounds, and phase can be modified,
but function could be expanded to control other columns.
Depends on SS_parlines
.
Used by SS_profile
and the ss3sim package.
SS_changepars(dir = NULL, ctlfile = "control.ss_new",
newctlfile = "control_modified.ss", linenums = NULL, strings = NULL,
newvals = NULL, repeat.vals = FALSE, newlos = NULL, newhis = NULL,
estimate = FALSE, verbose = TRUE, newphs = NULL)
Directory with control file to change.
Control file name. Default="control.ss_new".
Name of new control file to be written. Default="control_modified.ss".
Line numbers of control file to be modified. Either this or
the strings
argument are needed. Default=NULL.
Strings (with optional partial matching) indicating which
parameters to be modified. This is an alternative to linenums
.
strings
correspond to the commented parameter names included in
control.ss_new
, or whatever is written as comment at the end
of the 14 number parameter lines. Default=NULL.
Vector of new parameter values. Default=NULL.
The vector can contain NA
values, which will assign the original
value to the given parameter but change the remainder parameters, where
the vector of values needs to be in the same order as either
linenums
or strings
.
If multiple parameter lines match criteria, repeat the
newvals
input for each line.
Vector of new lo bounds. Default=NULL.
The vector can contain NA
values, which will assign the original
value to the given parameter but change the remainder parameters, where
the vector of values needs to be in the same order as either
linenums
or strings
.
Vector of new hi bounds. Must be the same length as newhis
Default=NULL.
The vector can contain NA
values, which will assign the original
value to the given parameter but change the remainder parameters, where
the vector of values needs to be in the same order as either
linenums
or strings
.
Vector of TRUE/FALSE for which changed parameters are to be
estimated. Default=FALSE. Can also be NULL
.
More detailed output to command line. Default=TRUE.
Vector of new phases. Can be a single value, which will be
repeated for each parameter, the same length as newvals, where each
value corresponds to a single parameter, or NULL
, where the
phases will not be changed. If one wants to strictly turn parameters
on or off and not change the phase in which they are estimated use
estimate = TRUE
or estimate = FALSE
, respectively.
The vector can contain NA
values, which will assign the original
value to the given parameter but change the remainder parameters, where
the vector of values needs to be in the same order as either
linenums
or strings
.
# NOT RUN {
# }
# NOT RUN {
SS_changepars(dir='Y:/ss/SSv3.03a/Simple/',ctlfile='Control.SS_New',
strings=c('SR_steep','SR_sigmaR'),newvals=c(.35,.6))
# [1] wrote new file to Control_Modified.SS
# oldvals newvals oldphase newphase comment
# 1 0.609048 0.35 4 -4 # SR_steep
# 2 0.600000 0.60 -4 -4 # SR_sigmaR
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab