BayesianBLP.elasticities#
- BayesianBLP.elasticities(*, at='mean', periods=None, regions=None, n_samples=500)[source]#
Posterior price elasticities
ε[market, share, price].Computes the closed-form mixed-logit elasticity from posterior draws:
ε_jk(m) = (p_km / s_jm) · (1/R) Σ_r α_ir(m) · s_jmr · (δ_jk − s_kmr)which is negative on the diagonal (own-price) and positive off-diagonal (cross-price substitutes). The integral over consumer types is approximated with the same Halton draws used for the likelihood, so it is essentially free.
- Parameters:
- at{“mean”, “samples”}
"mean"(default) returns the posterior mean elasticity per cell, dims(market, share, price)."samples"returns the full per-sample array, dims(sample, market, share, price).- periodssequence of
periodlabelsorslice, optional Slice the returned DataArray to these periods (coord labels). Only valid when
time_colwas set on the model. The elasticity is still computed across the whole panel; the returned array is restricted at the output boundary.- regionssequence of
regionlabels, optional Slice the returned DataArray to these regions (coord labels).
- n_samples
int Number of posterior samples to use. With
at="mean"the samples are averaged after computation (correct for Jensen’s inequality, unlike plugging in posterior-mean parameters); withat="samples"they are returned as-is. The default of 500 is sufficient for smooth posterior densities on typical panels; increase for finer KDE resolution at the cost of memoryO(n_samples · M · J · n_mc_draws).
- Returns:
xr.DataArray