mixle.ppl.regression module¶
Regression / GLMs for mixle.ppl.
A linear predictor in a parameter slot makes a model a regression; the outer family sets the link:
Normal(a*Field(“x”) + b, sigma) identity link -> linear regression Bernoulli(a*Field(“x”) + b) logit link -> logistic regression Poisson(a*Field(“x”) + b) log link -> Poisson regression
Coefficients may be free or may carry Normal penalty handles. Fitting is
IRLS/Fisher scoring for a likelihood or penalized-likelihood point estimate.
For Normal responses this module uses the ridge/penalized-least-squares
convention documented in the book and reports a scale-adjusted
inverse-curvature diagnostic; it is not a full Gaussian-prior posterior
unless the likelihood and prior precisions are scaled consistently. Fit with
.fit(y, given={"x": xs}).
- class RegressionResult(names, idx_of, beta, cov, sigma, columns, link='identity')[source]
Bases:
objectRegression point estimate with coefficient curvature diagnostics.
- samples(param=None, n=4000, rng=None)[source]
Draw from the Gaussian coefficient approximation represented by
betaandcov.- Parameters:
n (int)
- predict(given, *, n=None, rng=None)[source]
Predict the response mean at covariates
given(dict of arrays): the fitted value through the link (probabilities for logistic, rates for Poisson, mean for linear). Withn, returnsndraws of the fitted mean under the Gaussian coefficient approximation; observation noise is not added.
- summary()[source]
- to_exponential_family(engine=None)[source]
Return the conditional exponential-family view
p(y|x)for a canonical link.For a canonical link the linear predictor is the natural parameter:
eta(x) = offset + X @ betais the logit (Bernoulli) / log-rate (Poisson) directly, and the meanmu(x)/sigma^2paired with-1/(2 sigma^2)for the Normal. The returnedConditionalExponentialFamilyFormexposesnatural_parameters(x),sufficient_statistics(y),log_partition,log_base_measure(y),mean(x)(the inverse link ==predict()), andlog_density(y, x).
- class LMMResult(names, beta, cov, Sigma, sigma, b, group_levels, re_names)[source]
Bases:
objectLinear mixed model: fixed-effect coefficients + variance components + group effects.
- summary()[source]
- class GLMMResult(family, link, names, beta, cov, Sigma, b, group_levels, re_names)[source]
Bases:
objectGeneralized linear mixed model: fixed-effect coefficients (on the link scale) + the random-effects covariance + per-group effects. No residual scale (the family sets dispersion).
- summary()[source]
- class LocationScaleResult(family, names_m, names_s, beta, cov, spec_m, spec_s)[source]
Bases:
objectHeteroskedastic (location-scale) regression: separate mean and log-scale coefficients.
The scale follows a log link,
scale = exp(eta_scale), so the dispersion can vary with covariates (Normal(mean_pred, free*Field("x") + free)).predictreturns per-rowlocandscale.- predict(given, **_)[source]
Return
{'loc': array, 'scale': array}at covariatesgiven.
- summary()[source]