regime_sampler: Sample Candidate Rows from Regime Probabilities

View source: R/regime-sampler.R

regime_samplerR Documentation

Sample Candidate Rows from Regime Probabilities

Description

Combines per-target regime probability vectors into row-level sampling probabilities and samples candidate future-trajectory rows accordingly.

Usage

regime_sampler(
  trafo_df,
  cluster_df,
  prob_vectors,
  weights = NULL,
  size = 1000L,
  return_type = c("stack", "index"),
  seed = NULL,
  eps = 1e-12,
  ...
)

Arguments

trafo_df

Data frame of candidate transformed observations to sample.

cluster_df

Data frame of regime labels for each candidate row. Must have the same number of rows as trafo_df.

prob_vectors

Named list of probability vectors or one-row matrices/data frames, one per target regime column. Names should correspond to columns of cluster_df.

weights

Optional numeric weights for target regime columns.

size

Number of rows or indices to sample with replacement.

return_type

Return sampled rows as "stack" or sampled row indices as "index".

seed

Optional random seed.

eps

Small positive probability floor.

...

Additional arguments. The legacy argument name return is accepted as an alias for return_type.

Value

If return_type = "stack", a data frame sampled from trafo_df. If return_type = "index", an integer vector of sampled row indices.

Examples

trafo <- data.frame(x = 1:4)
clusters <- data.frame(r = c("low", "low", "high", "high"))
probs <- list(r = c(low = 0.2, high = 0.8))
regime_sampler(trafo, clusters, probs, size = 5, seed = 1)

CRAFT documentation built on Nov. 2, 2026, 9:06 a.m.