Learn R Programming

exdqlm (version 0.4.0)

quantileSynthesis: Synthesize a unified posterior predictive distribution from multiple quantile-model draws

Description

The function synthesizes posterior predictive draws from multiple fitted quantile models into a single posterior predictive distribution. It uses a two-step correction: (i) isotonic regression at the grid of target quantiles to align the fitted quantile levels, and (ii) distributional alignment (shift each model's draws so its tau-quantile matches the isotone anchor). It then builds a single predictive quantile function per time by piecewise-linear blending across adjacent quantile models with optional global monotone rearrangement.

Usage

quantileSynthesis(
  draws_list,
  p,
  enforce_isotonic = TRUE,
  rearrange = TRUE,
  grid_M = 1001L,
  n_samp = 1000L,
  seed = NULL,
  T_expected = NULL
)

Value

An object of class "exdqlmSynthesis", which is a list containing:

  • draws - Numeric matrix T x n_samp of synthesized draws.

  • levels - Sorted copy of p (length L).

  • quantiles - Numeric matrix T x L of isotone anchors m^*_{i,t}.

  • summary - List with row-wise summaries of draws (mean, q025, q250, q500, q750, q975).

  • method - List of synthesis settings used (name, isotonic, rearrange, grid_M, T_inferred).

Arguments

draws_list

List of length L; each element is either: (i) a numeric matrix of posterior predictive draws (T x ns or ns x T), (ii) a dynamic fit object (exdqlmMCMC, exdqlmLDVB, or legacy exdqlmISVB) with samp.post.pred, or (iii) an exdqlmForecast object with samp.fore. Rows are coerced to time.

p

Numeric vector of target quantile levels in (0,1) of length L (same order as draws_list, not necessarily sorted). Duplicate levels are not allowed.

enforce_isotonic

Logical; apply isotonic regression (PAVA) over the grid p at each time t to remove crossing. Default TRUE.

rearrange

Logical; apply monotone rearrangement (evaluate -> sort -> reinterpolate) on a dense grid over u in (0,1). Default TRUE.

grid_M

Integer; size of dense grid M for rearrangement (u_k = k/(M+1)). Default 1001L.

n_samp

Integer; number of synthesized draws per time. Default 1000L.

seed

NULL or integer for reproducible synthesized draws. Default NULL.

T_expected

Optional integer; if provided, forces the time dimension to T_expected when orienting each matrix to T x ns. This avoids accidental transposes.

Examples

Run this code
# \donttest{
# short example
data("scIVTmag", package = "exdqlm")
old = options(exdqlm.max_iter = 10L)
TT = 50
y = scIVTmag[1:TT]

# create a compact trend model
trend.comp = polytrendMod(1, stats::quantile(y, 0.85), 10)
model = trend.comp

# fit quantiles using LDVB and save posterior predictive samples
fits <- draws <- NULL
p0s = c(0.10, 0.50, 0.90)
for(i in 1:length(p0s)){
  fits[[i]] = exdqlmLDVB(
    y, p0 = p0s[i], model, df = 0.98, dim.df = 1,
    sig.init = 15, n.samp = 20, tol = 0.2, verbose = FALSE
  )
  draws[[i]] = fits[[i]]$samp.post.pred
}

# synthesize posterior predictive from all quantiles
syn = quantileSynthesis(
  draws_list = draws,
  p = p0s,
  T_expected = TT)

# alternatively, pass fitted dynamic objects directly
syn2 = quantileSynthesis(
  draws_list = fits,
  p = p0s,
  T_expected = TT)

# plot the synthesized 95% posterior predictive interval
plot(syn2, y = y)
options(old)
# }

Run the code above in your browser using DataLab