Learn R Programming

PortfolioTesteR (version 0.1.4)

create_regime_buckets: Convert Continuous Indicator to Discrete Regimes

Description

Transforms continuous indicators into discrete regime categories.

Usage

create_regime_buckets(
  indicator,
  breakpoints,
  labels = NULL,
  use_percentiles = FALSE
)

Value

Integer vector of regime classifications

Arguments

indicator

Numeric vector or data frame with indicator values

breakpoints

Numeric vector of breakpoints

labels

Optional character vector of regime names

use_percentiles

Use percentiles instead of fixed breakpoints (default: FALSE)

Examples

Run this code
data("sample_prices_weekly")
momentum <- calc_momentum(sample_prices_weekly, lookback = 12)
selected <- filter_top_n(momentum, 10)
# Create VIX-like indicator from volatility
vol <- calc_rolling_volatility(sample_prices_weekly, lookback = 20)
vix_proxy <- vol$SPY * 100  # Scale to VIX-like values
regimes <- create_regime_buckets(vix_proxy, c(15, 25))

Run the code above in your browser using DataLab