GammaLS#
- class superglm.GammaLS#
Bases:
MeanPredictor,ScalePredictorPositive responses with mean and coefficient-of-variation predictors.
Declare
family.mean(...)andfamily.scale(...). Both use log links. Herescaleis the coefficient of variation, so the unit-law variance ismean**2 * scale**2. It is the square root of GLM Gamma dispersion, and differs from the scale argument ofscipy.stats.gamma.Results use the column names
meanandscalein that order. Responses must be strictly positive. An empty helper call estimates a constant parameter through an intercept-only predictor.See also
SuperLSSConstruct and fit a model with these predictors.
- censored_recession(
- bounds: ResponseBounds,
Every censored row escapes along the mean; none is flagged on the scale.
At a fixed coefficient of variation the mean is a scale parameter, and
d^2 log f/(dy dm) = a/m^2 > 0is a monotone likelihood ratio inm, so within any truncation windowP(Y > c)rises andP(Y <= c)falls strictly with the mean. Along the coefficient of variation, at a fixed mean,P(Y <= c)nears one both ascvgrows and, forcabove the mean, as it shrinks, andP(Y > c)nears its supremum ascvshrinks only forcbelow the mean and peaks at an interiorcvabove it, so the direction depends on the fitted mean.
- predictor_curvature_directional_derivative(
- y: NDArray,
- eta: NDArray,
- eta_direction: NDArray,
- links: Sequence[Link],
- plan: FamilyLikelihoodPlan,
Differentiate observed predictor curvature along one predictor path.
- predictor_curvature_second_directional_derivative(
- y: NDArray,
- eta: NDArray,
- direction_a: NDArray,
- direction_b: NDArray,
- links: Sequence[Link],
- plan: FamilyLikelihoodPlan,
Differentiate observed predictor curvature twice, along
athenb.
- log_window_probability(
- lower: NDArray,
- upper: NDArray,
- theta: NDArray,
- weights: NDArray | None = None,
log P(lower < Y <= upper)per row, shapew/cv^2with prior weightsw.
- cdf(
- y: NDArray,
- theta: NDArray,
P(Y <= y)per row: shape1/cv^2and scalemean cv^2.
- quantile(
- p: NDArray,
- theta: NDArray,
The
p-quantile per row,pinside(0, 1).
- expected_shortfall(
- p: NDArray,
- theta: NDArray,
E[Y | Y > q_p]for shape1 / cv^2at unit prior weight.
- variance(
- theta: NDArray,
Var(Y) = (mean cv)^2per row at unit prior weight.
- variance_prior_weighted(
- theta: NDArray,
- weights: NDArray,
Var(Y) = (mean cv)^2 / wper row: shapew / cv^2, scalemean cv^2 / w.
- cdf_prior_weighted(
- y: NDArray,
- theta: NDArray,
- weights: NDArray,
P(Y <= y)per row: shapew / cv^2and scalemean cv^2 / w.
- quantile_prior_weighted(
- p: NDArray,
- theta: NDArray,
- weights: NDArray,
The prior-weighted
p-quantile per row,pinside(0, 1).
- expected_shortfall_prior_weighted(
- p: NDArray,
- theta: NDArray,
- weights: NDArray,
E[Y | Y > q_p]for weighted shapew / cv^2.