GeneralizedGammaLSS#

class superglm.GeneralizedGammaLSS(
parametrisation: Literal['mean', 'location'] = 'mean',
scale_floor: float = 0.01,
)#

Bases: MeanPredictor, LocationPredictor, ScalePredictor, ShapePredictor

Generalized gamma with natural parameters (mean | location, scale, shape).

Prentice’s (mu, sigma, Q) law on y > 0: shape = 0 is the log-normal, shape = 1 the Weibull, shape = scale the gamma. The default mean form puts E[Y] first under a log link, so its relativities multiply the mean; the location form puts the log-scale location first under an identity link and admits an infinite mean.

Parameters:
parametrisation{“mean”, “location”}, default=”mean”

Choose family.mean(...) for the conditional response mean or family.location(...) for Prentice’s log-scale location. Declare family.scale(...) and family.shape(...) in either form. Scale is Prentice’s sigma and shape is Q. Scale need not equal the standard deviation of the response or its logarithm.

scale_floorfloat, default=0.01

Nonnegative lower bound on scale. Its default link is log(scale - scale_floor). Shape uses an identity link.

Notes

Changing the first parameter changes what its additive predictor describes. The mean form requires a finite response mean. Results contain mean, scale, shape or location, scale, shape. predict returns the response mean in both forms, including infinity where the mean does not exist in the location form.

censored_recession(
bounds: ResponseBounds,
) → NDArray[bool]#

Every censored row escapes along the location or mean; none along scale or shape.

At a fixed scale and shape log Y = mu + sigma W is a location family in mu, and the mean form’s mu = log m - log C(sigma, Q) is a strictly increasing shift. W’s density is log-concave (d^2 log f/dw^2 = -e^(Q w)), so the family has a monotone likelihood ratio in mu, and within any truncation window P(Y > c) rises and P(Y <= c) falls strictly with mu. Along the scale or the shape a bound probability’s limit depends on the fitted location and the other parameter, so those predictors are not flagged.

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.

predictor_curvature_second_directional_derivative(
y: NDArray,
eta: NDArray,
direction_a: NDArray,
direction_b: NDArray,
links: Sequence[Link],
plan: FamilyLikelihoodPlan,
) → NDArray[float64]#

Differentiate observed predictor curvature twice, along a then b.

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

Population variance, with infinity for a divergent second moment.

log_window_probability(
lower: NDArray,
upper: NDArray,
theta: NDArray,
weights: NDArray | None = None,
) → NDArray[float64]#

log P(lower < Y <= upper) per row; NaN where the mean form’s mean does not exist.

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

E[Y | Y > q_p] per row in either natural parametrisation.