Learn R Programming

BayesianDisaggregation (version 0.1.2)

spread_likelihood: Spread a likelihood vector across time with a chosen temporal pattern

Description

Expands a sectoral likelihood \(L\) (length \(K\)) into a \(T \times K\) matrix by applying a temporal weight profile and then row-normalizing to the simplex.

Usage

spread_likelihood(
  L,
  T_periods,
  pattern = c("constant", "recent", "linear", "bell")
)

Value

Numeric matrix \(T \times K\); each row sums to 1.

Arguments

L

Numeric vector (length \(K\)); sectoral likelihood. It is normalized internally to sum to 1 before spreading.

T_periods

Integer; number of time periods \(T\).

pattern

Temporal pattern for the weights across time; one of "constant", "recent", "linear", "bell".

Details

Given \(L\) and a non-negative time-weight vector \(w_t\), the function replicates \(L\) across rows and applies \(w\) elementwise, then row-normalizes using row_norm1(): $$LT_{t,k} \propto w_t \cdot L_k, \qquad \sum_k LT_{t,k} = 1 \ \forall t.$$

Patterns:

  • "constant": \(w_t = 1\).

  • "recent": linearly increasing in \(t\) (more weight to later periods).

  • "linear": affine ramp from first to last period.

  • "bell": symmetric bell-shaped profile centered at \(T/2\).

See Also

compute_L_from_P, bayesian_disaggregate

Examples

Run this code
set.seed(1)
K <- 5; T <- 8
L <- runif(K); L <- L / sum(L)
LT <- spread_likelihood(L, T, "recent")
stopifnot(nrow(LT) == T, ncol(LT) == K, all(abs(rowSums(LT) - 1) < 1e-12))

Run the code above in your browser using DataLab