runSims: Function to run TCSAM02 multiple times using initial...

View source: R/runSims.R

runSimsR Documentation

Function to run TCSAM02 multiple times using initial parameter values to create simulated data for fits.

Description

This functions runs a TCSAM02 model multiple times initial parameter values to create simulated data to assess model consistency and estimation bias.

Usage

runSims(
  os = "osx",
  path = ".",
  model = "tcsam02",
  path2model = "",
  configFile = "",
  pinFile = file.path(path, "tcsam02.pin"),
  numRuns = 3,
  minPhase = 1,
  out.csv = "simResults.csv",
  calcOFL = 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

pinFile
  • path to pin file w/ model parameters for simulation

numRuns
  • number of jitter runs to make

minPhase
  • phase in which to start optimization

out.csv
  • filename for summary simulation results

calcOFL
  • flag (T/F) to perform OFL calculations

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 in "fit sim" mode. Initial model parameters are taken from a preliminary model run and used as the basis for simulating data prior to fitting the model. 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/ 2 elements: dfrSmry - dataframe with seed, objective function, and other summary values from all model runs parList - list of par dataframes for each model run


wStockhausen/rTCSAM02 documentation built on Sept. 27, 2024, 6:52 a.m.