LogNormalLS#
- class superglm.LogNormalLS( )#
Bases:
MeanPredictor,LocationPredictor,ScalePredictorLog-normal with natural parameters
(mean | location, scale).log Y ~ N(mu, sigma^2)ony > 0. The default mean form putsE[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 putsmufirst 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(...)forE[Y]or, in location form,family.location(...)forE[log Y]. Declarefamily.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, scaleorlocation, scaleaccording to the selected form.predictreturns the response mean in both forms.- censored_recession(
- bounds: ResponseBounds,
Every censored row escapes along the location or mean; some escape along the scale.
On
log Ythe law is normal, so the location (or the mean at fixedsigma) 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 formP(Y <= c) = Phi(sigma/2 - log(m/c)/sigma)nears one only assigmagrows, whateverm, and so doesP(Y <= c | Y <= b), so a left-censored row with no lower truncation bound escapes along the scale.P(Y > c)instead peaks atsigma = sqrt(2 log(c/m))below a limit, a lower bound keeps a left-censored row’s probability below one assigmagrows, 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,
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.
- variance(
- theta: NDArray,
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,
log P(lower < Y <= upper)under each row’s law, from the tail-safe window kernel.
- expected_shortfall(
- p: NDArray,
- theta: NDArray,
E[Y | Y > q_p]per row in either natural parametrisation.