Skip to contents
  1. Clone and cd into this git repo
  2. Make build_install.sh executable by running chmod +x build_install.sh in bash terminal
  3. In terminal, run ./build_install.sh to build and install the package
  4. To ensure a clean start, run:
rm -f src/*.o src/*.so
rm -rf wispack.Rcheck
rm -f wispack_*.tar.gz
./build_install.sh

Note that additional system dependencies are required before the building process. Below are instructions for Mac and Linux (Ubuntu/Debian). Installation on Windows should be possible, but is not currently tested or supported.

Mac

First, ensure your Mac has the necessary backend dependencies:

  1. Xcode developer tools: In terminal, run xcode-select --install and follow the instructions
  2. GNU Fortran compiler: Go to https://mac.r-project.org/tools/, then download and run the relevant gfortran-[version]-universal.pkg
  3. Follow the instructions at this same website to install LaTeX for R

(NLopt itself comes from the CRAN package nloptr, installed automatically as a dependency – no separate brew install nlopt/pkg-config step needed. nloptr builds its own copy of NLopt via CMake if no suitable system one is found, so a cmake install may be needed the first time nloptr itself installs.)

Install Homebrew if needed:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo >> /Users/[name]/.zprofile
echo 'eval "$(/opt/homebrew/bin/brew shellenv zsh)"' >> /Users/[name]/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv zsh)"

Rebuild and cleanly install Rcpp and Stan, in R: install.packages(c("Rcpp", "RcppEigen", "RcppParallel", "StanHeaders"))

Linux

Need to install the following system dependencies: - libxml2 for roxygen2 - r-base-dev for Rcpp, RcppEigen, and StanHeaders - cmake, only needed the first time the CRAN package nloptr itself installs, and only if no suitable system NLopt (>= 2.7.0) is already present for it to use instead - libhdf5-dev for hdf5 functionality (backs the hdf5r dependency)

For PDF documentation generation, pdflatex should also be installed

sudo apt install \
    libxml2 \
    r-base-dev \
    cmake \
    libhdf5-dev \
    texlive-latex-base \
    texlive-fonts-recommended \
    texlive-fonts-extra \
    texlive-latex-extra

Build documentation

In R, run:

devtools::document()
devtools::build_readme()
pkgdown::build_site()
pkgdown::build_article("<article name>")

build_readme() knits README.Rmd into README.md (via devtools::build_readme()); edit README.Rmd, not README.md directly – the latter is generated and gets overwritten.

Running the test suite

Wispack has a testthat suite under tests/testthat, split into two tiers:

  • Fast tier (runs by default, in well under a minute): synthetic data and precomputed fixtures only – no real model fitting against the data used in the tutorials. This is what runs automatically with R CMD check or:
devtools::test()
  • Slow tier (opt-in, several minutes): full-scale replications of the tutorial vignettes’ own fitted-value checks, using the same extdata and the same bootstrap/MCMC settings as the tutorials themselves. These are gated behind an environment variable so they don’t slow down routine testing:
Sys.setenv(WISPACK_RUN_SLOW_TESTS = "true")
devtools::test()

(equivalently, WISPACK_RUN_SLOW_TESTS=true Rscript -e 'devtools::test()' from the shell).

Both tiers read their expected numeric bounds from a single shared table (.wisp_golden, in R/golden_checks.R), which the tutorial vignettes’ own check chunks also read from – so a model-fitting change that shifts a tutorial’s narrative numbers will show up the same way whether you notice it by rebuilding the vignette or by running the test suite. If you deliberately change model-fitting behavior, re-run the slow tier and update the bounds in R/golden_checks.R (and the corresponding prose in whichever tutorial it affects) in the same commit.

System requirements

Wispack is computationally intense. Fitting all but the smallest models can easily use four or five Gb of RAM. We strongly recommend a modern multi-core Unix system (Apple Silicon or Linux) with at least 24 Gb of RAM, although realistically a workstation or compute cluster with 100+ Gb of available RAM and 20 or more cores are needed for realistic run times of complex models.