name: regression-spec
description: The regression entry's shared contract — flat top-level slot keys, knobs another engine owns, the penalty objective and its missing inference, weighted fits per engine, conf_level, save and name, and the GLM's dispersion, IRLS and pseudo-R² details. Topical design; per-model params in atomic op-reg-* skills.
type: guide
kind: design
applies_to: process, compose, predict
covers: [RegressionSpec, slot keys, penalty, alpha, l1_ratio, conf_level, weight, save, name, dispersion, IRLS, PseudoR2, ConvergedIters]
Regression spec
What every built-in fit shares. Per-model params and outputs: atomic op-reg-*; choosing a model: regression-modeling; intervals, vcov, robust covariance: regression-inference; unpenalized, bounds, per-coefficient priors: regression-model-options; the resample knobs: the resample modifier’s atomic skill.
Slot keys
Every param is a FLAT top-level key of the regression entry (manifest slot: true); a params key on the OLS, GLM, Bayesian-linear or multinomial fit is PULSE_REQUEST_UNKNOWN_FIELD (the ordinal, media-mix and registered regressions take params).
Knobs belong to their engine; another engine’s knob is PROCESSING_CONFIG, at predict and at runtime alike:
- a
penaltyon a gamma GLM, oralpha/l1_ratiowithout apenalty; thetaoff anegative_binomialGLM,dispersionoff it, withoutthetaorestimatedbesidepenalty(details.requires);penalty/alpha/l1_ratio/unpenalized/family/linkon the Bayesian fit;resample/selectionon the Bayesian fit (credible intervals already convey uncertainty).
Shared keys:
conf_level—CILower/CIUppercoverage,0<c<1, default 0.95 (regression-inference). The Bayesian fit’scredible_levelsetsCredibleIntervals; the two intervals are equal whenconf_levelis unset.name— the result alias, and the saved model’s name (default: thesavefile’s stem).save— writes the finished fit as a model file (.pulse-model.json,compose-fits).multiplicity{method, family, alpha, coefficients}(OLS, GLM) — the member coefficients’ p-values join a request-wide or batch-wide family; addsPAdjusted/SignificantAdjusted+ an echo beside the rawPValues, which never move (multiplicity-correction). The Bayesian fit has no p-values: any method butnoneisPULSE_MULTIPLICITY_INVALID, predict too.
Penalty
penalty l2 / l1 / elasticnet (OLS; GLM but gamma; multinomial, op-reg-multinomial) uses glmnet’s standardize=FALSE objective: raw predictor units, intercept unpenalized. The GLM minimizes −loglik/N* + alpha·[(1−l1_ratio)/2‖β‖² + l1_ratio‖β‖₁], N* = Σw.
alpha— strength,> 0(glmnetlambda), required with apenalty.l1_ratio— the mix,0<r<1,elasticnetonly.- Raw units: scale predictors upstream to penalize them alike.
l2SEs are the ridge sandwich (GLM: H = XᵀWX + N*·α·D).l1/elasticnethave no analytical inference (the data pick the predictors):StdErrors/PValues/ CIs are null on EVERY key andAdvisoriescarriesPULSE_ADVISORY_PENALIZED_INFERENCE_UNDEFINED— an advisory, not a warning, never Strict-escalated.vcovisPROCESSING_REGRESSION_VCOV_UNSUPPORTED. Want uncertainty →resample(it refits every replicate and silences the advisory); want p-values →l2or no penalty.- A penalty with
selection: predict warnsPROCESSING_REGRESSION_REGULARIZED_SELECTION— the penalty already shrinks or selects.
OLS solver and intercept
solver:qr(default) solves a streaming QR of the design at κ(X);normalsolves the normal equations at κ(X)². Unpenalized, unbounded fits only.intercept: falsefits through the origin:(intercept)stays 0 with null SE / p / CI, R² is uncentred Σŷ²/Σy²,DF= N* − p (Rlm(y ~ 0 + x)). Refused with a penalty, bounds, a modifier, a robustcovarianceornormal.
Weighted fits
weight: null opts a slot out (weighting). NObs stays the raw row count; a weighted fit adds SumWeights (+ NEff under a probability weight).
| Fit | Kinds | What the weight does |
|---|---|---|
| OLS | frequency, probability | WLS β; df = N* − p − 1, N* = Σw (frequency) or Kish n_eff (probability) |
| GLM | frequency, probability | IRLS prior weights w* (R glm(weights = w*)); SEs and deviances on w*; a robust covariance follows w* |
| Bayesian linear | frequency only | the expanded rows: XᵀWX, XᵀWy and Σw enter the posterior |
resample: bootstraporselectionunder a weight →PULSE_WEIGHT_UNSUPPORTED; a jackknife is weighted (JK1, each replicate keeps its rows’ weights).- n_eff ≤ p + 1 (OLS, gamma GLM) or < p + 1 (binomial / poisson GLM) →
PULSE_WEIGHT_LOW_NEFF. - OLS residual df ≤ 0 makes
StdErrors,PValues,CILower/CIUpper,DF,AdjR2andResidualStdErrnull.
GLM details
- Dispersion φ = 1 for binomial / poisson / NB: Wald z,
CILower/CIUpper= β ∓ z·SE (Rconfint.default), noDF. Overdispersed counts:negative_binomialor a robustcovariance. - Gamma (and NB with
theta+dispersion: estimated) estimates φ̂ = Pearson χ²/DF,DF= N* − p − 1 (N* = n, Σw or n_eff): t p-values and β ∓ t·SE (Rsummary.glm); φ̂ itself is not emitted;DF≤ 0 nulls SE / p / CI /DF. Gammaselectionscores R’sAIC(glm)/BIC(glm)(φ = D/n counted), not D + 2k. PseudoR2= 1 − D/D₀ (McFadden only for a 0/1 binomial target);Deviance,NullDeviancebeside it.ConvergedIterscounts IRLS steps (R’s start, step-halving). Non-convergence →PROCESSING_REGRESSION_NO_CONVERGE(details.reason): raisemax_iters, loosentol, rescale.linkper family, canonical default first:binomiallogit/probit/cloglog;poissonlog/identity/sqrt;gammainverse/log/identity;negative_binomiallog/identity/sqrt. Another family’s link →PROCESSING_REGRESSION_INVALID_LINK. SEs read the expected information φ·(XᵀWX)⁻¹, W = μ′(η)²/V(μ); off the canonical link IRLS converges linearly (β ~1e-7 off the MLE at defaulttol).- Binomial separation: the MLE is infinite, so no coefficients; check the separating predictor is not recorded after the outcome.