MyNixOS website logo
Description

Bayesian Inversion of Leaf Wax Hydrogen Isotopes to Precipitation.

Bayesian inversion of leaf wax hydrogen isotopes to reconstruct precipitation isotopes using hierarchical spatial models. Provides fourteen Bayesian models that vary in their use of spatial Gaussian processes and ancillary covariates (precipitation amount, plant functional type, C4 fraction). Models are pre-computed using 'Stan' and stored as posterior distributions, so prediction does not require 'Stan' to be installed. A 100-draw fixture ships with the package; full 1000-draw posteriors are downloaded from a versioned 'Zenodo' deposit on first use; see Bradley (2026) <doi:10.5281/zenodo.20085465>.

leafwax

R-CMD-check DOI

Bayesian inversion of leaf-wax hydrogen isotope ratios (δ²Hwax) to precipitation isotope values (δ²Hprecip) and a defensibility framework for paleoclimate claims based on those reconstructions.

leafwax is the operational backend for the manuscript "Spatial modeling improves the calibration of leaf wax hydrogen isotopes to precipitation" (Bradley, Geochimica et Cosmochimica Acta, submitted). It exposes the 14 hierarchical Bayesian models reported there and the four-phase paleo workflow that the manuscript references in Sections 4.5.3, 4.5.5, and 4.5.6.

Installation

# install.packages("devtools")
devtools::install_github("bradleylab/leafwax")

The installed tarball ships a 100-draw "preview" fixture under inst/extdata/posteriors_light/ so the package builds and tests without network access. The preview tier is for code-path verification only — tail probabilities and 95% intervals are noisy at 100 draws. For inference, prefetch the full 1000-draw posteriors explicitly:

# Required before any inferential use. Downloads from
# bradleylab/leafwax-data v1.0.1 and caches under
# tools::R_user_dir("leafwax", "data").
leafwax::download_model_data("baseline_sp")

Heavy posteriors come from bradleylab/leafwax-data v1.0.1 (Zenodo DOI 10.5281/zenodo.20085465). Inversions done against the preview tier emit a loud warning naming the function context and the actual draw count; set options(leafwax.suppress_preview_warning = TRUE) to silence it in batch jobs that have already acknowledged the limitation.

Quick start: single-point inversion

library(leafwax)

result <- invert_d2H(
  d2H_wax    = -180,
  d2H_wax_sd = 3,
  longitude  = -90,
  latitude   = 38,
  model_name = "baseline_sp"
)

result[, c("d2h_precip_mean", "d2h_precip_sd",
           "d2h_precip_lower", "d2h_precip_upper")]

available_models() lists the 14 v10 model variants. Spatial models end in _sp and are recommended whenever site coordinates are known.

Paleo-record workflow

For a downcore series, the workflow combines four functions. The calibration's posterior residual SD (σresidual, ≈16 per mil for the spatial models) applies uniformly to absolute and within-record use; see the manuscript Section 4.5.3 for the derivation.

library(leafwax)

# 1. Raw per-draw local slope at the site
slope <- local_effective_slope(
  longitude  = -90,
  latitude   = 38,
  model_name = "baseline_sp"
)

# 2. Inversion with the defended slope
recon <- invert_d2H(
  d2H_wax    = record$d2h_wax,
  d2H_wax_sd = record$d2h_wax_err,
  longitude  = rep(-90, nrow(record)),
  latitude   = rep( 38, nrow(record)),
  model_name = "baseline_sp",
  slope      = slope,
  record_id  = "your_record_id",
  return_full = TRUE
)

# 3. Detection threshold + posterior P(change > magnitude)
rho_t <- estimate_temporal_autocorrelation(record$d2h_wax, record$age)
dc <- detect_change(
  reconstruction    = recon,
  age               = record$age,
  baseline_interval = c(0, 5000),
  test_intervals    = list(post = c(5000, 10000)),
  sigma_residual    = 16,
  rho_t             = rho_t,
  beta_eff          = stats::median(slope),
  confidence        = 0.95,
  magnitudes        = c(10, 30, 50)
)

# 4. Four-level taxonomy verdict on a published claim
verdict <- assess_claim(
  record         = record,
  claim          = list(level = 4, ...),     # see ?assess_claim
  reconstruction = recon
)
verdict$highest_level

The full sequence on a real Iso2k record is in vignette("paleo-record-workflow", package = "leafwax").

Available models

available_models() returns the 14 v10 variants. Capability flags are derived from the posterior parameter names, not the model id, so the routing layer correctly reflects what each fit actually contains.

ModelSpatial GPPrecipC4VegetationInteractions
baseline
baseline_spx
baseline_envx
baseline_env_spxx
baseline_vegxx
baseline_veg_spxxx
c4_only_spxx
elevation_only_spx
elevation_c4_spxx
elevation_c4_interact_spxxx
fullxxxx
full_spxxxxx
full_interactxxxx
full_interact_spxxxxx

The "Precip" column flags models that include a fitted precipitation-amount coefficient (beta_precip). The _env and _full* variants carry it; the elevation_* variants do not. The v10 fits did not produce beta_elev coefficients, so no model in the table propagates supplied elevation through the predictor linear combination — the historical "elevation_*" naming reflects the regional context the variants were designed for, not a fitted elevation effect.

Spatial models share a single 125-knot Fibonacci-sphere lattice.

Manuscript correspondence

The paleo workflow maps directly to the manuscript:

Manuscript sectionFunction
4.5.3 detection threshold formuladetect_change()
4.5.3 vegetation-only envelope (Level 2 magnitude path)compute_vegetation_envelope()
4.5.5 local slope posteriorlocal_effective_slope()
4.5.6 four-level claim taxonomyassess_claim()
Section S4 inversion machineryinvert_d2H()

Citation

Cite both the software archive and the related manuscript:

@software{bradley_leafwax_pkg_2026,
  author  = {Bradley, Alexander S.},
  title   = {leafwax: spatially-aware paleo-precipitation reconstruction
             from leaf-wax hydrogen isotopes},
  year    = {2026},
  doi     = {10.5281/zenodo.20172570},
  url     = {https://doi.org/10.5281/zenodo.20172570}
}

@unpublished{bradley_leafwax_paper_2026,
  author = {Bradley, Alexander S.},
  title  = {Spatial modeling improves the calibration of leaf wax
            hydrogen isotopes to precipitation},
  year   = {2026},
  note   = {Manuscript in preparation}
}

The @software DOI is the concept DOI — it always resolves to the latest version. To cite a specific release, replace it with that release's version DOI from the Zenodo deposit page.

Help

  • Function reference: ?invert_d2H, ?local_effective_slope, ?detect_change, ?assess_claim, ?compute_vegetation_envelope.
  • Vignette: vignette("paleo-record-workflow", package = "leafwax").
  • Issues: https://github.com/bradleylab/leafwax/issues.

License

MIT. See LICENSE.

Metadata

Version

0.2.7

License

Unknown

Platforms (79)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    uefi
    wasip1
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-uefi
  • aarch64-windows
  • aarch64_be-none
  • arc-linux
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-linux
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • sh4-linux
  • vc4-none
  • wasm32-wasip1
  • wasm64-wasip1
  • x86_64-cygwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-uefi
  • x86_64-windows