GammaLS#

class superglm.GammaLS#

Bases: MeanPredictor, ScalePredictor

Positive responses with mean and coefficient-of-variation predictors.

Declare family.mean(...) and family.scale(...). Both use log links. Here scale is the coefficient of variation, so the unit-law variance is mean**2 * scale**2. It is the square root of GLM Gamma dispersion, and differs from the scale argument of scipy.stats.gamma.

Results use the column names mean and scale in that order. Responses must be strictly positive. An empty helper call estimates a constant parameter through an intercept-only predictor.

See also

SuperLSS

Construct and fit a model with these predictors.

predictor_curvature_directional_derivative(
y: NDArray,
eta: NDArray,
eta_direction: NDArray,
links: Sequence[Link],
plan: FamilyLikelihoodPlan,
) → NDArray[float64]#

Differentiate observed predictor curvature along one predictor path.

cdf(
y: NDArray,
theta: NDArray,
) → NDArray[float64]#

P(Y <= y) per row: shape 1/cv^2 and scale mean cv^2.

quantile(
p: NDArray,
theta: NDArray,
) → NDArray[float64]#

The p-quantile per row, p inside (0, 1).

expected_shortfall(
p: NDArray,
theta: NDArray,
) → NDArray[float64]#

E[Y | Y > q_p] for shape 1 / cv^2 at unit prior weight.

variance(
theta: NDArray,
) → NDArray[float64]#

Var(Y) = (mean cv)^2 per row at unit prior weight.

variance_prior_weighted(
theta: NDArray,
weights: NDArray,
) → NDArray[float64]#

Var(Y) = (mean cv)^2 / w per row: shape w / cv^2, scale mean cv^2 / w.

cdf_prior_weighted(
y: NDArray,
theta: NDArray,
weights: NDArray,
) → NDArray[float64]#

P(Y <= y) per row: shape w / cv^2 and scale mean cv^2 / w.

quantile_prior_weighted(
p: NDArray,
theta: NDArray,
weights: NDArray,
) → NDArray[float64]#

The prior-weighted p-quantile per row, p inside (0, 1).

expected_shortfall_prior_weighted(
p: NDArray,
theta: NDArray,
weights: NDArray,
) → NDArray[float64]#

E[Y | Y > q_p] for weighted shape w / cv^2.