Skip to contents

Implements the quantile-specific adaptive betting scheme of Arnold et al. (2026), translating their log-scale loss convention to seqcomp's positively-oriented scores.

Usage

lambda_betting_quantile(p_t, q_t, tau, delta_hat_lag1 = NULL, eps = 1e-08)

Arguments

p_t

Numeric vector. Quantile forecasts of the first forecaster.

q_t

Numeric vector. Quantile forecasts of the second forecaster.

tau

Numeric scalar in (0, 1). The quantile level.

delta_hat_lag1

Numeric vector. The previous step's score difference. Must have delta_hat_lag1[1] = 0.

eps

Positive numeric scalar. Used as a denominator safeguard against zero. Default: 1e-8.

Value

A list with c_t and lambda_t vectors for eprocess_betting().

Details

If two forecasts are identical at a time point, their tick-loss difference and its analytic bound are both zero. To accommodate the strictly positive bound required by eprocess_betting() and the adaptive betting rules, this function replaces such bounds (and any smaller bounds) by eps. This is a conservative predictable enlargement of the bound; the corresponding Arnold betting fraction is capped at 1 / c_safe.

Note

Scale Translation: This function assumes p_t, q_t, and delta_hat_lag1 are calculated on the raw, linear scale. To replicate the exact log-scale bounds used in the Arnold et al. (2026) Covid-19 case study, the forecast vectors passed to this function must be log-transformed prior to evaluation.

Examples

set.seed(456)
T_sim <- 100
y <- rnorm(T_sim)
tau <- 0.90

# Forecaster 1 correctly predicts the true 90th percentile (~1.28)
p_t <- rep(qnorm(tau), T_sim)
# Forecaster 2 is biased and incorrectly predicts the median (0.0)
q_t <- rep(0.0, T_sim)

# 1. Compute pointwise tick loss (positively oriented)
s_p <- tick_loss(p_t, y, tau)
s_q <- tick_loss(q_t, y, tau)

# 2. Compute the lagged score difference required by Arnold's heuristic
xs <- s_p - s_q
delta_lag1 <- c(0, head(xs, -1))

# 3. Generate the predictable bounds (c_t) and betting fractions (lambda_t)
bnds <- lambda_betting_quantile(p_t, q_t, tau, delta_hat_lag1 = delta_lag1)

# 4. Plug these directly into the betting e-process
res <- eprocess_betting(
  scores1 = s_p,
  scores2 = s_q,
  c_t = bnds$c_t,
  lambda_t = bnds$lambda_t
)

# View the final evidence accumulation
tail(res[, c("t", "e_pq", "e_qp")], 3)
#>       t     e_pq         e_qp
#> 98   98 275.0086 0.0005317017
#> 99   99 339.3710 0.0004072634
#> 100 100 329.9405 0.0004185805