runJitter: Function to run TCSAM02 multiple times using jittered initial...

Description Usage Arguments Details Value

View source: R/runJitter.R

Description

This functions runs a TCSAM02 model multiple times, jittering the initial staarting values to assess model convergence.

Usage

1
2
3
4
5
6
7
8
runJitter(os = "osx", path = ".", model = "tcsam02",
  path2model = "", configFile = "", numRuns = 3, minPhase = 1,
  onlyEvalJitter = FALSE, in.csv = "jitterInfo.csv",
  out.csv = "jitterResults.csv", calcOFL = FALSE,
  calcOFLJitter = FALSE, mcmc = FALSE, mc.N = 1e+06,
  mc.save = 1000, mc.scale = 1000, saveResults = FALSE,
  cleanup = TRUE, keepFiles = c("tmp.sh", "tcsam02.par"),
  cleanupAll = FALSE)

Arguments

os

- 'win', 'mac', 'osx', or 'linux'

path

- path for model output

model

- TCSAM02 model executable name

path2model

- path to model executable

configFile

- path to model configuration file

numRuns

- number of jitter runs to make

minPhase

- phase in which to start optimization

onlyEvalJitter

- flag (T/F) to only evaluate a (previous) set of jitter runs, not make new runs

in.csv

- filename for jitter info (seed, obj fun value) from ADMB model run

out.csv

- filename for jittered results

calcOFL

- flag (T/F) to perform OFL calculations for "best" model

calcOFLJitter

- flag (T/F) to perform OFL calculations while jittering

mcmc

- flag (T/F) to run mcmc on "best" model

mc.N

- number of mcmc iterations to make

mc.save

- number of iterations to skip when saving mcmc calculations

mc.scale

- number of iterations to adjust scale for mcmc calculations

saveResults

- T/F to save final results to best/ModelResults.RData

cleanup

- T/F to clean up SOME model output files after each run

keepFiles

- vector of file names to keep, not clean up, after model run

cleanupAll

- T/F to clean up ALMOST ALL model output files after each run

Details

For each model run, this function creates a shell script ('./tmp.sh') in the working directory and uses it to run the ADMB version of the TCSAM02 model. Initial model parameters are jittered based on the system clock time as a seed to the random number generator. The seed and final objective function value are saved for each model run in a csv file (the value of out.csv).

When all the models requested have been run, the function determines the seed associated with the 1st model run that yielded the smallest value for the objective function and re-runs the model using this seed to re-create the model run resulting in the minimum objectve function to recreate the model output files. The final model run is done estimating the hessian, so standard deviations for estimated model parameters are available in the .std file.

Value

- list w/ 4 elements: imx - index of (1st) smallest value for the objective function seed - seed resulting in the smallest objective function par - dataframe with par results from run w/ smallest objective function objFuns - vector of objective function values from all model runs parList - list of par dataframes for each model run


wStockhausen/rTCSAM02 documentation built on Dec. 14, 2018, 2:09 p.m.