Install and Setup
Audience
Engineers and analysts setting up DSAMbayes for local development or modelling runs. This page is written for a Unix shell (Linux or macOS). If you are on Windows using RStudio, especially on a work-issued machine without full administrator rights, use Install and Setup (Windows / RStudio) instead.
Prerequisites
- R >= 4.1: check with
R --version. - A C++ toolchain for Stan compilation. This is the most common source of setup issues:
- macOS: install Xcode Command Line Tools (
xcode-select --install). - Windows: install Rtools matching your R version. Ensure
makeis on yourPATH. - Linux (Ubuntu/Debian):
sudo apt install build-essential. - See the RStan Getting Started Guide for detailed platform instructions.
- macOS: install Xcode Command Line Tools (
- A local checkout of this repository.
Quick setup (recommended)
Open a terminal in the repository root and run:
This keeps all package libraries and Stan compilation caches inside the repo, avoiding permission issues with system library paths.
Do not share a compiled package library between R runtimes or containers.
dsambayes_set_r_library host selects
.Rlib-host-r<active-R-version>/; use dsambayes_set_r_library container
inside a container instead. The path is deliberately derived from the active
runtime, not hard-coded in the repository.
Verify the installation
1. Confirm DSAMbayes loads
Expected: prints the installed package version.
2. Confirm the runner works
Expected: validation completes without errors.
3. (Optional) Run the test suite
Expected: all tests pass.
Alternative: install the private fork from GitHub
If you need only the package API and have read access to the private canonical repository, install it directly:
This installs the current package version from main. remotes reads
GITHUB_PAT from the environment for private-repository access. Keep the token
in your user environment or credential manager, never in a command, script, or
tracked file. Clone the repository instead when you need its example configs,
data, runme.R, or development tooling.
Using renv (optional)
The repository includes a renv.lock file for fully reproducible dependency management. To use it:
This installs the exact dependency versions used during development. It is optional but recommended for production runs where reproducibility matters.
Runner setup and first execution
1. Validate the example config
2. Execute a full run
Expected: a timestamped run directory is created under results/ with model outputs and diagnostics.
Troubleshooting
Stan compilation fails
Symptom: errors during Compiling model... referencing C++ or compiler issues.
Actions:
- Confirm your C++ toolchain is working:
R -q -e 'pkgbuild::has_build_tools(debug = TRUE)'. - On Windows, ensure Rtools is installed and
makeis on yourPATH. - Clear the Stan cache and retry:
rm -rf .cache/dsambayes. - Follow the RStan Getting Started Guide for your platform.
Package installation fails
Symptom: install.packages(".", repos = NULL, type = "source") errors.
Actions:
- Confirm you are in the repository root directory.
- Confirm the selected
R_LIBS_USERdirectory exists and is writable. - Check for missing system dependencies in the error output.
Stale Stan cache
Symptom: unexpected model behaviour after updating the package.
Actions:
- Clear the cache:
rm -rf .cache/dsambayes. - Re-run with
model.force_recompile: truein your config if you need to invalidate a stale compiled model.
Permission issues
Symptom: write failures for library, cache, or run outputs.
Actions:
- Ensure
R_LIBS_USER,.cache, andresults/are writable. - Keep
R_LIBS_USERandXDG_CACHE_HOMEset in your shell session. - Run all commands from the repository root.
Related pages
- Install and Setup (Windows / RStudio), setup guidance for admin-restricted Windows machines
- Quickstart (YAML Runner), first end-to-end run
- FAQ, short practical answers