JAGS on Hopper
Set up R and JAGS in your own Hopper account, run a small Bayesian model, and download the results. No administrator install needed.
Tested October 2026 on Hopper with R 4.5.3, JAGS 4.3.2 and jagsUI 1.6.3. Setup takes 20–30 minutes plus any queue wait; see Testing and references.
What you'll build
R and JAGS in a Conda environment in your own Hopper account, and a starter project that submits models as Slurm jobs and writes results and plots you can download.
Quick start
Already have a Hopper account and the JAGS environment? Download the starter (step 1), then run this in the extracted folder. If you have Conda but not the environment, run bash setup.sh first. Otherwise, start with Before you start.
source ./activate.sh
bash submit.sh
The first time, enter your Slurm account and partition when asked; they're remembered for this folder. Then check the job:
bash status.sh
Before you start
- A Hopper account, and your college VPN to reach it.
- A terminal: macOS or Linux Terminal, or Windows PowerShell. Commands labelled On your computer run there; On Hopper means after you log in, where the prompt reads like
[you@hopper ~]$. - Your Slurm account name. Step 2 shows how to find it.
- About 410 MB of downloads if you also need Conda, and several GB of disk quota.
Copy one command block at a time, and stop if one fails. Model fitting runs as a scheduled job, never on the login node.
1. Connect and download
-
Connect to your college VPN. Then log in, replacing
YOUR_USERNAMEwith your Hopper username:ssh YOUR_USERNAME@hopper.mckenna.eduThe first time you connect, SSH asks whether to trust the server. Find the algorithm your prompt names and compare its SHA256 fingerprint before typing
yes. If the key differs, don't connect; ask Hopper support.Algorithm SHA256 fingerprint ED25519 SHA256:jt8F40xEaVV+ITKozzR5jFrfJTe7O5HhQg9vS8w73dUECDSA SHA256:o32TmYIa3Qxl8KNcD8dLc5QwV75oA8fvIqiTbZ+H3v4RSA SHA256:GpcwMVW4H/Mo664eVBwb8x5aYzrm6CtE+BAyP00QPOYRead on October 5, 2026 over an established, authenticated connection to
hopper.mckenna.edu. This is a dated observation, not an administrator's key notice.Then type your password; nothing appears as you type.
-
Download and extract the starter on Hopper:
mkdir -p "$HOME/jags-workshop" cd "$HOME/jags-workshop" curl -fL -O https://www.cs.hmc.edu/~ndodds/guides/hopper-jags/hopper-jags-starter.zip unzip -n hopper-jags-starter.zip cd hopper-jags-starterunzip -nkeeps files that are already there. To use a later starter release, extract it into a new folder so it doesn't mix with your edited model. Ifunzipisn't available, extract the ZIP on your computer and copy the folder over withscp.
Download starter ZIP The same ZIP as at the top of the page.
The download contains:
| File | Purpose |
|---|---|
setup.sh, install-jagsUI.R | Install the tested software versions |
activate.sh | Activate the environment after each login |
hello.R, run.sbatch | Example model and Slurm job script |
submit.sh, status.sh | Submit jobs and check their results |
research-template.R | Starting structure for your own model |
guide.html, README.md | Offline instructions |
validated-demo.pdf | Reference plots |
VALIDATION.txt | What was tested and what remains untested |
2. Check your account
You log in to a login node to edit files and submit work. Slurm, the scheduler, runs jobs on compute nodes. A partition is a queue with resource and time limits. A Slurm account identifies your allocation; it may differ from your username or lab group.
hostname
uname -m
printf 'Shell: %s\n' "$SHELL"
command -v conda
module list
sinfo -s
sacctmgr -nP show assoc where user="$USER" format=Account,Partition
- Expect
hopperin the hostname,x86_64for the architecture, and a Bash shell such as/bin/bash. If you use another shell, runbashfirst. - No output from
command -v condajust means Conda isn't loaded yet. - If an R module is listed, run
module unload R; this guide uses the environment's own R. - An account row such as
standard|debugmeans that account can usedebug. A row such asstandard|has no partition restriction in that association, though other access rules may still apply.sinfo -slists queue names and limits. - If the account list is empty or your queue is unclear, ask support.
Note your account name for the first submission. The demo uses two cores, 2 GB of RAM and five minutes. Hopper's debug limit was one hour when tested; main allows up to three days, subject to account policy. Check your quota if space is tight.
3. Make Conda available
This step installs Miniforge, a minimal Conda, in your home directory. Any working Miniconda, Miniforge or Anaconda is enough, so check for one first; the first two items let you skip ahead if you have one.
-
Check whether Conda already works:
conda --versionIf it prints a version, load it and continue to step 4:
source "$(conda info --base)/etc/profile.d/conda.sh" -
If not, look for an installation that isn't loaded:
ls -d "$HOME/miniconda3" "$HOME/miniforge3" "$HOME/anaconda3" 2>/dev/nullIf one is listed, load it, then continue to step 4. This loads
miniconda3; useminiforge3oranaconda3instead if that's what you have:source "$HOME/miniconda3/etc/profile.d/conda.sh" conda --version -
Otherwise, install Miniforge. These are Linux commands run on Hopper, even if your computer is a Mac or Windows machine. They download a versioned installer from the official Miniforge project and its checksum, and verify it:
mkdir -p "$HOME/software-installers" cd "$HOME/software-installers" curl -fL -O https://github.com/conda-forge/miniforge/releases/download/26.7.2-0/Miniforge3-26.7.2-0-Linux-x86_64.sh curl -fL -O https://github.com/conda-forge/miniforge/releases/download/26.7.2-0/Miniforge3-26.7.2-0-Linux-x86_64.sh.sha256 sha256sum -c Miniforge3-26.7.2-0-Linux-x86_64.sh.sha256Continue only if the result ends in
OK:./Miniforge3-26.7.2-0-Linux-x86_64.sh: OK -
Run the installer:
bash Miniforge3-26.7.2-0-Linux-x86_64.shPress Enter to read the license, type
yesif you accept it, press Enter for the default location, and answernoto shell initialization. If the destination already exists, load that installation instead of replacing it. -
When the prompt returns, load Conda and go back to the starter:
source "$HOME/miniforge3/etc/profile.d/conda.sh" conda --version cd "$HOME/jags-workshop/hopper-jags-starter"
4. Install and activate JAGS
-
For a new environment, run the setup once:
cd "$HOME/jags-workshop/hopper-jags-starter" bash setup.shIt installs R, JAGS and their dependencies from conda-forge into
$HOME/.conda/envs/jags, then installs jagsUI from CRAN, accepting the Conda package plan automatically. If the environment already exists, skip this step. -
Activate and verify:
source ./activate.sh command -v R Rscript Rscript --vanilla -e 'cat(R.version.string,"\n"); library(rjags); library(jagsUI); print(jags.version()); print(packageVersion("jagsUI"))'
R and Rscript are inside .conda/envs/jags/bin, and the versions are R 4.5.3, JAGS 4.3.2 and jagsUI 1.6.3. A message that traceplot is “masked” is normal: two packages define a function with that name.
The helper saves your Conda path in conda-base.txt. After each new login, go back to the folder and run source ./activate.sh. Scheduled jobs use the same helper.
5. Submit your first model
-
Submit the example:
bash submit.shThe first time, enter your Slurm account and a partition you're authorized for, usually
debugfor this short test. Once Slurm accepts the job, the helper saves them in.slurm-settingsand the job ID inlast-job-id.txt, so they survive reconnecting. Later submissions show the saved values first. -
Check on it:
bash status.shA pending job is waiting for resources and a running job needs more time; check again later.
Success shows the PASS line and a completed job with exit code 0:0. Your job ID will differ.
PASS: parallel JAGS sampling completed successfully.
JobID State ExitCode
366462 COMPLETED 0:0
366462.batch COMPLETED 0:0
The job writes hello-fit.rds, hello-summary.csv, hello-diagnostics.pdf and hello-session.txt. Email your job ID and PASS line to ndodds@g.hmc.edu.
- To use another queue, run
bash submit.sh --partition mainif you're authorized formain. - To enter the account and partition again, run
bash submit.sh --reset. - Resource options aren't saved; each run starts from the defaults in
run.sbatchunless you pass options.
Each run replaces the last results
Running again in the same folder replaces the result files. Finish one run before starting another, and use separate project copies to keep experiments apart.
6. Read the results
Open another terminal on your computer and change to the folder where you want the results. Replace YOUR_USERNAME:
scp 'YOUR_USERNAME@hopper.mckenna.edu:~/jags-workshop/hopper-jags-starter/hello-*' .
Open the CSV and PDF. The reference PDF shows the same example.


How the numerical check works
The observations are 1.8, 2.1, 2.0, 1.9, 2.2, with standard deviation fixed at 1. The prior for the mean has mean 0 and standard deviation 10. JAGS works in precision (1 divided by variance), so the model uses precisions 1 and 0.01.
The analytic posterior mean is 10 / 5.01 ≈ 1.996, with standard deviation sqrt(1 / 5.01) ≈ 0.447. The check needs finite draws and a sampled mean within 0.15 of the analytic mean. It keeps 1,500 samples per chain (3,000 in total) after 500 adaptation iterations.
It's a software check. Passing it, or an Rhat near 1, says nothing about another model's assumptions or convergence.
Try a small change
-
Open the example:
nano hello.R - Change
y <- c(1.8, 2.1, 2.0, 1.9, 2.2)toy <- c(2.8, 3.1, 3.0, 2.9, 3.2). Save with Control + O and Enter, then exit with Control + X. - Run
bash submit.shandbash status.shagain. The expected mean becomes15 / 5.01 ≈ 2.994, and the check adjusts automatically. - Put the original observations back when you're done.
7. Run your research model
-
Copy the starter to a new project folder.
my-projectmust not already exist; pick another name if it does.cd "$HOME/jags-workshop" cp -r hopper-jags-starter my-project cd my-project cp research-template.R analysis.R source ./activate.sh -
Edit
analysis.Rto load your data and JAGS model. The template deliberately stops until you replace its example. It already uses the Slurm CPU allocation, saves results and records R session information.If we're working through your model together, bring your script, a small dataset, your package list and any custom JAGS modules.
-
Submit it to
mainor another longer partition you're authorized for, notdebugwith its one-hour limit. This example asks for four cores, 4 GB of RAM and two hours; adjust for your model and account limits.bash submit.sh analysis.R --partition main --cpus-per-task 4 --mem 4G --time 02:00:00bash status.sh
The copied folder keeps your saved account, and a successful submission saves main as this project's partition. The helper accepts --account, --partition, --cpus-per-task, --mem, --time and --job-name, as --name value or --name=value; see bash submit.sh --help.
Paths are relative to the project folder. Rscript --vanilla doesn't restore a saved workspace, so load all data and packages explicitly. Keep parallel workers within your allocated CPUs. Start small, check resource use with status.sh, and look at mixing, effective sample size, Rhat and model-specific diagnostics before interpreting results.
8. Keep a reproducibility record
Once your model runs, save its environment alongside the code, the input data version, seeds and job settings:
source ./activate.sh
conda list --explicit > conda-linux-64-explicit.txt
conda env export --no-builds > environment-record.yml
Rscript --vanilla -e 'write.csv(installed.packages()[,c("Package","Version","LibPath")], "r-packages.csv", row.names=FALSE); writeLines(capture.output(sessionInfo()), "session-info.txt")'
Conda's exports don't fully describe jagsUI, which comes from CRAN, so keep install-jagsUI.R and r-packages.csv too. The installer picks jagsUI 1.6.3 from current CRAN or, if needed, CRAN's archive.
Recreate the environment
From a folder with the export and installer files, create a new environment. This accepts the exported package plan automatically:
conda create --yes --prefix "$HOME/.conda/envs/jags-reproduced" --file conda-linux-64-explicit.txt
conda activate "$HOME/.conda/envs/jags-reproduced"
Rscript --vanilla install-jagsUI.R
This was tested on Hopper, including a successful scheduled demo in the rebuilt environment. To use it with the helpers, run export JAGS_ENV_PREFIX="$HOME/.conda/envs/jags-reproduced" before activating and submitting; unset JAGS_ENV_PREFIX returns to the default. The exports work on compatible Hopper Linux systems, not on your Mac or Windows R.
Troubleshooting
| Symptom | What to do |
|---|---|
conda: command not found | Load your existing installation (step 3), or install Miniforge. |
Run 'conda init' before 'conda activate' | Use source ./activate.sh, or source your installation's conda.sh. |
Permission denied when logging in | Check the VPN, username and password; contact support if it continues. |
Permission denied during setup | Make sure the destination is in your own home directory. |
| Environment already exists | Skip setup, then activate and verify. |
there is no package called ... | Check which R is active and read the first installation error. |
| rjags can't find JAGS | Use R and JAGS from the same Conda environment. |
Invalid account or account/partition combination specified | Check your account list; retry with --reset or give the account and partition explicitly. |
| Saved settings are wrong or garbled | Run bash submit.sh --reset. Settings are only saved after a submission is accepted. |
No log, or the job is PENDING | Wait for resources, then check the status again. |
OUT_OF_MEMORY, TIMEOUT, or no PASS | Read the log before changing resource requests. |
| Quota or checksum error | Stop and keep the error; check your quota or retry the official download. |
For help, email ndodds@g.hmc.edu or hpc-help@its.cmc.edu with your command, the full error, the job ID and the log. Never send a password. To cancel one of your jobs, run scancel followed by its job ID.
Testing and references
The example, a fresh installation, Miniforge setup, the plots and the downloaded starter were tested on Hopper; VALIDATION.txt in the ZIP has the details. Your own access and research dependencies still need checking.
The Miniforge installer was tested in batch mode, while this guide uses its interactive prompts. The fallback to CRAN's archive hasn't been exercised, because jagsUI 1.6.3 is still on current CRAN.