Skip to content

Add sliced and nested Latin hypercube designs#71

Merged
bertcarnell merged 3 commits into
masterfrom
claude/lhs-package-features-au1As
Jun 13, 2026
Merged

Add sliced and nested Latin hypercube designs#71
bertcarnell merged 3 commits into
masterfrom
claude/lhs-package-features-au1As

Conversation

@bertcarnell

Copy link
Copy Markdown
Owner

Summary

Adds two new design-generation methods to the package, filling a gap in supported design types (previously there was no way to create designs with a slice/subset structure):

  • slicedLHS(m, t, k) — a sliced Latin hypercube design (Qian, 2012) made up of t slices of m points each. Every slice is itself a Latin hypercube design, and the union of all slices is a Latin hypercube design of n = m*t points. Useful for computer experiments mixing quantitative and qualitative factors (one slice per level combination) and for collecting data in batches. Slice membership is returned in the "slices" attribute of the result.
  • nestedLHS(small, large, k) — a nested Latin hypercube design (Qian, 2009) in which the small-point design is a subset of the large-point design and both are valid Latin hypercube designs. Useful for two-level / multi-fidelity computer experiments. Returns a list with $small and $large, where $small is the first small rows of $large.

Both are implemented in pure R (the constructions are simple combinatorial assignments), matching the style of the existing augmentLHS.

What's included

  • R/slicedLHS.R, R/nestedLHS.R with roxygen documentation
  • Generated man pages man/slicedLHS.Rd, man/nestedLHS.Rd
  • NAMESPACE exports
  • testthat tests (tests/testthat/test-slicedlhs.R, test-nestedlhs.R) covering the Latin properties of the union/slices/subsets and input validation, using the existing checkLatinHypercube helper
  • NEWS, README (.Rmd + .md) entries, updated package Description, and a version bump to 1.4.0

Verification

R is not available in the build environment used to prepare this branch, so the testthat suite was not executed here — please run R CMD check / devtools::test() before merging. The construction algorithms were validated by porting them to an independent script and confirming, over 2000 randomized trials each, that:

  • sliced: the union and every individual slice are valid Latin hypercube designs
  • nested: both the large and small designs are valid Latin hypercube designs and the small design is exactly the first small rows of the large design

References

  • Qian, P. Z. G. (2012) Sliced Latin Hypercube Designs. JASA 107, 393–399.
  • Qian, P. Z. G. (2009) Nested Latin hypercube designs. Biometrika 96, 957–970.

Notes / possible follow-ups

  • nestedLHS implements the canonical two-layer case (large must be an integer multiple of small). A multi-layer chain (n_1 | n_2 | ... | n_L) could be a future extension.
  • The man pages were hand-written to match roxygen2 output since R wasn't available to regenerate them; re-running roxygen2::roxygenise() should produce an identical result.

https://claude.ai/code/session_01JNVgdYk9zNB8B4hLSn8rzj


Generated by Claude Code

claude and others added 2 commits June 6, 2026 18:22
Add two new design-generation functions:

- slicedLHS(m, t, k) builds a sliced Latin hypercube design (Qian, 2012)
  composed of t slices of m points each.  Every slice is a Latin hypercube
  design and the union of the slices is a Latin hypercube design.  Slice
  membership is returned in the "slices" attribute.
- nestedLHS(small, large, k) builds a nested Latin hypercube design (Qian,
  2009) where the small design is a subset of the large design and both are
  Latin hypercube designs.

Includes roxygen documentation and man pages, NAMESPACE exports, testthat
tests covering the Latin properties and input validation, NEWS and README
entries, and a version bump to 1.4.0.
@bertcarnell bertcarnell self-assigned this Jun 13, 2026
@bertcarnell bertcarnell added the enhancement New feature or request label Jun 13, 2026
@bertcarnell bertcarnell merged commit b5879a6 into master Jun 13, 2026
14 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants