hsa_sample_constrained: Constrained HespDiv Sensitivity Analysis by Subsampling

View source: R/hsa_sample_constrained.R

hsa_sample_constrainedR Documentation

Constrained HespDiv Sensitivity Analysis by Subsampling

Description

Conduct a constrained sensitivity analysis on a hespdiv object by repeatedly subsampling observations within each polygon. Each subsample is used to call hespdiv with recursion disabled (i.e., single-split only).

Usage

hsa_sample_constrained(
  obj,
  n.runs = 100,
  subsample_factor = 0.7,
  RAM = NULL,
  load_prop = NULL,
  chunk_size = 8,
  workers = NULL
)

Arguments

obj

A hespdiv object.

n.runs

Integer. The number of subsampling runs to perform (default: 100).

subsample_factor

Numeric proportion of data to subsample within each polygon (0 to 1]. For example, 0.7 means 70% of the data in each polygon are retained.

RAM

Integer. Approximate amount of RAM in GB to guide how many parallel workers to use. The function uses up to 80\ but also caps the number of workers at RAM.

load_prop

Numeric value (0,1]. Specifies the proportion of available CPU cores or RAM to be used for setting up parallel workers. For example, load_prop = 0.8 uses 80% of the available resources. If both load_prop and RAM are provided, the number of workers will be the minimum based on the constraints imposed by both. Defaults to 0.8 if not provided.

chunk_size

Integer. Number of runs submitted per batch. Parallelism is controlled by workers; chunking mainly controls memory/queue size.

workers

A number of parrallel workers. Determines the number of hespdiv runs to be processed in parallel.

Details

For each polygon in the hespdiv object, this function draws subsample_factor of the data (by default 70%), creating multiple random subsamples (n.runs). These are processed in chunks (as given by chunk_size) and runs in each chunk being parallelized to manage memory usage.

Value

A hsa_constrained class object, a list with two elements:

  • Alternatives A named list corresponding to each polygon where each entry is another list of hespdiv results for each subsample run.

  • Basis The original hespdiv object (obj).

See Also

hespdiv for details on the main function. future.apply

Other functions for hespdiv sensitivity analysis: change_base(), hsa(), hsa_detailed(), hsa_quant(), plot_cs_hsa(), plot_hsa(), plot_hsa_q()

Other functions for hespdiv results post-processing: cross_comp(), hsa(), hsa_detailed(), hsa_quant(), nulltest(), taxon_effect()


hespdiv documentation built on May 21, 2026, 5:09 p.m.