Obtaining and editing the code
Model development can be done in several different ways. In order of most difficult to least difficult the options are:
- Creating a branch of the
sbt
repository, cloning the branch, editing thesbt_model.cpp
and/orsbt_functions.hpp
files, testing the code, rebuilding the R package, pushing the edits, then merging the branch with the main repository. - Cloning the main
sbt
repository, editing thesbt_model.cpp
and/orsbt_functions.hpp
files, testing the code, rebuilding the R package, pushing the edits to the main repository. - Copying the
sbt_model.cpp
andsbt_functions.hpp
files to a local directory, editing the files, and then compiling and running as outlined below.
Compiling and running the model
Compile and load the model - this should not be required when integrated with package, but another version should be created that does this anyway (i.e., a dev version).
library(TMB)
library(tidyverse)
library(sbt)
theme_set(theme_bw())
# compile("src/sbt_v100.cpp")
# dyn.load(dynlib("src/sbt_model"))
# Create the AD object
# obj <- MakeADFun(data = Data, parameters = Params, map = Map, random = Random,
# hessian = TRUE, inner.control = list(maxit = 50),
# DLL = "sbt")
Rebuilding the website
The website can be rebuilt using:
pkgdown::build_site()
See https://pkgdown.r-lib.org/index.html or https://github.com/r-lib/pkgdown for a detailed
description of pkgdown
.
Some helpful references
- Vectors, matrices, and arrays in TMB: https://kaskr.github.io/adcomp/matrix_arrays_8cpp-example.html
- Things you should not do in TMB: https://github.com/kaskr/adcomp/wiki/Things-you-should-NOT-do-in-TMB
- The WHAM stock assessment model written in TMB: https://github.com/timjmiller/wham
- How to maintain NEWS file: https://blog.r-hub.io/2020/05/08/pkg-news/
- Kable tables: https://rstudio-pubs-static.s3.amazonaws.com/444395_76727eaf9c774fa8bf932bed16500a00.html