Skip to contents

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 the sbt_model.cpp and/or sbt_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 the sbt_model.cpp and/or sbt_functions.hpp files, testing the code, rebuilding the R package, pushing the edits to the main repository.
  • Copying the sbt_model.cpp and sbt_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.