LogNormalLS#

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

Bases: MeanPredictor, LocationPredictor, ScalePredictor

Log-normal with natural parameters (mean | location, scale).

log Y ~ N(mu, sigma^2) on y > 0. The default mean form puts E[Y] first under a log link, so its relativities multiply the mean and the scale predictor only redistributes mass within a cell; the location form puts mu first under an identity link, where relativities multiply every quantile. The mean always exists, so neither form has an invalid region.

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

Choose the first modeled parameter. Use family.mean(...) for E[Y] or, in location form, family.location(...) for E[log Y]. Declare family.scale(...) in either form; scale is the standard deviation of the log response. Changing forms changes which quantity the first additive predictor describes.

scale_floorfloat, default=0.01

Nonnegative lower bound on scale. Its default link is log(scale - scale_floor).

Notes

Fit the positive response directly. Results contain mean, scale or location, scale according to the selected form. predict returns the response mean in both forms.

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

Every censored row escapes along the location or mean; some escape along the scale.

On log Y the law is normal, so the location (or the mean at fixed sigma) moves every bound probability one way within any truncation window. In the location form the scale is the normal one: a row right-censored above a lower truncation bound with no upper bound, or left-censored below an upper bound with no lower one, escapes along it. In the mean form P(Y <= c) = Phi(sigma/2 - log(m/c)/sigma) nears one only as sigma grows, whatever m, and so does P(Y <= c | Y <= b), so a left-censored row with no lower truncation bound escapes along the scale. P(Y > c) instead peaks at sigma = sqrt(2 log(c/m)) below a limit, a lower bound keeps a left-censored row’s probability below one as sigma grows, and elsewhere the scale’s direction depends on the fitted mean or location.

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]#

Var(Y) = E[Y]^2 (exp(sigma^2) - 1) per row, in either parametrisation.

There is no prior-weighted companion: the log-normal is not a reproductive family, so this family refuses non-unit prior weights at the fit and has no weighted law to report a second moment from.

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

log P(lower < Y <= upper) under each row’s law, from the tail-safe window kernel.

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

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