srvar.elb

class srvar.elb.ElbSpec(bound, applies_to=<factory>, tol=1e-08, init_offset=0.05, enabled=True)[source]

Bases: object

Effective lower bound (ELB) configuration.

When ELB is enabled, selected observed series are treated as censored at an upper bound (the effective lower bound). During estimation, latent shadow values are sampled for observations at/below the bound.

Parameters:
  • bound (float) – The ELB level. Observations at or below bound + tol are treated as constrained.

  • applies_to (list[str]) – Names of variables (as they appear in srvar.data.dataset.Dataset) to which the ELB constraint applies.

  • tol (float) – Numerical tolerance when identifying bound observations.

  • enabled (bool) – Whether to enable ELB handling.

applies_to: list[str]
bound: float
enabled: bool
init_offset: float
tol: float
srvar.elb.apply_elb_floor(values, *, bound, indices)[source]

Apply an ELB floor to simulation draws.

This is used during forecasting to map latent shadow-rate draws back into observed rate draws by enforcing y >= bound on the constrained variables.

Return type:

ndarray

srvar.elb.sample_shadow_value(*, y, t, j, p, beta, sigma, upper, include_intercept, rng)[source]

Sample y[t, j] from its full conditional (truncated above at upper).

This conditional accounts for the fact that y[t, j] enters as a regressor in the next p likelihood terms.

Assumptions: - Standard VAR(p): y_t ~ N(x_t beta, Sigma) - The only constraint is: y[t, j] <= upper

Return type:

float

Returns:

new value for y[t, j]

srvar.elb.sample_shadow_value_fsv(*, y, h_eta, factor_mean, t, j, p, beta, upper, include_intercept, rng)[source]

Sample y[t, j] from its full conditional under factor SV (given factors/loadings).

This is the ELB shadow-rate update for a VAR(p) with factor stochastic volatility, conditioning on the current factor contribution to the mean.

The conditional likelihood is treated as diagonal given factors/loadings:

y_t = x_t beta + factor_mean_t + eta_t eta_t ~ N(0, diag(exp(h_eta_t)))

where factor_mean_t corresponds to Lambda f_t evaluated at the current Gibbs state.

The only constraint is: y[t, j] <= upper.

Return type:

float

srvar.elb.sample_shadow_value_svcov(*, y, h, q, t, j, p, beta, upper, include_intercept, rng)[source]

Sample y[t, j] from its full conditional under triangular SV covariance.

This is the ELB shadow-rate update for a VAR(p) with stochastic volatility where the reduced-form residual covariance is:

Sigma_t = Q^{-1} diag(exp(h_t)) (Q^{-1})’

with Q upper-triangular and ones on the diagonal.

Return type:

float

srvar.elb.sample_shadow_value_svrw(*, y, h, t, j, p, beta, upper, include_intercept, rng)[source]
Return type:

float

srvar.elb.truncnorm_rvs_upper(*, mean, sd, upper, rng)[source]

Draw from a univariate normal distribution truncated above at upper.

Return type:

float