Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Regression Modeling

Pulse exposes regression through a compact, composable surface. A small set of REG_* operators (pulse --json lists them under regressions), two orthogonal modifiers, and one upstream feature transform together cover every textbook regression variant. This chapter is the human-facing counterpart to skills/regression-modeling.md; agents should fetch the skill via pulse_skills_get rather than read this page.

Overview

OperatorEngineStreaming
REG_OLSOrdinary least squares + optional regularizationStreams sufficient statistics
REG_GLMGeneralized linear model via IRLSAlways buffered (Newton-Raphson refit)
REG_BAYES_LINEARBayesian linear regression (conjugate NIG)Streams sufficient statistics
REG_MMM_HILLMedia-mix model: joint nonlinear least squares over Hill-saturated channels plus linear controls; channels arrive adstocked, or params.adstock fits the decay in the same least squaresAlways buffered
REG_MMM_BAYESBayesian media-mix model: raw spend adstocked in the model, Hill saturation, linear controls, posterior sampled by NUTSAlways buffered
REG_MULTINOMIALMultinomial (baseline-category) logit of a categorical target by Newton-RaphsonAlways buffered
REG_ORDINALOrdinal (proportional-odds, cumulative link) regression, MASS polr’s model: logit / probit / cloglog, Newton on the analytic informationAlways buffered

Two spec-level modifiers compose with the first three (REG_MMM_HILL takes Resample only; its own knobs ride params, and it names its own curve coefficients k:<channel> / s:<channel>, plus its adstock kernel’s terms under params.adstock (decay:<channel>, delayed adding peak:<channel>, a Weibull kernel shape: / scale:<channel> instead), which requires order — skill op-reg-mmm-hill, example internal/examples/regression/19_mmm_hill.json). REG_MMM_BAYES takes neither: its sampler, priors and model-owned holdout (holdout_from) ride params, its scorer averages over its posterior draws, so save, the engine holdout and ATTR_REG_PREDICT need params.return_draws (skill mmm-bayes-posterior), and it names its adstock kernel’s terms (decay:<channel>; with params.adstock delayed also peak:<channel>, under a Weibull kernel shape: / scale:<channel> instead), k:<channel>, s:<channel> and sigma beside the predictors, its ROI / mROI / contribution intervals and sampler diagnostics riding outputs — skill op-reg-mmm-bayes, example internal/examples/regression/20_mmm_bayes.json, design guide mmm-workflow. REG_ORDINAL and REG_MULTINOMIAL take both, every refit at the first fit’s levels / categories (their sections below). The modifiers:

  • Resample ∈ {jackknife, bootstrap} — replaces analytical SE / p-values with resample-based estimates. Forces buffered.
  • Selection ∈ {forward, backward, stepwise} — drives AIC- or BIC-based greedy subset search. Requires Criterion. Forces buffered.

One upstream feature operator (FEAT_POLY) extends the linear core to polynomial regression. Per-row attributes (ATTR_REG_FITTED, ATTR_REG_RESIDUAL, ATTR_REG_LEVERAGE, ATTR_REG_INFLUENCE) attach per-record diagnostics in the output row stream.

The 13 textbook names → Pulse specs

The Indeed regression taxonomy double-counts (Simple ≡ Linear univariate, Multiple ≡ Multiple Linear) and treats orthogonal wrappers (Jackknife, Stepwise) as families. Pulse does not. The table below maps each textbook name onto the corresponding Pulse spec and links to a runnable example file under internal/examples/regression/.

#Indeed namePulse expressionExample
1SimpleREG_OLS with one predictorinternal/examples/regression/02_simple_linear.json
2MultipleREG_OLS with multiple predictorsinternal/examples/regression/03_multiple_linear.json
3Linear= #1internal/examples/regression/02_simple_linear.json
4Multiple Linear= #2internal/examples/regression/03_multiple_linear.json
5LogisticREG_GLM{Family:"binomial", Link:"logit"}internal/examples/regression/04_logistic.json
6RidgeREG_OLS{Penalty:"l2", Alpha:λ}internal/examples/regression/05_ridge.json
7LassoREG_OLS{Penalty:"l1", Alpha:λ}internal/examples/regression/06_lasso.json
8PolynomialFEAT_POLY{Field:x, Degree:n} upstream → REG_OLSinternal/examples/regression/07_polynomial.json
9Bayesian LinearREG_BAYES_LINEAR{Prior:"nig"}internal/examples/regression/08_bayesian_linear.json
10Jackknifeany regression with Resample:"jackknife"internal/examples/regression/09_jackknife.json
11Elastic NetREG_OLS{Penalty:"elasticnet", Alpha, L1Ratio}internal/examples/regression/10_elasticnet.json
12EcologicalGROUP_* upstream → REG_OLS over group means (composed request)internal/examples/regression/01_ecological_fallacy.json
13Stepwiseany regression with Selection:"stepwise", Criterion:"aic"|"bic"internal/examples/regression/11_stepwise.json

Streamability matrix

SpecStreamableMemoryNotes
REG_OLS no penaltyyesO(p²)sufficient stats: n, Σx, Σy, XᵀX, Xᵀy, Σy²
REG_OLS + l1 / l2 / elasticnetyesO(p²)streaming Gram; regularized solve at finalize
REG_BAYES_LINEAR (conjugate NIG)yesO(p²)streaming sufficient stats + closed-form posterior update
REG_GLM (binomial / poisson / gamma / NB)noO(n·p)IRLS / Newton requires multiple passes
REG_MULTINOMIALnoO(n·p)Newton-Raphson requires multiple passes
REG_ORDINALnoO(n·p)Newton–Raphson over every admitted row
Any regression with Resample != ""noO(n·p)LOO / bootstrap refit
Any regression with Selection != ""noO(n·p)refit per candidate subset
REG_OLS / REG_BAYES_LINEAR with a robust covariance (not classical)noO(n·p)second pass for residuals / leverage

pulse_predict reports per-request streamability on PredictResult.Streamable, mirroring the runtime gate.

Operator reference

REG_OLS

Ordinary least squares with optional regularization.

ParamRequiredNotes
targetyesNumeric response field.
predictorsyesOne or more numeric predictor fields.
penaltyno"" (default), "l1", "l2", or "elasticnet".
alphaconditionalRequired and > 0 when penalty != "".
l1_ratioconditionalRequired and in (0, 1) when penalty == "elasticnet".
max_itersnoCoordinate-descent cap (default 1000).
tolnoConvergence tolerance (default 1e-6).
resampleno"jackknife" or "bootstrap". Downgrades streaming.
jackknife_groups / jackknife_bynoDelete-a-group jackknife (see Resample below); exclusive.
selectionno"forward", "backward", or "stepwise". Requires criterion. Downgrades streaming.
conf_levelnoCoverage of ci_lower / ci_upper, 0 < c < 1. Default 0.95. Student t on the residual df.
boundsno{nonnegative: [predictors]}: those slopes are constrained >= 0 (non-negative least squares); see “Non-negative slopes” below.
interceptnotrue (default) fits the intercept. false fits through the origin; see “Solver and intercept” below.
solvernoqr (default) or normal; see “Solver and intercept” below.
covarianceno{type, cluster, cluster2, order_by, entity, lags}: classical (default), hc0–hc3, cluster (CR1 on cluster’s levels, df = clusters − 1; with cluster2, two-way on df = min(G₁, G₂) − 1), hac (Newey–West over order_by, lags an integer or "auto"; with entity, per-entity Newey–West over the order_by periods) or driscoll_kraay (panel: scores summed per period, Newey–West over the periods). See Panel-robust covariance. Drives std_errors, p_values, the intervals and vcov; refused beside a penalty, resample or selection (PROCESSING_REGRESSION_VCOV_UNSUPPORTED). Downgrades streaming.
marginsno{type, terms, scale, binary}: marginal effects — on OLS every one is its coefficient, with its SE, t and interval; streams. See Marginal effects.
collinearityno{basis, groups}: each term’s variance inflation factor and tolerance (generalized VIF for a group of columns), off the weighted predictor moments the fit streams. See Variance inflation factors.

Modifier compatibility: Resample and Selection may be combined; Selection runs first, Resample re-fits the selected subset.

Unpenalized, coefficients, std_errors, p_values, ci_lower / ci_upper, r2, adj_r2, residual_std_err and df are R lm()’s (summary, confint) to relative 1e-10; under frequency weights they are lm() on the rows repeated w times. Oracle: scripts/reference/gen_ols_lm.R.

Every penalty minimizes one objective, glmnet’s with standardize = FALSE and the same one REG_GLM uses: (1/2N*)·Σw·(y − β₀ − Xβ)² + alpha·[(1 − l1_ratio)/2·‖β‖² + l1_ratio·‖β‖₁] (l2 is l1_ratio = 0, l1 is 1), N* the sum of the weights, the intercept unpenalized and the predictors on their own units — so l2 at alpha is the elastic net’s limit at l1_ratio → 0 at the same alpha, and a predictor on a large scale is barely shrunk (divide it by its SD upstream to penalize all alike). l2 is solved in closed form, l1 / elasticnet by coordinate descent on the centred Gram. l2 standard errors are the closed-form ridge sandwich σ̂²·A⁻¹·G·A⁻¹ (A = G + N*·alpha·I, G the centred Gram, σ̂² = RSS / (N* − p − 1)) with Student-t p-values on N* − p − 1 df; l1 / elasticnet report std_errors, p_values and intervals null on every coefficient (the data pick the predictors, so no analytical inference is valid) with the advisory PULSE_ADVISORY_PENALIZED_INFERENCE_UNDEFINED. unpenalized (any penalty) lists predictors the penalty skips — glmnet’s penalty.factor 0: under l2 A = G + N*·alpha·diag(pf) in the sandwich; under l1 / elasticnet coordinate descent gives them neither the soft threshold nor the ridge term, so they are never shrunk and never leave the active set — for controls or dummies that should stay unshrunk; no penalty refuses it with PROCESSING_CONFIG. Oracle: R glmnet for the coefficients (with penalty.factor for unpenalized, every kind) and R matrix algebra for the ridge covariance (scripts/reference/gen_ols_penalty.R).

Non-negative slopes. bounds.nonnegative lists predictors whose coefficient must be >= 0; the intercept and every other slope stay free. Pulse solves the bounded least-squares problem by Lawson–Hanson’s active-set method on the centred Gram (so it streams and takes weights). When the unconstrained fit already satisfies every bound, the result is that fit byte for byte. When a bound binds — a coefficient is held at exactly 0 — the estimator is constrained and its classical inference is not valid: coefficients, r2, adj_r2 and residual_std_err stand, while std_errors, p_values, ci_lower / ci_upper and every vcov entry are null, and the result carries the advisory PULSE_ADVISORY_CONSTRAINT_ACTIVE (details.active names the held predictors). It is result-only: predict cannot know whether a bound will bind. For intervals of the bounded fit set resample: bootstrap — each replicate refits the bounded model. bounds is refused PROCESSING_CONFIG with any penalty or selection, on REG_GLM / REG_BAYES_LINEAR, or for an unknown or repeated name; a robust covariance is PROCESSING_REGRESSION_VCOV_UNSUPPORTED (reason: bounds). Oracle: R nnls (scripts/reference/gen_ols_nnls.R), including a near-collinear case.

Solver and intercept.

  • solver: "qr" (the default). An unpenalized, unbounded fit solves a streaming QR factorization of the weighted design (Givens rotations, as in R’s biglm). The design is shifted to its first row, so a predictor with a large offset stays well separated from the intercept column. The solve works at κ(X), so ill-conditioned designs keep their digits: NIST Filip fits to 7.4 digits, and Wampler1–5 reach 5.7–13.3 (see “How Pulse is validated”).
  • solver: "normal". Solves the normal equations by Cholesky on the centred Gram matrix, at κ(X)². Use it to match a package that solves the normal equations. Both solvers stream.
  • intercept: false. Fits through the origin. The intercept is pinned to 0, not estimated: coefficients["(intercept)"] is 0, so a bound fit scores unchanged, and its std_errors, p_values, ci_lower / ci_upper and vcov row are null. As R’s lm(y ~ 0 + x) reports, r2 is the uncentred Σŷ² / Σy², the residual df is N* − p, and adj_r2 is 1 − (1 − R²)·N*/df. NIST NoInt1 and NoInt2 agree to 14 and 15 digits.
  • Refusals. Both knobs are REG_OLS only and are refused PROCESSING_CONFIG (predict too) on another type. solver is also refused beside a penalty or bounds. intercept: false is also refused beside a penalty, bounds, selection, resample, holdout, a robust covariance or solver: "normal".

Error codes: PROCESSING_REGRESSION_RANK_DEFICIENT, PROCESSING_REGRESSION_SINGULAR_GRAM, PROCESSING_REGRESSION_NO_CONVERGE, PROCESSING_REGRESSION_INSUFFICIENT_DATA, PULSE_ADVISORY_PENALIZED_INFERENCE_UNDEFINED (advisory, l1/elasticnet without resample: null SEs / p-values), PULSE_ADVISORY_CONSTRAINT_ACTIVE (advisory, a binding bounds without resample: null SEs / p-values), PROCESSING_REGRESSION_REGULARIZED_SELECTION (warning, penalty + selection), PROCESSING_CONFIG.

REG_GLM

Generalized linear model via iteratively-reweighted least squares.

ParamRequiredNotes
targetyesNumeric response.
predictorsyesOne or more numeric predictor fields.
familyyes"binomial", "poisson", "gamma", or "negative_binomial" (NB2, below).
linknoOne of the family’s links, the canonical one the default when empty: binomial logit / probit / cloglog, poisson log / identity / sqrt, gamma inverse / log / identity, negative_binomial log / identity / sqrt. Another family’s link is PROCESSING_REGRESSION_INVALID_LINK (predict too).
thetanonegative_binomial only: a fixed θ > 0 (R glm(family = negative.binomial(theta))); absent estimates θ. Elsewhere, or ≤ 0, PROCESSING_CONFIG.
dispersionnonegative_binomial with a fixed theta only: "fixed" (default, φ = 1) or "estimated" (φ̂ = Pearson χ²/df, R’s summary.glm). Elsewhere, with θ estimated, or another value, PROCESSING_CONFIG.
max_itersnoIRLS iteration cap (default 50).
tolnoConvergence tolerance (default 1e-8).
penaltyno"l2", "l1", "elasticnet" (binomial / poisson only; gamma and negative_binomial refuse it).
alphanoPenalty strength, > 0 when penalty is set.
l1_rationoElastic-net mix, 0 < l1_ratio < 1; elasticnet only.
resampleno"jackknife" or "bootstrap"; jackknife_groups / jackknife_by as for REG_OLS.
selectionnoSubset-selection wrapper; requires criterion.
conf_levelnoCoverage of ci_lower / ci_upper (Wald z; gamma t on df), 0 < c < 1. Default 0.95.
covariancenoAs REG_OLS: the sandwich over the IRLS scores at the converged weights (R sandwich on glm) behind std_errors, p_values, the intervals and vcov. Dispersion-free; inference stays Wald z, cluster and gamma included.
marginsno{type, terms, scale, binary}: marginal effects with delta-method SEs — see Marginal effects.
collinearityno{basis, groups}: variance inflation factors on the fit’s working-weighted design (basis: model) or the predictors alone (basis: predictors) — see Variance inflation factors.

Always buffered.

Dispersion. Binomial and poisson fix the dispersion at 1 (the family assumption): standard errors from (XᵀWX)⁻¹, Wald z p-values and intervals, no df. Gamma estimates it, as R’s summary.glm does: φ̂ = Pearson χ² / df, df = N* − p − 1 (N* = n unweighted, Σw under frequency weights, Kish n_eff under probability weights), standard errors and vcov scaled by φ̂, p-values and intervals on a Student t with df, which the result reports (null, with every standard error, p-value and bound, when it is 0 or below). φ̂ itself is not emitted. Oracle: R glm(family = Gamma()) (scripts/reference/gen_glm_gamma.R). A gamma selection scores each candidate by R’s AIC(glm) / BIC(glm) — the gamma log-likelihood at dispersion deviance / n, the dispersion counted as a parameter — not the deviance + 2k that binomial and poisson use (scripts/reference/gen_glm_gamma_selection.R).

Penalties. penalty minimizes glmnet’s objective with standardize = FALSE — −loglik/N* + alpha·[(1 − l1_ratio)/2·‖β‖² + l1_ratio·‖β‖₁], N* the sum of the (prior) weights, the predictors on their own units and the intercept unpenalized (l2 is l1_ratio = 0, l1 is 1). Each IRLS step solves the penalized working least-squares problem: in closed form for l2, by coordinate descent with an exact active-set finish for l1 / elasticnet. For l2, standard errors, Wald p-values and intervals read the penalized-Fisher sandwich H⁻¹·XᵀWX·H⁻¹, H = XᵀWX + N*·alpha·D (D zero on the intercept and on every unpenalized predictor). For l1 / elasticnet they are null on every coefficient, the intercept included — the data choose the active set, so no analytical sampling distribution exists — and the fit (and predict) carries PULSE_ADVISORY_PENALIZED_INFERENCE_UNDEFINED unless resample is set; vcov is refused PROCESSING_REGRESSION_VCOV_UNSUPPORTED. deviance and pseudo_r2 are the unpenalized figures at the penalized estimate. A penalty rides resample (every replicate penalized) and selection (predict warns PROCESSING_REGRESSION_REGULARIZED_SELECTION). unpenalized (any penalty) lists predictors the penalty skips — glmnet’s penalty.factor 0: never shrunk, always in the l1 active set; no penalty refuses it PROCESSING_CONFIG. An l2 penalty keeps a separated binomial fit finite — unless the separating predictor is unpenalized, which nothing bounds: that fit is refused PROCESSING_REGRESSION_SEPARATION. Oracle: R glmnet (scripts/reference/gen_glm_penalty.R, penalty.factor for unpenalized).

The fit is R’s glm.fit IRLS: per-row starting values (binomial (w·y + 0.5)/(w + 1), poisson y + 0.1, gamma y), the step halved back toward the previous coefficients whenever the deviance rises, and convergence on the relative change in the coefficients. An up-front QR rank check of the (weighted) design is the only source of PROCESSING_REGRESSION_RANK_DEFICIENT (details.columns names the aliased columns). A binomial fit whose fitted probabilities reach numerically 0 or 1 while a predictor’s coefficient keeps climbing is separated — the maximum-likelihood estimate is at infinity — and is refused PROCESSING_REGRESSION_SEPARATION (details.predictors) rather than reporting wherever the loop stopped.

Links. Every link is R’s (stats make.link): probit μ = Φ(η) and cloglog μ = 1 − exp(−e^η) clamp μ to [ε, 1 − ε] and floor dμ/dη at ε as R does; the poisson and gamma identity links and the poisson sqrt link keep μ positive, so a step that would push a fitted mean through 0 is halved, as glm.fit does. Nothing assumes a canonical link: the working weight is (dμ/dη)²/V(μ), the score x·(y − μ)·(dμ/dη)/V(μ), so vcov is φ·(XᵀWX)⁻¹ at the expected information (R’s summary.glm), the robust sandwich reads those scores (R sandwich), the working residual is (y − μ)·g′(μ), the leverage is W½X(XᵀWX)⁻¹XᵀW½, and DFFITS carries the sign of g′(μ). Off the canonical link IRLS is Fisher scoring, which converges linearly: at the default tol the coefficients sit within about 1e-7 (relative) of the MLE; tol: 1e-12 reaches R’s to 1e-13. A first step that lands outside the link’s range (R’s glm stops there, “no valid set of coefficients”) is halved toward the intercept-only fit instead. An omitted link is the canonical one. Penalties, selection, resample, covariance, the per-row attributes over a bound fit and model files all take every link; the file’s link key carries it. Oracle: R 4.6.1 glm(family = <family>(link = <link>)) and sandwich 3.1-3 (scripts/reference/gen_glm_links.R).

Negative binomial. family: "negative_binomial" is NB2, Var = μ + μ²/θ, for counts more variable than a poisson allows. θ is estimated by maximum likelihood as MASS glm.nb does: a poisson fit on the same link, then rounds of θ ← the Newton root of the θ score at the fitted means (MASS theta.ml, from the moment estimate, then the previous θ) and β ← IRLS at that θ (warm-started), until a round moves θ by at most tol relative and β by less than tol; one more IRLS fit at the final θ makes β, the deviances and vcov those at θ̂. That is the joint MLE glm.nb approximates (its own stopping rule leaves it ~1e-6 off; the oracle pushes it to the fixed point). theta fixes θ instead: R’s glm(family = negative.binomial(theta)). The result adds theta and theta_std_err (1/√I(θ̂), estimated θ only); its two_log_lik and aic count θ when it is estimated (MASS’s AIC; below). Standard errors and vcov are (XᵀWX)⁻¹ at θ̂ with φ = 1, Wald z (summary.negbin, which treats β and θ as orthogonal — also for a fixed θ, where R’s summary.glm would estimate a dispersion). deviance / null_deviance are at θ̂. A robust covariance holds θ̂ fixed (as sandwich on a glm.nb fit); the residual kinds, leverage and influence over a bound fit read V(μ) at θ̂ with φ = 1; scoring needs only the link. Weights (frequency and probability) enter as prior weights like every family; a frequency fit is the rep() expansion’s. A penalty (any kind, unpenalized too) re-estimates θ around the penalized fit — the same alternation, each β step the penalized IRLS — or holds a fixed theta, as mpath::glmregNB does; the result adds theta, and theta_std_err (1/√I(θ̂) at the penalized means) under l2 only (null under l1 / elasticnet, like the coefficients’); a penalty beside dispersion: "estimated" is refused (details.requires unpenalized: φ̂ reads the residual df). Oracle: mpath 0.4-2.28 (scripts/reference/gen_glm_nb_penalty.R), log link. selection and resample re-estimate θ inside every refit (or hold a fixed theta): each selection candidate is scored by its own log-likelihood at its own θ̂, θ counted (−2ℓ + k·(rank + 1); MASS stepAIC on glm.nb walks the same path), and each jackknife / bootstrap replicate refits β and θ̂ on its rows — theta stays the full-data θ̂, theta_std_err becomes θ̂’s replicate SE (estimated θ only), and resampled margins read each replicate’s own fit. Oracle: scripts/reference/gen_glm_nb_refit.R (stepAIC; a fixed θ against an exact greedy, since step / stepAIC on a glm rank moves by a one-step approximation; base-R glm.nb replicate loops). Counts no more variable than a poisson put θ̂ at infinity: PROCESSING_REGRESSION_NO_CONVERGE details.reason theta_unbounded (fit poisson). A model file carries θ (feature theta).

Fixed-θ dispersion. With a fixed theta, dispersion chooses φ: "fixed" (the default, φ = 1, Wald z — the behaviour above) or "estimated", which is R’s summary(glm(family = negative.binomial(theta))): φ̂ = Pearson χ²/(N* − p − 1), vcov and the standard errors scaled by it, Student-t p-values and intervals on df, dispersion beside a classical vcov, and the influence figures over a bound fit on φ̂ — standardized residuals and Cook’s distance at φ̂, studentized residuals and DFFITS on the leave-one-out σ, as R’s rstudent / dffits on that fit. A robust covariance stays dispersion-free (Wald z). Such a fit’s model file adds its dispersion beside θ (features dispersion and theta). Refused (PROCESSING_CONFIG, details.requires): dispersion on another family or regression (family negative_binomial), with θ estimated (theta: glm.nb’s φ is 1), or another value (dispersion fixed or estimated).

Oracle: R 4.6.1, MASS 7.3-66, sandwich 3.1-3 (scripts/reference/gen_glm_nb.R).

Error codes: PROCESSING_REGRESSION_INVALID_FAMILY, PROCESSING_REGRESSION_INVALID_LINK, PROCESSING_REGRESSION_RANK_DEFICIENT, PROCESSING_REGRESSION_SEPARATION, PROCESSING_REGRESSION_NO_CONVERGE, PROCESSING_REGRESSION_INSUFFICIENT_DATA, PROCESSING_CONFIG.

Log-likelihood and AIC

Every plain REG_OLS and REG_GLM fit reports two_log_lik (2ℓ, the maximised log-likelihood) and aic (−2ℓ + 2k), R 4.6.1’s logLik() / AIC() exactly, k being logLik’s df:

Fitℓk
REG_OLSlogLik.lm: −N*/2·(log(2π·RSS/N*) + 1)coefficients + 1 (σ)
binomial, poissonΣw·log f(y; μ) (the family’s aic)coefficients
gammaΣw·log dgamma(y; 1/φ, μφ) at φ = deviance / N* (Gamma()$aic, not summary.glm’s Pearson φ̂)coefficients + 1 (φ)
negative binomialMASS glm.nb’s log-likelihood at θcoefficients, + 1 when θ is estimated

Unweighted, and under a frequency weight the rep()-expanded fit’s figure (R’s glm(weights = f) agrees; lm(weights = f) does not, reading the weights as precision weights). Absent under a probability weight — a weighted pseudo-likelihood is not a likelihood — and on a penalized fit, an OLS fit whose bounds bind, and REG_BAYES_LINEAR. A poisson or binomial response that is not a whole count has likelihood 0 (R’s dpois / dbinom), so 2ℓ is −Inf and aic +Inf, both null on the wire. Selection scores OLS and gamma candidates by these same likelihoods; binomial and poisson candidates by deviance + 2k, which differs from aic by a constant every candidate on the same rows shares. Oracle: scripts/reference/gen_loglik.R (lm with and without an intercept, the canonical-link GLMs, frequency weights against rep()), with the non-canonical links in gen_glm_links.R and the negative binomial in gen_glm_nb.R.

Marginal effects (margins)

"margins": {type, terms, scale, binary} on a REG_OLS or REG_GLM entry (on REG_MULTINOMIAL per category and REG_ORDINAL per level — below; on an extension model that declares Margins) adds regressions[i].margins: per term the effect of a unit change in the predictor on the expected outcome, with a delta-method standard error. It mirrors vcov — opt-in, additive, absent byte-identical — and every knob has a default, so "margins": {} reports the average marginal effect of every predictor on the response scale (Stata margins, dydx(*); R marginaleffects::avg_slopes).

KnobValuesDefaultMeaning
typeame, memameame: the (weighted) mean over the fitted rows of β_j·μ′(η_i). mem: β_j·μ′(x̄ᵀβ) at the (weighted) predictor means (Stata atmeans; marginaleffects::slopes(newdata = "mean")), echoed as at.
termspredictorsevery predictorEach a listed predictor, once.
scaleresponse, linkresponseresponse: ∂μ/∂x through the inverse link. link: ∂η/∂x — the coefficient itself.
binaryslope, contrastslopeslope: every term’s derivative. contrast: a predictor whose fitted values are all 0 or 1 reports the discrete contrast μ(x=1) − μ(x=0) (below), listed in contrasts; every other term keeps its slope.

The result is {type, scale, terms, binary, contrasts, estimates, std_errors, statistics, p_values, ci_lower, ci_upper, df, conf_level, inference, at}, the maps keyed by term like the coefficient table (df only for a Student t, at only for mem, binary / contrasts only under binary: "contrast" — contrasts only when a term is 0/1 — and inference only under resample).

  • Delta method. Var = J·V·Jᵀ, V the fit’s own coefficient covariance — the one std_errors reads, so hc0–hc3, cluster and hac carry through. For ame, J_jk = δ_jk·m̄ + β_j·Σw·μ″(η_i)·x_ik/Σw with m̄ = Σw·μ′(η_i)/Σw (x_i0 = 1); for mem, J_jk = δ_jk·μ′(η̄) + β_j·μ″(η̄)·x̄_k. On the link scale, and on any identity link (all of REG_OLS; poisson, gamma and negative binomial identity), J = e_j: the effect, its standard error, p-value and interval are the coefficient’s, bit for bit.
  • Reference distribution is the coefficient table’s: a Student t on the fit’s df for REG_OLS (the cluster fit’s G − 1 included) and a classical gamma fit, Wald z otherwise (binomial, poisson, negative binomial, any robust GLM). Intervals at the fit’s conf_level.
  • Weights. The mean is weighted by the fit’s row weight (marginaleffects wts), and mem’s point is the weighted means; a frequency-weighted block equals the rep() expansion’s.
  • Multiplicity. Under the regression’s own multiplicity block the terms form a family of their own, one per regression — never pooled with the coefficients’ request / compose family, so a coefficient’s p_adjusted is byte-identical with margins and without — and the block gains p_adjusted / significant_adjusted and a multiplicity echo (family: "margins", m the terms); the raw p_values never move. margins is echo-only: a block naming it is PULSE_MULTIPLICITY_INVALID.
  • Execution. REG_OLS’s effects are its coefficients, so the block needs no row and streams (and merges across shards) with the fit; mem’s at is the accumulator’s weighted means. REG_GLM is buffered: one pass over the fitted rows in record order after IRLS converges, so the block answers bit for bit the same under every DecodeWorkers / ShardWorkers count, as the fit does.
  • Refusals (PROCESSING_CONFIG, details.requires, identical at predict and run — internal/regmargins): a type / scale outside its values; a term that is not a predictor or repeats (a predictor); REG_BAYES_LINEAR (a type that reports margins); an extension or model regression not declaring margins (declared_margins, the shared-slot table’s {regression, slot: "margins"}); a penalty (unpenalized), selection (no_selection) or bounds (unbounded); a predictor derived from another predictor of the same regression (independent_predictors, details.predictor / depends_on / path) — the field-reference walk records what every feature, attribute and window reads (its field, params columns, expression names, order / partition keys, vector members) and follows those reads transitively, at predict and run alike — since the effect of one holding the other fixed (x² beside x, an interaction beside its factors) is not defined.
  • Under resample. Every replicate refit — jackknife (leave-one-out, jackknife_groups, jackknife_by) or bootstrap — re-estimates the effects from its own β, rows and prior weights: the replicate’s ame (its rows’ weighted mean), its mem (at its rows’ means) or the contrast of each term the full fit lists in contrasts. The effect’s replicate spread replaces the delta-method SE exactly as the coefficients’ replaces theirs — jackknife √((g − 1)/g·Σ(θ₍ₖ₎ − θ̄)²), bootstrap the B − 1 sample SD over the successful replicates — with the resampled coefficient table’s inference: statistic estimate / SE, p the Wald z (jackknife) or the percentile p (bootstrap, floored at 1/B), the interval Wald normal at conf_level, no df. The estimates (and at) stay the full fit’s, and the block adds inference: "resample". An effect that is a coefficient (the link scale, an identity link, all of REG_OLS; REG_MULTINOMIAL’s and REG_ORDINAL’s link scale) therefore reports the coefficient table’s SE, p and interval bit for bit. A margins block never moves the replicates — the rng_seed: 0 seed ignores it — so the coefficient table is byte-identical with or without it. REG_MULTINOMIAL, REG_ORDINAL and a declared extension model refit through the extension drivers, each replicate reporting its block again. The p-values join the margins multiplicity family. Oracle: base-R replicate loops of the effect itself (gen_margins_resample.R → margins_resample.json: lm and logit / probit / poisson glm, ame / mem / contrast, leave-one-out, delete-a-cluster and frequency-weighted jackknife, a bootstrap over R’s own index sets) at 1e-7 (TestReferenceOracle_MarginsResampleMatchesR).
  • Binary contrast (binary: "contrast"). A term whose value is exactly 0 or 1 on every fitted row (judged on the rows the fit used, so a one-hot dummy, a 0/1 field or a cond ? 1 : 0 attribute all qualify) reports C_j = μ(x_j=1) − μ(x_j=0), the other predictors as observed (ame: the weighted mean over the rows of μ(η_i1) − μ(η_i0), η_i1 / η_i0 the row’s linear predictor with x_ij set to 1 / 0) or at their weighted means (mem: x̄ with x̄_j set to 1 and 0) — marginaleffects’ default for a binary column (avg_comparisons). Its gradient is J_k = Σw·(μ′(η_i1)·x1_ik − μ′(η_i0)·x0_ik)/Σw. On the link scale and on an identity link the contrast is β_j, the coefficient, exactly as the slope. REG_MULTINOMIAL contrasts each category’s probability π_c(1) − π_c(0), REG_ORDINAL each level’s P_k(1) − P_k(0); a declared extension model gets the value in extend.MarginsRequest.Binary and lists its contrasted terms in MarginsOutput.Contrasts. binary outside its values is refused like type; the block streams on REG_OLS (a per-row 0/1 flag). Absent or slope is byte-identical.
  • Derived predictors are differentiated with respect to the column as given: the effect of a FEAT_LOG output is that of a unit change in log1p(z), and under the default binary: "slope" a one-hot dummy’s (or any 0/1 column’s) is its slope — Stata’s dydx on a continuous-coded dummy. Oracle: logit_ame_derived (a pre-computed log1p column and a dummy, under binary: "contrast") in gen_margins.R, matched end to end through the features by TestMargins_DerivedPredictorsMatchR.
  • Factors. Pulse regressions take numeric predictors only (a categorical’s dictionary index is refused), so there are no factor terms to contrast; a 0/1 dummy gets a slope unless binary: "contrast" asks for the discrete difference between its levels.

Oracle: R 4.6.1 analytic closed forms (MASS 7.3-66, sandwich 3.1-3 vcovHC / vcovCL) at 1e-9 — lm, logit, probit, cloglog, poisson, gamma inverse / log, negative binomial; HC3 and cluster; link scale; mem; a frequency-weighted pair against the rep() expansion; binary: "contrast" on each of those families, OLS, the ordinal and the multinomial blocks — and marginaleffects 1.0.0 avg_slopes / slopes(newdata = "mean") at 1e-7, its numerical-derivative accuracy (measured within 7e-9; its 1 − 0 contrast of a 0/1 term under binary: "contrast") (scripts/reference/gen_margins.R, margins.json).

Variance inflation factors (collinearity)

"collinearity": {basis, groups} on a REG_OLS or REG_GLM entry adds regressions[i].collinearity: per term its variance inflation factor (VIF) — how many times its coefficient variance is inflated by overlap with the other predictors — and tolerance 1/VIF. It is R’s car::vif(model) (Stata estat vif) on the fit itself; MAT_COLLINEARITY gives the same VIF (plus Belsley’s diagnostics) for a candidate predictor set before any model. Opt-in, additive, absent byte-identical; "collinearity": {} reports every predictor on the model basis.

KnobValuesDefaultMeaning
basismodel, predictorsmodelmodel: the fit’s information matrix XᵀWX at the fitted weights, centered on its intercept — the prior weights on REG_OLS, prior × IRLS working weights at the converged β on REG_GLM — which is what car::vif reads through vcov(model) (φ cancels). predictors: the prior-weighted predictor correlation alone, car::vif on lm over the same predictors and weights, MAT_COLLINEARITY’s VIF. On REG_OLS the two are one matrix.
groups[{name, predictors}]noneMulti-column terms: each group’s predictors (a FEAT_ONE_HOT block’s dummies, a spline basis) are judged together; every other predictor is a term of its own, named after itself. A predictor joins at most one group; a group’s name must differ from every other term’s.

The result is {basis, terms, df, vif, tolerance, gvif_scaled}, the maps keyed by term (a predictor or a group’s name), terms in order (a group at its first predictor’s position), gvif_scaled only when groups is set.

  • Generalized VIF. For a term S the figure is Fox & Monette’s (1992) GVIF det(R_SS)·det(R_−S,−S)/det(R), R the basis’s correlation of the predictor columns — computed as det(R_SS)·det((R⁻¹)_SS), one inverse for every term; on one column it is (R⁻¹)_jj, the classical VIF. df is the term’s column count and gvif_scaled = GVIF^(1/(2·df)), car’s GVIF^(1/(2*Df)), comparable across terms of different size as √VIF is for one column (a group’s GVIF itself grows with its df). The arithmetic is MAT_COLLINEARITY’s, shared (internal/collinearity): its VIF did not move a bit.
  • A design figure. The VIF reads the predictors and, on a GLM’s model basis, the fitted weights — not the estimator: a REG_OLS penalty, bounds, a robust covariance, resample and holdout leave it the plain fit’s on the same rows; dispersion and the sandwich never enter. Unbanded: 5 and 10 are rules of thumb (O’Brien 2007).
  • Weights. The fit’s prior weights; a frequency-weighted block is the rep() expansion’s, and both kinds give the same figures (the correlation is scale-free).
  • Execution. REG_OLS reads its streaming accumulator’s centered moments, so the block streams and merges across shards with the fit; REG_GLM takes one two-pass weighted pass over the fitted rows in record order after IRLS converges. Both answer bit for bit the same under every DecodeWorkers / ShardWorkers count. A correlation that is not positive definite in double precision nulls every figure (the fit stands).
  • Refusals (PROCESSING_CONFIG, details.requires, identical at predict and run — internal/collinearity): a basis outside its values; a group with no name (a group name), no predictor, a member that is not a predictor or sits in two groups (a predictor), a name clashing with another term (a unique term name); REG_BAYES_LINEAR, an extension or model regression (type REG_OLS or REG_GLM); intercept: false (intercept — an uncentered VIF measures distance from 0, which car warns “may not be sensible”); selection (no_selection); a REG_GLM penalty on basis model (unpenalized — the working weights would be the shrunken fit’s; basis predictors is allowed); fewer than two terms (two_or_more_terms, car’s own floor).

Oracle: car 3.1-5 vif on R 4.6.1 at 1e-10 (measured within 2e-15) — lm, binomial logit, poisson log, fixed-θ negative binomial and gamma log; ungrouped and with a three-level factor’s dummies as one term; both bases; frequency weights against the rep() expansion and probability weights — each re-derived in the script from the weighted design’s closed form (scripts/reference/gen_vif.R, vif.json), and end to end through FEAT_ONE_HOT (TestCollinearity_OneHotMatchesCar).

Row order (order)

"order": {"field": "week", "partition": "market", "gaps": "refuse"} on any regression fits the rows in time order: the engine sorts them by field (an unsigned integer period index, date or datetime) within each partition series (optional; ragged starts and ends are fine), after listwise deletion, before any fit. Under gaps: "refuse" (the default and only policy) a repeated period in one series (reason: duplicate) or a step that is not the cadence — the smallest positive step over every series — (reason: gap) fails that slot alone with PROCESSING_REGRESSION_ORDER. A null field or partition drops its row; a filtered or null-target row inside the span leaves a gap. Months on a date read as gaps: order such a series by an integer period index. An order forces the buffered path; a holdout fits the ordered (gap-checked) train rows and scores the held-out rows in order. A model that carries state across rows requires an order and refuses a spec without one (PROCESSING_CONFIG, reason: order_required). REG_MMM_BAYES reads order.field as its time field — params.time is its deprecated alias (the same fit and seed; both set must agree, time_alias_conflict) — and on a geo panel needs partition = params.geo. Rides capability:regression_order.

Panel-robust covariance

A panel is entities (geos, stores) observed over shared periods. A plain hac reads one series and refuses a repeated order_by (order_by_ties), so two panel estimators read the panel instead, on REG_OLS, REG_GLM and REG_BAYES_LINEAR:

  • Per-entity Newey–West — {"type": "hac", "order_by": "week", "entity": "geo"}: each entity is its own series; the Bartlett meat pairs an entity’s rows l periods apart (weight 1 − l/(L+1)) and never pairs two entities.
  • Driscoll–Kraay — {"type": "driscoll_kraay", "order_by": "week"}: the scores u = w*·g of one period are summed across entities, then the Newey–West meat runs over the period sums — robust to a shock that hits every entity in a week as well as to serial correlation.

The periods are the distinct order_by values over the fitted rows; a lag counts periods, not rows (an entity missing week 5 pairs its weeks 4 and 6 at lag 2). lags "auto" is ⌊4(T/100)^(2/9)⌋ over the T periods. Both scale by N*/(N* − k); OLS stays t on N* − k, GLM Wald z, Bayes the Müller sandwich posterior. entity takes the order.partition key types (categorical, unsigned integer, date, datetime, packed_bool); it is optional under driscoll_kraay. An entity repeating an order_by value is refused at run time (PROCESSING_REGRESSION_VCOV_UNSUPPORTED, order_by_ties, with entity_value) — predict cannot see it; the shape rules (driscoll_kraay without order_by, entity on another type or naming the order_by field) are PROCESSING_CONFIG in predict and at run time. The echo adds periods and, with an entity, entity / entities. Oracle: sandwich::vcovPL(aggregate = FALSE / TRUE), cross-checked by plm::vcovNW / vcovSCC(type = "HC1") (scripts/reference/gen_robust_vcov_panel.R); "auto" equals vcovPL’s lag = "NW1994" (plm’s default lag differs — pass lags).

Two-way clustering — {"type": "cluster", "cluster": "geo", "cluster2": "week"}: Cameron, Gelbach & Miller (2011), V = B·[G₁/(G₁−1)·M₁ + G₂/(G₂−1)·M₂ − G₁₂/(G₁₂−1)·M₁₂]·B·(N* − 1)/(N* − k), M_c the cluster meat over c’s levels and M₁₂ over the intersection cells (G₁₂ of them) — sandwich::vcovCL(cluster = ~geo + week, type = "HC1") (cadjust = TRUE, multi0 = FALSE). On REG_OLS, REG_GLM and REG_BAYES_LINEAR; REG_OLS reads t on min(G₁, G₂) − 1 df. The meat is a difference, so with few clusters a variance can come out negative: it is kept in vcov (vcovCL’s fix = FALSE) and its standard error, p-value and interval are null, never a clamped 0. cluster2 takes the cluster field types; off type cluster or naming cluster it is PROCESSING_CONFIG, on REG_MULTINOMIAL or an extension model (whose cluster is one-way) PROCESSING_REGRESSION_VCOV_UNSUPPORTED reason: type, and a second field with fewer than two levels in the fitted rows reason: clusters (details.cluster names it). The echo adds cluster2 / clusters2. Oracle: robust_vcov_panel.json cluster2_cases (geo × week and geo × four-week month; unweighted, frequency, probability).

Nested-model comparison (Compose compare)

A Compose batch’s compare list tests two of its regression fits against each other: does the full model’s extra terms improve on the restricted model it contains? It is R’s anova(m0, m1) (test = "F" | "Chisq" | "LRT"), MASS’s anova.negbin and lmtest::waldtest(m0, m1, vcov = V); Stata’s lrtest / test. Each entry {name, restricted, full, test, multiplicity} runs once the fits have run, reading no record; the results are ComposedResponse.comparisons, in declaration order, outside the Compose return. Opt-in, additive, absent byte-identical; gated by capability:compose_compare (which depends on capability:compose_fits and REG_OLS, REG_GLM or REG_ORDINAL, so a feature profile can keep fits and hide comparisons).

testStatisticReference distribution
f((D₀ − D₁)/q) / φ̂₁F on (q, df₁)
lrt(D₀ − D₁) / φ₁; a θ-estimated negative binomial 2ℓ₁ − 2ℓ₀χ² on q
waldb_Sᵀ V_SS⁻¹ b_S over the full fit’s covariance VF = W/q on the coefficient table’s df where its p-values are Student t, else χ² on q

D is each fit’s residual deviance (the weighted RSS on REG_OLS, deviance on REG_GLM), df its residual df N* − rank, q the number of tested terms, φ̂₁ the full fit’s estimated dispersion (σ̂² = RSS₁/df₁; the Pearson χ²/df₁ on gamma and on a fixed-θ negative binomial under dispersion: estimated, computed under a robust covariance too, as anova.glm reads summary.glm’s), φ₁ = 1 on a family that fixes it. V is the covariance the full fit’s standard errors read — classical, or the HC / cluster / HAC sandwich its covariance chose — and the df the coefficient table’s (G − 1 on a cluster-robust REG_OLS fit, where waldtest would read n − k; Stata’s test after regress, vce(cluster) reads G − 1). Omitted, test takes R’s anova default: f on REG_OLS and on a family that estimates its dispersion, lrt on every other family. A classical REG_OLS Wald test equals its F test.

Over a resampled fit. Under resample, V is the full fit’s jackknife / bootstrap replicate covariance — the matrix its vcov reports and its standard errors are the square roots of, formed for the comparison whether or not vcov is asked for (over the same replicates; a skipped bootstrap replicate is absent from both) — and the test is χ² on q on every type, as the resampled coefficient table is Wald z: car::linearHypothesis(m1, vcov. = V, test = "Chisq"). f and lrt read the base fits’ deviances, unchanged by the resample. Both fits carry the same resample knobs (the same-rows rule); the replicates — and so the statistic — are the same whether or not the full fit asks for vcov, since the rng_seed: 0 seed ignores it as it ignores margins. Oracle: scripts/reference/gen_compare_resample.R → compare_resample.json (manual base-R replicate loops; leave-one-out and delete-a-cluster jackknife, a bootstrap over R’s own index sets; lm, logit, poisson, gamma log), TestReferenceOracle_CompareResampleMatchesR at 1e-9 relative (1e-6 on the gamma log link).

  • Nesting is verified, never assumed (internal/regcompare, shared by predict and the runtime): both names bind regression fits of one type, REG_OLS, REG_GLM, REG_MULTINOMIAL (below) or a model declaring comparisons (REG_ORDINAL — below — or an extension registered with Compare), not the same fit twice (two vector fits compare member-wise, a from_sweep fit is judged per sweep slot, and two SEM fits compare by their chi-square difference, all below); every restricted term — its predictors, and (intercept) when it fits one — is a full-fit term, and the full fit adds at least one (the result’s terms, in the full fit’s order). A restricted fit through the origin is nested in one with an intercept; the reverse is not.
  • Same rows. The two fit requests must be equal but for the regression’s predictors, intercept and reporting knobs (name, vcov, conf_level, margins, collinearity, save, multiplicity) and the request’s label, return, disable_components and multiplicity — so the cohort, filters, features, attributes, windows, weight, holdout, family, link (an omitted link equals its family’s default), theta, dispersion and covariance agree (request_mismatch, details.keys names the differences; declare a feature only the full model reads in both requests). The full fit’s rows, listwise over a superset of columns, are then a subset of the restricted fit’s, so equal row counts mean the same rows: once fitted, unequal counts fail the comparison alone with PULSE_COMPARISON_ROWS_DIFFER (R’s anova stops on unequal sizes the same way).
  • Weights. The fits’ own (equal) weight. A frequency weight is the rep() expansion’s (df = Σw − rank). A probability weight refuses f and lrt (requires: no_probability_weight, alternative: wald): the fits’ deviances are pseudo-likelihoods there, as two_log_lik is absent; the Wald test on a robust covariance is the design-consistent comparison.
  • Multiplicity. A comparison is one hypothesis: it inherits like a test (its own multiplicity → the batch’s → Options.DefaultMultiplicity), in the batch’s compose family (the only one it offers), p_adjusted / significant_adjusted / multiplicity beside the raw p_value.
  • Result. {name, restricted, full, test, distribution, terms, statistic, df, df_residual (F only), p_value, n_obs, restricted_df_residual, full_df_residual, restricted_deviance, full_deviance, dispersion (the φ divided by; absent on Wald and a θ-estimated negative binomial), restricted_two_log_lik / full_two_log_lik (a θ-estimated negative binomial's LR only)}; an undefined figure (a residual df ≤ 0, a V_SS not positive definite) is null.
  • Fails alone. A fit the comparison reads that failed on its data (its own code, details.fit), or unequal rows, keep the entry’s {name, restricted, full, test, error} and lift PULSE_SLOT_FAILED (slot_kind: comparisons); Strict fails the batch with the code. --stream ends with one {"comparisons": [...]} line.
  • Sweep-bound fits. A side bound from the sweep (from_sweep) is refitted on the rank-1 slot, known only after the sweep runs. Predict and the runtime’s pre-fit rule judge the comparison against the fit request of every sweep slot that could win (two sweep-bound sides bind the same slot): every slot refusing is the refusal (the first slot’s); otherwise the entry is valid, and predict’s summary carries unresolved {slots, refused [{slot, label, reason}], varies} when some slots refuse or the passing ones resolve another test / distribution (the summary is then the first passing slot’s). The regression’s type, target and predictors are axis-invariant (from_sweep_signature_varies), so not_nested and the type rules never vary by slot; an axis reaching the rows (request_mismatch), a modifier (requires) or the family (the default test) does. An adaptive sweep’s later slots are judged at their representative point. After the rank the run judges the winner again: a refusal there fails the comparison alone with its own PULSE_COMPARISON_INVALID (details.sweep_slot / sweep_label; Strict fails the batch). Oracle: scripts/reference/gen_compare_sweep.R → compare_sweep.json (R ranks the row windows the same way and runs anova / waldtest on the winning pair; lm F, poisson LRT, logit Wald), TestReferenceOracle_CompareSweepMatchesR at 1e-10.
  • Vector fits. When restricted names a vector fit, full must be one too (fit_kind, the vector fits under available), both batteries must list their members — fields, or a vectors entry with fields (its labels name them); a pattern or a vector field resolves only at run, members_unlisted — every restricted member (label and column) must be a full member (not_nested), the full battery must add one (no_extra_terms), and the requests must be equal but for the member lists and the battery’s reporting knobs (a matrix slot’s name, encoding, multiplicity; an attribute’s label) and the request’s label, return, disable_components, multiplicity (request_mismatch). A probability weight is refused (requires: no_probability_weight, no alternative). Each restricted member j is one row of members: the Gaussian lm(j ~ the other restricted members) against lm(j ~ the other full members), both residual sums of squares Schur complements of the full fit’s co-moment M2 (RSS(j | S) = M2_jj − M2_jS M2_SS⁻¹ M2_Sj), N* = Σw, df₁ = N* − p_full, σ̂² = RSS₁/df₁: f (default) ((RSS₀ − RSS₁)/q)/σ̂² on (q, df₁), lrt (RSS₀ − RSS₁)/σ̂² on χ²(q), wald the classical W/q on (q, df₁) — equal to F on a linear model. The rows are {member, statistic, p_value, restricted_deviance, full_deviance, dispersion (not on Wald)} with their own p_adjusted / significant_adjusted / multiplicity — each row one test of the compose family; the comparison keeps terms (the tested members), df, df_residual, n_obs, both residual dfs, and its single-pair statistic, p_value and deviances are null. Unequal rows (N or Σw) fail alone (PULSE_COMPARISON_ROWS_DIFFER). Predict’s summary lists members. Oracle: R 4.6.1 per-member anova(lm) / test = "Chisq" / lmtest::waldtest, one with a frequency weight as the rep() expansion, at 1e-10 (scripts/reference/gen_compare_vector.R, compare_vector.json; TestReferenceOracle_CompareVectorMatchesR); TestCompareVector_* (root) holds predict ≡ runtime, the rows against the regression engine’s own comparison of the same two models, worker invariance and the multiplicity fold.
  • SEM fits. Two fits entries each holding one MAT_SEM matrix compare by lavaan’s lavTestLRT: test is lrt (the default; f / wald are test_unsupported), distribution chisq, terms empty, df = d₀ − d₁, restricted_df_residual / full_df_residual each fit’s model df and restricted_deviance / full_deviance each fit’s model χ² (the chi2 scalar: lavaan’s standard test on a lavaan-convention fit). Under ml and dwls the statistic is the plain difference T₀ − T₁; under wlsmv the Satorra–Bentler (2001) scaled difference (T₀ − T₁)/c_d, c_d = (d₀c₀ − d₁c₁)/(d₀ − d₁) with c = tr(UΓ)/df each fit’s mean-adjusted scaling factor (lavaan’s method = "satorra.bentler.2001" on the satorra.bentler test — lavaan’s own default for a scaled-shifted fit is satorra.2000, which Pulse does not compute), reported as scaling_factor (null, with the statistic and p, where c_d < 0). Nesting is declared, never proven (no NET check): the two fit requests are equal but for params.model, group_equal, group_partial and the reporting and solver knobs (ci_level, resample, bootstrap_iters, rng_seed, solver, information, ftol, max_iter, grad_tol) — so the members, group, estimator, ordered set and meanstructure agree (request_mismatch); the model knobs differ (same_model); written models name the same observed variables (observed_differ, restricted_only / full_only); a SEM fit beside a regression fit is kind_mismatch. Once run, a restricted fit whose df does not exceed the full fit’s (df_not_positive: the df count the data’s thresholds and groups) or a pair where only one fit follows lavaan’s conventions or models the means (conventions_differ) fails the comparison alone with PULSE_COMPARISON_INVALID; unequal row or group counts with PULSE_COMPARISON_ROWS_DIFFER (reason: rows_differ). MLR is no Pulse estimator. Oracle: scripts/reference/gen_sem_compare.R → sem_compare.json (lavaan 0.7.3 on the brand survey: a dropped path, the metric and scalar invariance steps across the waves, a fixed factor covariance under DWLS and WLSMV, WLSMV threshold + loading invariance), TestReferenceOracle_CompareSEMMatchesR (internal/integration) at 1e-8 (ML) / 1e-6 (ordinal) relative.
  • Refusals (PULSE_COMPARISON_INVALID, details.reason, details.compare the entry index, identical at predict and run): name_missing, name_duplicate, fit_missing, fit_unknown (available), fit_kind, members_unlisted (two vector fits), same_fit, type_unsupported, type_mismatch, test_unknown, not_nested (missing), no_extra_terms, request_mismatch (keys) and requires — unpenalized (a penalty), no_selection, unbounded (bounds), estimated_dispersion (f on a fixed dispersion, on REG_MULTINOMIAL and on a declared model), no_probability_weight; levels_differ (two declared fits whose params.levels differ); reference_differs (two REG_MULTINOMIAL fits whose reference differs: restricted_reference / full_reference); between SEM fits kind_mismatch, test_unsupported, same_model and observed_differ (above). Predict’s compare summary lists each valid entry’s resolved test, distribution and terms (and a sweep-bound entry’s unresolved).

Oracle: R 4.6.1 anova with MASS 7.3-66, sandwich 3.1-3 and lmtest 0.9-40 at 1e-10 (measured within 2.2e-14) — lm (F, Chisq, classical and HC3 Wald, a restricted fit through the origin, frequency weights against the rep() expansion), binomial logit (LRT, Wald, HC3 Wald) and probit, poisson (LRT, Wald, frequency LRT), gamma inverse (F, LRT, Wald) and log (frequency F), negative binomial with θ estimated (anova.negbin, Wald) and fixed (LRT at dispersion 1, F at the Pearson dispersion) — each statistic re-derived in the script from its closed form (scripts/reference/gen_nested.R, nested.json, TestReferenceOracle_NestedMatchesR).

REG_BAYES_LINEAR

Bayesian linear regression with a conjugate Normal-Inverse-Gamma prior.

ParamRequiredNotes
targetyesNumeric response.
predictorsyesOne or more numeric predictor fields.
priornoOnly "nig" accepted in v1. Default "nig".
prior_munoLength p+1 mean vector (intercept first); defaults to zero.
prior_precisionnoScalar ε ≥ 0 on the precision matrix ε·I (default 1e-3), or a list of p+1 entries, intercept first like prior_mu, for Λ₀ = diag(v): 0 is a flat prior on that coefficient, a large entry pins it to its prior_mu. A wrong length or a negative entry is PROCESSING_CONFIG (predict too); flat entries the data cannot identify leave the posterior improper (PROCESSING_REGRESSION_RANK_DEFICIENT). Oracle: scripts/reference/gen_bayes_precision.R.
prior_shapenoInverse-gamma shape a₀. Default 1e-3.
prior_ratenoInverse-gamma rate b₀. Default 1e-3.
credible_levelnoPosterior interval mass. Default 0.95.
conf_levelnoMass of ci_lower / ci_upper (the same posterior t interval). Defaults to credible_level.
covariancenoAs REG_OLS. Keeps the posterior-mean coefficients but REPLACES the posterior covariance with Müller’s (2013) sandwich posterior N(μ_n, Λ_n⁻¹·M·Λ_n⁻¹): std_errors, credible_intervals, ci_lower / ci_upper (normal, no df) and vcov follow it. A substitution, not the conjugate posterior: honest under heteroskedastic or dependent rows, but no longer the conjugate model’s probability statement. Downgrades streaming.

Every fit with standard errors reports ci_lower / ci_upper (keyed like coefficients), conf_level and, for a t interval, df: OLS t on the residual df (N* − p − 1 on a weighted fit), GLM Wald normal (R’s confint.default) for binomial / poisson / negative binomial and t on the residual df for gamma, Bayes the posterior t on 2·a_n, and any fit under resample normal on the resampled standard errors. An interval exists exactly where a standard error does; an undefined bound is null. A t interval on df differs from a pasted ±1.96·SE in about the third digit on small samples.

Modifier compatibility: Resample and Selection are rejected for REG_BAYES_LINEAR at spec validation, by predict and the runtime alike (internal/regbayes) — the posterior already conveys uncertainty via credible intervals, and stepwise feature selection on a Bayesian model is a posterior-based question the conjugate-NIG engine doesn’t support.

Setting penalty / alpha / l1_ratio / unpenalized / family / link on a Bayes spec is rejected with PROCESSING_CONFIG.

Error codes: PROCESSING_REGRESSION_RANK_DEFICIENT, PROCESSING_REGRESSION_INSUFFICIENT_DATA, PROCESSING_CONFIG.

REG_MULTINOMIAL

Multinomial logistic regression (the baseline-category logit; R nnet::multinom, Stata mlogit, SPSS NOMREG) of a categorical target on numeric predictors. With L fitted levels and the reference r, each other level k has its own coefficients β_k: log(π_k / π_r) = xᵀβ_k.

ParamRequiredNotes
targetyesA categorical cohort field (categorical_u8/u16/u32): its dictionary labels are the categories, in dictionary order. A numeric field is PULSE_FIELD_TYPE_UNSUPPORTED; a derived column carries no dictionary and is PROCESSING_CONFIG (requires: categorical_target).
predictorsyesOne or more numeric predictor fields.
referencenoThe baseline category, one of the target’s labels; default the first level, in dictionary order, that a fitted row carries (multinom’s first factor level). A label outside the dictionary is PROCESSING_CONFIG (requires: a level of the target), at predict and run; beside a penalty it is PROCESSING_CONFIG (requires: unpenalized — the penalised fit is symmetric).
penalty / alpha / l1_ratio / unpenalizednoglmnet’s symmetric penalised multinomial — below.
max_itersnoNewton-Raphson cap, default 50.
tolnoRelative step tolerance, default 1e-8. Convergence is quadratic, so the returned β is the MLE to double precision (nnet’s BFGS stops some 1e-8 short).
conf_levelnoWald normal intervals.
vcovnoThe inverse information I⁻¹ at β̂ (multinom’s solve(Hessian)) and its correlation; the robust sandwich under covariance.
covariancenoA robust coefficient covariance: hc0, hc1 or cluster — below.
exponentiatenotrue adds exponentiated: the relative-risk ratios — below.
marginsno{type, terms, scale}: per-category marginal effects — below.
term_testsnotrue adds term_tests: the joint Wald and LR test of each predictor across the categories — below.
weightnoFrequency (the rep() expansion’s fit) or probability (prior weights w* = w·n_eff/Σw, REG_GLM’s rule; no two_log_lik / aic). A bootstrap or a selection refuses any weight (PULSE_WEIGHT_UNSUPPORTED); a weighted jackknife runs (JK1).
resample / selectionnoThe engine’s modifiers (and their knobs bootstrap_iters, jackknife_groups, jackknife_by, rng_seed, criterion) — below.
multiplicitynoDefault family: every non-intercept coefficient of every non-reference level; coefficients lists <level>:<term> keys (each counted, as an extension model’s list is). Predict counts (levels − 1) × predictors on the dictionary basis.

Result. reference, categories (the fitted levels in dictionary order, the reference among them), and coefficients / std_errors / p_values (Wald z) / ci_lower / ci_upper keyed "<level>:<term>" per non-reference level, category-major — nnet’s vcov row names, the intercept "<level>:(intercept)"; deviance (−2ℓ), null_deviance (the intercept-only model’s, every row at the category shares), pseudo_r2 (McFadden), two_log_lik and aic (−2ℓ + 2·K·(p + 1), multinom’s), n_obs, converged_iters. e^β is a relative risk ratio.

Fit. Newton-Raphson on the full multinomial likelihood from the intercept-only MLE, halving a step that lowers ℓ; I = Σw*·(diag(π) − ππᵀ) ⊗ xxᵀ. Every product is barriered and every transcendental is detmath’s, so the fit is bit-identical on every GOARCH and across DecodeWorkers / ShardWorkers (buffered rows in record order).

Data-dependent refusals (the slot fails alone): fewer than two fitted levels or a named reference no fitted row carries (PROCESSING_REGRESSION_INSUFFICIENT_DATA, reason: one_category / reference_empty); a collinear design (PROCESSING_REGRESSION_RANK_DEFICIENT); separation — fitted probabilities numerically 1 while coefficients keep growing (PROCESSING_REGRESSION_SEPARATION, details.coefficients); PROCESSING_REGRESSION_NO_CONVERGE. A dictionary level no fitted row carries is dropped with its coefficients, as multinom drops an empty group.

Resample and selection. resample (jackknife — leave-one-out, jackknife_groups, jackknife_by — or bootstrap) and selection (forward / backward / stepwise, criterion aic / bic) refit the baseline-category logit through the engine’s drivers. Every refit — each replicate and each selection candidate — keeps the categories and the reference of the slot’s first fit (the full fit; under selection, the search’s first candidate), so every replicate reports the same "<level>:<term>" keys; a refit’s rows at a category outside that set are not fitted. A bootstrap replicate whose draw carries no row of one of the categories is skipped (bootstrap_requested − bootstrap_succeeded counts it); a jackknife replicate that loses one — the leave-one-out deletion of a category’s only row, or a deleted group holding all its rows — fails the slot alone (PROCESSING_REGRESSION_INSUFFICIENT_DATA, reason: replicate_empty_level, details.level; Strict fails the request), since the jackknife variance needs every replicate; a selection candidate that loses one is dropped. Selection is term-level: a predictor enters or leaves across all K − 1 non-reference categories at once, and AIC / BIC are deviance + k·(K − 1)·(terms + 1) (stepAIC’s extractAIC on multinom). Resampled p-values are the Wald z on the replicate SE (jackknife) or the percentile p (bootstrap); intervals are Wald normal on the replicate SE, vcov the replicate covariance. Oracle: R’s manual-deletion jackknife on multinom (leave-one-out and delete-a-cluster) and MASS::stepAIC on multinom at k = 2 and log(n) (TestMultinomial_JackknifeMatchesR, TestMultinomial_SelectionMatchesStepAIC, at 1e-8); the bootstrap (Pulse’s own seeded draws) is pinned seed-stable and worker-invariant.

Penalty. penalty l2 / l1 / elasticnet fits glmnet’s symmetric multinomial (family = "multinomial", type.multinomial = "ungrouped", standardize = FALSE): EVERY category k gets its own β_k (no reference; reference is refused beside it), and the fit minimises −ℓ/N* + alpha·Σ_j pf_j·[(1 − l1_ratio)/2·Σ_k β_kj² + l1_ratio·Σ_k |β_kj|], N* = Σw*, the intercepts unpenalised, pf_j = 0 for an unpenalized predictor (any kind; glmnet’s penalty.factor 0, without its rescaling) and 1 otherwise. ℓ is unchanged when one constant is added to every category’s coefficient on a term, so an unpenalised term (the intercept, an unpenalized predictor) is reported centred to mean zero over the categories, and under l1 a penalised term’s median interval is centred on zero (glmnet’s centring; a no-op for an odd category count). The result carries categories and no reference, coefficients keyed "<level>:<term>" for every level (category-major), the penalty echo, and deviance / null_deviance / pseudo_r2 — the unpenalised figures at the penalised estimate; no two_log_lik / aic. Inference has no analytical form on any kind (the intercepts are identified only by the centring): std_errors, p_values and intervals are null on every key with PULSE_ADVISORY_PENALIZED_INFERENCE_UNDEFINED, and vcov is PROCESSING_REGRESSION_VCOV_UNSUPPORTED, unless resample replaces them with the replicate figures (every replicate refits the symmetric form; predict then counts levels × predictors p-values). A penalised selection runs (k = K·(terms + 1)) and predict warns PROCESSING_REGRESSION_REGULARIZED_SELECTION, as for REG_OLS / REG_GLM. ATTR_REG_PREDICT scores the probabilities the same way; scale: link gives the category’s own xᵀβ_k (glmnet’s type = "link"), and a saved file carries every category’s coefficients and no reference. The fit is proximal Newton on the penalised quadratic model (closed form for l2, coordinate descent with an exact active-set finish otherwise), FMA-free. Oracle: R 4.6.1 glmnet 5.1, Newton-polished on the active set and KKT-checked against the stated objective (scripts/reference/gen_multinomial_penalty.R, multinomial_penalty.json, TestReferenceOracle_MultinomialPenaltyMatchesGlmnet) at 1e-10 — ridge, lasso and elastic net on three categories, unpenalized on each kind, a frequency-weighted elastic net, ridge and elastic net on four; measured within 7e-13 (coefficients 3.5e-13, grid probabilities 2.3e-15, linear predictors 6.2e-13).

Robust covariance. covariance hc0 / hc1 / cluster replaces I⁻¹ behind std_errors, the Wald z p_values, the intervals and vcov (√diag = std_errors) with the score sandwich V = B·M·B: B = I⁻¹ and a row’s unit score s_i = (y_ik − π_ik) ⊗ x_i over the K − 1 non-reference blocks (the coefficient keys’ order). hc0: M = Σ w*·s·sᵀ; hc1 scales by N*/(N* − d), d = K·(p + 1); cluster (CR1): M = Σ_g S_g·S_gᵀ, S_g = Σ_{i∈g} w*·s_i, scaled G/(G − 1)·(N* − 1)/(N* − d) — fewer than two clusters fail the slot alone (PROCESSING_REGRESSION_VCOV_UNSUPPORTED, reason: clusters), a null cluster drops the row. Weights follow the one rule (the frequency sandwich on w*, so a probability weight gets the design-based meat on w* = w·n_eff/Σw). Inference stays Wald z, cluster included; the result echoes covariance ({type, cluster, clusters}). hc2 / hc3 (a per-row leverage the block hat matrix has no scalar form of) and hac (a series order) are PROCESSING_REGRESSION_VCOV_UNSUPPORTED (reason: type, details.supported), and a robust type beside penalty (whose fit has no analytical covariance), resample (the replicates already replace the standard errors) or selection is the same code (reason naming it), as on REG_OLS / REG_GLM — one rule at predict and run (internal/regcov). Oracle: the closed-form sandwich in R at the polished MLE (sandwich has no multinom method; gen_multinomial.R, TestReferenceOracle_MultinomialRobustMatchesR) at 1e-10 — every case, unweighted, frequency- and probability-weighted.

Exponentiated coefficients. exponentiate: true adds exponentiated {estimates, std_errors, ci_lower, ci_upper} BESIDE the raw table, which never moves: per "<level>:<term>" key the relative-risk ratio exp(β) (Stata mlogit, rrr), its delta-method standard error exp(β)·SE and the exponentiated interval exp(lower), exp(upper) — asymmetric about exp(β). The figures read whatever the fit reports: the classical, the robust (covariance) or the resampled standard errors and their intervals; a penalised fit’s null SE and bounds stay null beside exp(β). Any type other than REG_MULTINOMIAL and REG_ORDINAL refuses it (PROCESSING_CONFIG, details.slot: exponentiate, details.requires: type REG_MULTINOMIAL or REG_ORDINAL; one rule at predict and run, internal/regexponent). A saved model file never carries it. Oracle: exp(coef(multinom)) and the delta method in gen_multinomial.R, classical and under each robust type (TestReferenceOracle_MultinomialExponentiatedMatchesR) at 1e-10.

Marginal effects. margins reports, per fitted category k and term j, the effect on that category’s probability: ∂π_k/∂x_j = π_k·(β_kj − Σ_m π_m·β_mj), β of the reference 0, averaged over the fitted rows with their prior weights (ame) or at the weighted means (mem, echoed as at); a term’s effects sum to 0 over the categories, and an effect’s sign can differ from its coefficient’s (which compares the category with the reference only). scale: link is each non-reference category’s log-odds against the reference, η_k = xᵀβ_k: the effect is the coefficient, with its standard error, p-value and interval bit for bit. The block adds outcomes (every fitted category on the response scale, the non-reference ones on the link, dictionary order) and keys every map "<category>:<term>"; standard errors are delta-method on the fit’s own covariance (the inverse information, or the hc0 / hc1 / cluster sandwich), statistics Wald z. A multiplicity block corrects every category × term effect as one family; predict counts them on the dictionary basis. The shared rules apply as on REG_GLM — a penalty (unpenalized: the symmetric fit has no delta-method distribution, so neither scale is defined), selection (no_selection) and a dependent predictor (independent_predictors) are refused at predict and run (internal/regmargins); under resample every replicate re-estimates the effects (see Marginal effects above). Oracle: the closed forms at the polished multinom MLE (the gradient checked against a central difference) at 1e-9 and marginaleffects 1.0.0 avg_slopes / slopes(type = "probs") on multinom set to that MLE at 1e-7 — classical, hc1 and cluster, a named reference over four categories, frequency weights against the rep() expansion, probability weights (gen_margins.R’s multinomial_cases; TestMultinomialMarginsOracle_*).

Term tests. term_tests: true adds term_tests {terms, df, wald_chi2, wald_p_values, lr_chi2, lr_p_values}, keyed by predictor: the joint test that a predictor’s coefficients are zero in every non-reference category at once, on df = K − 1 — the Wald χ² bᵀ·V⁻¹·b over its K − 1 coefficients on the fit’s covariance (classical or robust), and the likelihood-ratio χ² against the refit without the predictor on the same rows, weights, categories and reference (car::Anova(multinom), type II; Stata test), with upper-tail χ² p-values. The LR never reads a robust covariance, and is absent under a probability weight (a pseudo-likelihood). No multiplicity family reads these p-values; predict counts them as uncorrected. Refused beside a penalty, selection or resample (PROCESSING_CONFIG, details.slot: term_tests) and on any other type (requires: type REG_MULTINOMIAL; an extension model’s shared-slot table refuses it too). Oracle: car::linearHypothesis (Wald, classical) and the closed form on every robust sandwich, car::Anova(multinom) (LR, at 1e-6 against its BFGS refits) and the polished refits in gen_multinomial.R (TestReferenceOracle_MultinomialTermTestsMatchR) at 1e-10, car 3.1-5.

Nested-model comparison. Two multinomial fits compare in a Compose compare entry (above): the terms are the predictors, each tested on its K − 1 "<level>:<term>" coefficients, so df = (K − 1)·(added predictors) on both tests. Both fits need the same reference (or none on both: reference_differs); category sets that differ once fitted fail the comparison alone (PULSE_COMPARISON_ROWS_DIFFER reason: terms_differ). lrt, the default, is anova(multinom0, multinom1) (nnet’s anova.multinom): the deviance change D₀ − D₁ on χ²(df), dispersion 1, each fit’s residual df (K − 1)·N* − K·(p + 1) — anova’s Resid. df, N* the rep() expansion’s Σw under a frequency weight; wald is b_Sᵀ V_SS⁻¹ b_S over every key of the added predictors on the full fit’s classical or robust (hc0 / hc1 / cluster) covariance, χ²(df) — a one-predictor comparison equals that predictor’s term_tests Wald and LR. f is refused (estimated_dispersion), a penalty (unpenalized); under resample the likelihood ratio reads the base fit and wald reads the replicate covariance of every tested key, χ²(df). Oracle: gen_nested.R’s multinomial_cases (TestReferenceOracle_NestedMultinomialMatchesR, 1e-10).

Not offered (PROCESSING_CONFIG, details.slot + details.requires, identical at predict and run — internal/regmultinom): family / link / theta / dispersion (no_family), bounds (unbounded), a prior (no_prior), solver (no_solver), intercept: false (intercept), collinearity (no_collinearity); term_tests beside a penalty (unpenalized), selection (no_selection) or resample (no_resample). A holdout scores each held-out row’s category probabilities: log_loss, brier and accuracy (no rmse / mae / r2; skill regression-row-scores). reference or term_tests on any other regression is PROCESSING_CONFIG (requires: type REG_MULTINOMIAL).

Scoring, saving, loading. A multinomial fit binds under a Compose fits entry, save writes its model file (feature categories: the fitted categories and the reference beside the "<level>:<term>" coefficients) and models loads it. ATTR_REG_PREDICT scores one column per slot from the row’s category probabilities π_k = exp(xᵀβ_k) / Σ_l exp(xᵀβ_l) — the fit’s own kernel, so a training row scores its fitted probabilities bit for bit: params.category gives P(y = category) (the default output; outcome_required without it), params.output: class the most probable category’s 0-based index in categories (dictionary order; a dictionary level no fitted row carried is not counted), params.scale: link the category’s log-odds against the reference (xᵀβ_k, 0 for the reference). for_each over the categories gives a column each. An unknown category is outcome_unknown — predict judges it once a loaded model file names the categories; over a fits entry the data decide them and the run does. terms and a lower / upper bound do not apply (terms_unsupported, bound_unsupported); a fitted / residual / leverage / influence params.fit slot cannot bind a multinomial fit (type_unsupported). coef() reads "<level>:<term>"; a bare predictor or (intercept) is PULSE_MODEL_TERM_UNKNOWN.

Oracle: R 4.6.1 nnet 7.3-21 multinom, Newton-polished to the MLE (scripts/reference/gen_multinomial.R, multinomial.json, TestReferenceOracle_MultinomialMatchesR) at 1e-10 — three levels at 0.95 and 0.90, four levels in a non-alphabetical dictionary order with a named reference, frequency weights against the rep() expansion, probability weights on w*, an empty dictionary level; measured within 1e-13 (coefficients 1.5e-15, SEs 6.7e-16, vcov 2.9e-14, p-values 7.3e-15, intervals 9.7e-14, deviances 1.3e-15, AIC 1.2e-16, fitted probabilities 1.8e-15). The same script pins the row scores: every training row’s probabilities (fitted(multinom)) and a grid of new rows’ (predict(multinom, type = "probs")) with their log-odds, read through the bound fit’s production scorer at 1e-10 under every weighting (measured within 1e-14). The weighted reference harness pins it under both kinds (internal/service/testdata/weight_reference).

REG_ORDINAL

Ordinal regression of an ordered response, MASS polr’s proportional-odds (cumulative link) model: P(Y ≤ k | x) = F(ζ_k − xᵀβ), k = 1..K−1, one coefficient per predictor shifting every threshold alike. Authored on the extension contract (a model regression, internal/regordinal): its own knobs ride params.

ParamRequiredNotes
targetyesThe ordered response: a categorical (its labels) or a numeric field (its values, formatted as R’s as.character: "3", "2.5"). 3 to 100 levels on the fitted rows (polr’s floor; a continuous target is no ordinal scale).
predictorsyesNumeric predictors. No intercept: the thresholds carry it.
params.linknologit (default; polr "logistic", proportional odds), probit, cloglog (1 − exp(−exp(q)), proportional hazards).
params.levelsnoThe level order, lowest first, each once (3 to 100). A fitted row whose response it does not list is dropped, as R’s factor(y, levels =) makes it NA and polr drops it; a listed level no fitted row carries fails the slot (INSUFFICIENT_DATA, reason: empty_level). Absent: a categorical’s dictionary order (the import order — pass levels for a scale imported out of order), a numeric target’s ascending values, over the levels the fitted rows carry.
params.brantno{}: adds outputs.brant, the Brant test of the proportional-odds assumption. Logit only (PROCESSING_CONFIG, details.requires: link logit).
params.nominal_testno{}: adds outputs.nominal_test, the likelihood-ratio test of the proportional-odds assumption against the partial proportional-odds fit (ordinal::nominal_test). Any link — below.
conf_level, vcov, multiplicity, weightnoAs the built-ins.
exponentiatenotrue adds exponentiated: the predictors’ cumulative odds ratios — below.
covariancenohc0 / hc1 (the score sandwich H⁻¹·Σw*·s·sᵀ·H⁻¹, hc1 scaled N*/(N* − q)) or cluster (CR1, G/(G − 1)·(N* − 1)/(N* − q)), q = p + K − 1 — sandwich::sandwich / vcovCL on polr. hc2 / hc3 (no row-wise hat matrix for a cumulative link) and hac are refused.
  • Result. coefficients are the predictors (spec order) then the thresholds "<level>|<next level>" (polr’s zeta names). std_errors from the inverse observed (analytic) information, or the sandwich; statistics z; p_values two-sided normal on the predictors only — a threshold’s ζ = 0 is no hypothesis, its p-value is null (so a multiplicity block corrects the predictors); Wald ci_lower / ci_upper at conf_level. deviance = −2ℓ (polr’s), null_deviance the thresholds-only fit’s (each row at the weighted level shares), pseudo_r2 McFadden’s, two_log_lik / aic (q parameters; R’s logLik / AIC on polr), converged_iters. outputs: link, levels (the fitted order), thresholds (the threshold names), fitted_probabilities (the weighted mean over the fitted rows of P(Y = level | x), R colMeans(fitted(polr))) and, with params.brant / params.nominal_test, brant / nominal_test.
  • Exponentiated coefficients. exponentiate: true adds exponentiated {estimates, std_errors, ci_lower, ci_upper} beside the raw table on the PREDICTORS only — the cumulative odds ratios exp(β) under logit (polr’s exp(coef); under cloglog a hazard ratio, under probit no ratio reading), the delta-method SE exp(β)·SE and exp of each interval bound — on the fit’s covariance (classical, robust or resampled). The thresholds are cut points, not effects, and carry no key. Oracle: exp(coef(polr)) and the delta method in gen_ordinal.R, every case including hc0 / hc1 / cluster (TestRegOrdinal_ExponentiatedMatchesR) at 1e-10.
  • Brant test. The K − 1 binary logits of 1{y > m} (prior weights w*) fitted to their fixed point; their slopes’ covariance Var(β*_m) = (X̃ᵀW_mX̃)⁻¹, Cov(β*_m, β*_l) = (X̃ᵀW_mX̃)⁻¹(X̃ᵀW_mlX̃)(X̃ᵀW_lX̃)⁻¹ (intercept rows dropped, W_ml = w*·π_l(1 − π_m), m < l) and its transpose at (l, m); the Wald χ² of β*_1 = β*_m for every m — {statistic, df, p_value} omnibus on (K − 2)·p df and terms per predictor on K − 2. A binary split a predictor separates leaves the figures null; the fit stands. The brant 0.3.0 package stores the (m, l) block untransposed at (l, m), so its omnibus statistic differs from this symmetric (covariance) one — its per-predictor statistics agree; the oracle script reproduces the package’s figure exactly.
  • Nominal test. The partial proportional-odds model frees a predictor’s slope at every cumulative split, P(Y ≤ k | x) = F(ζ_k − Σ_j x_j β_{j,k}) (clm(nominal = ~ term)), fitted by Newton–Raphson on its analytic gradient and information from the proportional-odds MLE, on the slot’s link. terms per predictor: LR = 2(ℓ_partial − ℓ) with that predictor freed, on K − 2 df (ordinal::nominal_test); the omnibus frees every predictor, (K − 2)·p df. A partial fit that does not converge (a predictor separating one split sends its slope to infinity) or whose fitted cumulative probabilities cross at a fitted row (η_k ≥ η_{k+1}) leaves that figure null with a PROCESSING_REGRESSION_DIAGNOSTIC warning (details.reason nominal_test_no_converge / nominal_test_crossing, details.scope term (+ term) or omnibus) — the fit stands; ordinal::nominal_test still prints a number there. Under a probability weight outputs.nominal_test is absent (no likelihood, as two_log_lik and the multinomial term_tests LR; never refused, no warning) and predict counts none of its p-values (with the knob in force, predict’s p_values count predictors + 1 for it, uncorrected — as for params.brant). Resample replicates fit without the Brant and nominal tests (their outputs are discarded): a resampled result carries the full fit’s; selection candidates keep them, so the chosen model reports its own.
  • Weights (REG_GLM’s rule): prior weights w* in the likelihood — frequency w* = w, the fit equal to the rep()-expanded one (Brant and nominal tests included); probability w* = w·n_eff/Σw (Kish), the frequency formulas on w*, two_log_lik / aic and nominal_test absent.
  • Scoring, save, models. A bound fit (a Compose fits entry, or a saved model file loaded through models) scores per row through ATTR_REG_PREDICT, one column per slot from the row’s level probabilities P(Y = k | x) = F(ζ_k − xᵀβ) − F(ζ_{k−1} − xᵀβ) (R predict(polr, type = "probs")): params.output expected (the default, Σ k·P_k over the levels numbered 1..K in fitted order), class (the most probable level’s number), probability (P(Y = level), the default once params.level names one) or cumulative (P(Y ≤ level)) — both need params.level, the level as written; an item for_each over the levels gives one column each. params.scale: link scores xᵀβ. The model file keeps outputs.link / levels beside the coefficients, so a reloaded fit scores bit-identically. Refused alike at predict and run (PULSE_MODEL_SCORE_INVALID, details.reason): level / output on any other fit and category on every fit (outcome_unsupported), an unknown level (outcome_unknown; predict judges it when params.levels pins the levels or a model file names them, else the run), a missing level (outcome_required), a level beside expected / class (outcome_unused), output or level beside scale: link (output_scale).
  • Resample and selection. resample (jackknife, jackknife_groups / jackknife_by, bootstrap) and selection (forward / backward / stepwise, criterion aic / bic) refit the model through the engine’s drivers. Every refit — each replicate and each selection candidate — keeps the levels of the slot’s first fit (the full fit; under selection, the search’s first candidate) as if params.levels named them, so every replicate reports the same thresholds. A bootstrap replicate whose draw carries no row at one of them is skipped (bootstrap_requested − bootstrap_succeeded counts it); a jackknife replicate that loses one — the leave-one-out deletion of a level’s only row, or a deleted group holding all of a level’s rows — fails the slot alone (INSUFFICIENT_DATA, reason: replicate_empty_level, details.level; Strict fails the request), since the jackknife variance needs every replicate; a selection candidate that loses one is dropped. The thresholds keep no p-value under resample. AIC / BIC are −2ℓ + k·edf with edf = predictors + thresholds (stepAIC’s extractAIC on polr). Oracle: R’s manual-deletion jackknife on polr and MASS::stepAIC (TestRegOrdinal_JackknifeMatchesR, TestRegOrdinal_SelectionMatchesStepAIC, at 1e-8).
  • Marginal effects. margins reports, per level and term, the effect on that level’s probability: dP_k/dx_j = −β_j·[f(ζ_k − η) − f(ζ_{k−1} − η)] (f the link’s density), averaged over the fitted rows with their prior weights (ame) or at the weighted means (mem, echoed as at); a term’s effects sum to 0 over the levels. scale: link is the effect on each cumulative link g(P(Y ≤ k)) = ζ_k − η: −β_j for every level but the last, with the coefficient’s SE. The block adds outcomes (the levels, in order) and keys every map "<level>:<term>"; standard errors are delta-method on the fit’s coefficient-and-threshold covariance (classical, hc0, hc1, cluster), statistics Wald z. A multiplicity block corrects every level × term effect as one family; predict counts one per term (lower_bound). The shared rules apply as on REG_GLM — selection (no_selection), a dependent predictor (independent_predictors) are refused at predict and run; under resample every replicate re-estimates the effects. Oracle: the closed forms at the polished polr MLE at 1e-9 and marginaleffects 1.0.0 on polr at 1e-7 (gen_margins.R’s ordinal_cases; TestOrdinalMarginsOracle_*, TestRegOrdinal_MarginsMatchREndToEnd).
  • Refused (identical at predict and run; the shared-slot table’s PROCESSING_CONFIG {regression, slot}): penalty, collinearity (requires: type REG_OLS or REG_GLM), the top-level link / family / theta / dispersion / max_iters / tol / prior / intercept / solver / bounds / unpenalized.
  • Nested-model comparison. Two ordinal fits compare in a Compose compare entry (above): the terms are the predictors (the thresholds are never tested, but both fits must carry the same ones — equal params.levels, or none on both: levels_differ; thresholds that still differ once fitted fail the comparison alone, PULSE_COMPARISON_ROWS_DIFFER reason: terms_differ). lrt, the default, is anova.polr: the deviance change D₀ − D₁ on χ² with the added predictors as df (dispersion 1; residual df Σw − (p + K − 1)); wald is b_Sᵀ V_SS⁻¹ b_S on χ² over the full fit’s classical or robust covariance; f is refused (requires: estimated_dispersion). Oracle: gen_nested.R’s ordinal_cases (anova.polr; the Wald on the polished information and hc1 sandwich, cross-checked on vcov(polr) / sandwich(polr)), TestReferenceOracle_NestedOrdinalMatchesR at 1e-10.
  • Holdout. A holdout scores each held-out row’s level probabilities, weighted means over the scored rows: log_loss −ln P(observed) (natural log), brier Σ_k (P_k − [y = k])², accuracy (the most probable level, first on a tie, is the observed one) and rps Σ_{k<K} (P(Y ≤ k) − [y ≤ k])²/(K − 1); no rmse / mae / r2. A held-out level the fit does not carry is not scored. Oracle: the closed forms over predict(polr, type = "probs") (TestRegOrdinal_HoldoutMatchesR).
  • Fails alone (PULSE_SLOT_FAILED): fewer than 3 or more than 100 levels, an empty listed level, no more rows (N*) than parameters (INSUFFICIENT_DATA, details.reason), a singular information (RANK_DEFICIENT), no convergence — a predictor that separates the levels (NO_CONVERGE). One cluster is the built-ins’ fatal PROCESSING_REGRESSION_VCOV_UNSUPPORTED (reason: clusters).

Oracle: R 4.6.1 + MASS 7.3-66 polr polished by Newton to its MLE on the analytic gradient and information (polr’s BFGS stops ~1e-6 off it and differentiates its Hessian numerically), sandwich 3.1-3, brant 0.3.0, ordinal 2026.7-26 (nominal_test / clm, the partial fits polished to their MLE; relative with a floor of 1), at 1e-10 (measured within 2e-12; scripts/reference/gen_ordinal.R, ordinal.json, internal/regordinal TestOrdinalOracle_Design and TestRegOrdinal_MatchesPolrEndToEnd; the row scores against predict(polr, type = "probs") in TestOrdinalOracle_RowScores and TestRegOrdinal_ScoresMatchPolrEndToEnd); the weighted-reference harness pins frequency and probability fits at 1e-12 (TestWeightReferenceValues). Example internal/examples/regression/22_ordinal.json; skill op-reg-ordinal.

Modifiers

Resample

Layered on top of any base operator except REG_BAYES_LINEAR and REG_MMM_BAYES.

ValueBehavior
""No resampling. Closed-form / asymptotic standard errors.
"jackknife"Leave-one-out resampling, SE = sqrt((n−1)/n · Σᵢ (β⁽⁻ⁱ⁾ − β̄)²); or delete-a-group with jackknife_groups: g (fitted rows split into g seeded random groups, rng_seed) or jackknife_by: field (one group per distinct value; a null value drops the row): SE = sqrt((g−1)/g · Σₖ (β₍ₖ₎ − β̄)²), echoed jackknife_groups. The two knobs are exclusive. Weighted (JK1): each replicate refits the remaining rows with their own weights. Every replicate must refit — the first failure fails the slot with its code (details.jackknife_group). Predict’s PULSE_ADVISORY_JACKKNIFE_COST flags leave-one-out at ≥ 10,000 records (Process predict, and each Compose slot and fit). Leave-one-out deletes each FITTED row: a row the fit drops (null target or predictor, zero weight) is no replicate and no part of n.
"bootstrap"Non-parametric bootstrap. bootstrap_iters (default 1000), rng_seed (0 → a seed derived from the request and the rows the fit reads, so the same request over the same cohort is reproducible — vcov and margins never move it; non-zero → reproducible across cohorts too).

An l1 / elasticnet fit reports null standard errors, p-values and intervals (advisory PULSE_ADVISORY_PENALIZED_INFERENCE_UNDEFINED); setting Resample replaces them with replicate ones and silences the advisory.

Selection

Layered on top of any base operator except REG_BAYES_LINEAR and the MMM models.

ValueBehavior
""No subset selection.
"forward"Start from intercept-only; add the predictor that lowers the criterion most.
"backward"Start from full model; remove the predictor whose absence lowers the criterion most.
"stepwise"Bidirectional sweep; try every add and every remove per cycle.

Requires Criterion ∈ {"aic", "bic"}.

  • AIC = -2·logL + 2·k. Lighter penalty; may retain weak predictors at moderate n.
  • BIC = -2·logL + log(n)·k. Heavier per-parameter penalty; rejects noise predictors more reliably at moderate n.

SelectedFeatures lists the chosen subset; Coefficients drops non-selected predictors entirely (absence ≠ zero — selection’s contract is stronger). Selection may be combined with Resample: Selection picks the active subset, then Resample replaces SE / p-values on the selected model.

Compositional patterns

Polynomial regression — FEAT_POLY + REG_OLS

Polynomial regression is linear in the coefficients; the non-linearity lives in the feature space. Use FEAT_POLY upstream to materialize <label>_2, <label>_3, …, <label>_<degree> derived columns, then list them alongside the original field in predictors:

{
  "cohort": {"filename": "mmm_weekly.pulse"},
  "features": [
    {"type": "FEAT_POLY", "field": "tv", "label": "tv", "params": {"degree": 3}}
  ],
  "regressions": [
    {"type": "REG_OLS", "name": "polyfit", "target": "sales",
     "predictors": ["tv", "tv_2", "tv_3"]}
  ]
}

Degree is gated at [2, 10]. Numerical stability is the caller’s responsibility: x^10 overflows f64 once |x| clears a few hundred, and the Gram matrix conditions poorly long before that. Centre or standardize predictors before requesting FEAT_POLY.

Ecological regression — group → regress

“Ecological regression” is a regression fit on aggregated group-level statistics — per-precinct means, per-county sums, per-region rates — rather than individual-level rows. Use pulse_compose with two slots: slot 1 produces per-group means via GROUP_* + AGG_AVERAGE, slot 2 fits REG_OLS over the aggregate output (or, in practice, over a pre-aggregated .pulse file).

The two slots are intentionally independent; Pulse does not pipe slot-1 results into slot-2 as cohort input. Either (a) materialize slot 1’s aggregate as its own .pulse cohort upstream, or (b) treat slot 1 as the audit trail (per-group means visible in the composed response) and run slot 2 over a pre-aggregated fixture.

Caution — the ecological fallacy. A significant group-level slope does not imply an individual-level association. Robinson (1950) showed that ecological correlations and individual correlations can take opposite signs in the same data: a per-state regression of literacy on race might suggest a strong relationship that vanishes (or reverses) at the per-person level. Aggregation collapses within-group variation, leaving only between-group structure that frequently encodes confounders.

When ecological regression is the right tool: aggregate-only data (census output, public-health summary tables); genuinely group-level research questions (“do counties with higher median income have higher turnout?”). When it is the wrong tool: individual-level claims; causal claims. Annotate consumer-facing prose with this caveat; Pulse cannot enforce it.

Robinson, W.S. (1950). “Ecological Correlations and the Behavior of Individuals.” American Sociological Review 15(3): 351–357.

Per-row regression attributes

Four attribute operators emit per-record diagnostics from a fitted regression onto the row stream; ATTR_REG_PREDICT scores a bound fit (skill op-attr-reg-predict).

AttributeEmits per row
ATTR_REG_FITTEDŷ_i = Xᵢ β — the model’s prediction at each row.
ATTR_REG_RESIDUALy_i − ŷ_i — the per-row residual; params.kind standardized / studentized on the refit (R rstandard / rstudent).
ATTR_REG_LEVERAGEh_ii = Xᵢ (XᵀX)⁻¹ Xᵢᵀ — the i-th diagonal of the hat matrix.
ATTR_REG_INFLUENCECook’s distance (params.measure cooks, the default) or DFFITS (dffits), R cooks.distance / dffits.

Studentized residuals and influence

With h the leverage, p′ = p + 1 coefficients, df = n − p′, s² = RSS/df and e = y − ŷ:

FigureFormula
standardized re / (s·√(1 − h))
studentized tr·√((df − 1)/(df − r²))
Cook’s distancer²·h / (p′·(1 − h))
DFFITSt·√(h/(1 − h))

On the refit they read its residual variance, so they take unpenalized OLS only (PROCESSING_CONFIG otherwise). A frequency weight reads each record as w identical observations and reports one copy’s figure (h/w, df = Σw − p′, the weighted RSS: statsmodels OLSInfluence on the rep() expansion); a probability weight is PULSE_WEIGHT_UNSUPPORTED. A row outside the fit, or a figure the fit leaves undefined (df ≤ 1, h ≥ 1), is null.

Penalized leverage. ATTR_REG_LEVERAGE on the refit takes any penalty and reads the hat matrix the penalized fit’s normal equations define, the intercept unpenalized (n = Σw): l2 the exact ridge hat 1/n + (x − μ_x)ᵀ(M2_xx + n·α·I)⁻¹(x − μ_x), so every row shrinks towards 1/n; l1 the hat of the unpenalized OLS on the active set {j : βⱼ ≠ 0}, whose trace 1 + |active| is the lasso’s degrees of freedom (Zou, Hastie & Tibshirani; glmnet’s df), 1/n on every row when nothing is active; elasticnet the active-set hat with the ridge term n·α·(1 − l1_ratio). A frequency weight reads it as on the unpenalized refit. Oracle: R matrix algebra on the uncentred design, diag(W½X_A(X_AᵀWX_A + n·λ₂·P)⁻¹X_AᵀW½), with the active set and its df cross-checked against glmnet 5.1 (scripts/reference/gen_ols_penalty.R, ols_penalty.json, TestReferenceOracle_PenalizedLeverageMatchesClosedForm) at 1e-10 — every penalty, unweighted, frequency-weighted and with unpenalized predictors. Influence and the standardized / studentized kinds still refuse a penalty (they read σ² = RSS/(n − p − 1), which a penalized fit does not define). Over a bound penalized fit the leverage is the same hat: every penalized REG_OLS / REG_GLM fit without resample or selection carries its regularized inverse (X̃ᵀWX̃ + λ₂·P)⁻¹ over (intercept) and the active predictors (λ₂ = N·α under l2, N*·α·(1 − l1_ratio) under elasticnet, 0 under l1; W* the prior weights on the inference basis — as given unweighted or under a frequency weight, rescaled to N* = n_eff under a probability weight, so it is scale-free — times a GLM’s final IRLS working weights) — in memory for a Compose fit’s binding and in a saved model file, never on the wire, so a response is byte-identical to one without it — and ATTR_REG_LEVERAGE with params.fit reads h = w·x̃ᵀMx̃ from it — no vcov needed, so lasso and elastic-net fits qualify — equal to the penalized refit’s hat for one copy of a row (oracle cases above, 1e-12) and, on a GLM, to the closed form at its final working weights. A model file keeps it (feature penalized_inverse); a file an earlier build saved is refused requires: penalized_inverse until re-saved. Over a penalized bound fit the influence measures and the scaled residual kinds are refused requires: unpenalized.

GLM refit leverage. params.family (with params.link, default the family’s canonical link) makes the ATTR_REG_LEVERAGE refit a generalized linear model of that family instead of OLS — the same IRLS engine as REG_GLM, default tolerance — and the leverage is its hat at the final working weights, w*·(dμ/dη)²/V(μ)·x̃ᵀ(XᵀW*X)⁻¹x̃ (R hatvalues(glm)), bit-equal to a bound REG_GLM fit of the same rows with vcov: true. It takes any penalty: the penalized GLM’s hat over its regularized inverse, (XᵀW*X + λ₂·P)⁻¹ on the active design (the OLS refit’s convention), bit-equal to the same penalized fit bound. The family keys are the leverage refit’s alone: a GLM’s fitted value, residual and influence figures go through a bound REG_GLM fit (params.fit), and on an instance whose feature profile hides REG_GLM the two keys are refused as unknown (PULSE_REQUEST_UNKNOWN_FIELD). A frequency weight is the rep() expansion’s summed copies; a probability weight gives the frequency figure (the hat ignores the weights’ scale). An unknown family or a foreign link is PROCESSING_REGRESSION_INVALID_FAMILY / _LINK, params.link without params.family is PROCESSING_CONFIG (details.requires family; a penalized negative_binomial refit re-estimates θ), and params.family beside params.fit is PULSE_MODEL_SCORE_INVALID slot_fields — predict and run alike (internal/reglink.CheckRefitFamily). Oracle: R 4.6.1 hatvalues on the binomial-logit, poisson-log and gamma-inverse rows of glm_influence.json (scripts/reference/gen_glm_influence.R, TestGLMRefitLeverage_MatchesR) at 1e-7 (the refit’s default IRLS tolerance; the bound fit at tol: 1e-14 meets it at 1e-9).

Each attribute carries its own target / predictors (plus penalty / alpha / l1_ratio) and refits OLS in its prepass. All four take params.fit instead: they name a bound fit — a compose fits entry or a loaded models entry — and score through it, so a REG_GLM residual is y − μ̂ on the response scale and an extension regression’s fit scores through its registration’s Scorer. The slot is then row-local and its default label is <TYPE>_<fit>. See skills/op-attr-reg-fitted.md, skills/op-attr-reg-residual.md, skills/op-attr-reg-leverage.md and skills/op-attr-reg-influence.md for the parameter tables.

Influence over a bound fit

ATTR_REG_LEVERAGE, ATTR_REG_INFLUENCE and ATTR_REG_RESIDUAL kind standardized / studentized with params.fit read the bound REG_OLS / REG_GLM fit’s design — its vcov, its dispersion and its n_obs — exactly as R 4.6.1’s hatvalues / rstandard / rstudent / cooks.distance / dffits read an lm or glm. With x̃ = [1, x…], μ the fitted mean, w = (dμ/dη)²/V(μ) the working weight (1 under OLS), rP = (y − μ)/√V(μ) the Pearson residual, φ the dispersion (1 for binomial / poisson / negative binomial, whose V(μ) reads the fit’s theta; RegressionResult.dispersion — σ̂² on OLS, the Pearson χ²/df on gamma — where it is estimated), p′ the coefficient count and df = n_obs − p′ (sum_weights − p′ under a frequency weight):

FigureFormula
leverage hw · x̃ᵀ(vcov/φ)x̃
standardizedrP / (√φ·√(1 − h)); with params.residual_type deviance, rD / (√φ·√(1 − h)), rD = sign(y − μ)·√dᵢ the deviance residual (R rstandard(type = "deviance"); equal to the Pearson form on a Gaussian fit)
σ₍ᵢ₎ (φ estimated)√((φ·df − rP²/(1 − h))/(df − 1))
studentizedrP / (σ₍ᵢ₎·√(1 − h)); the standardized under binomial / poisson / negative binomial
Cook’s distance(rP/(1 − h))²·h/(φ·p′)
DFFITSsign(g′(μ))·rP·√h/(σ·(1 − h)), σ = σ₍ᵢ₎ or √φ

residual_type is kind standardized’s alone (pearson default, deviance): the studentized residual, Cook’s distance and DFFITS stay Pearson-based, as in R, and any other kind refuses it (PULSE_MODEL_SCORE_INVALID params_invalid). DFFITS is the change on the linear-predictor scale, so under a decreasing link — gamma’s inverse — it is negative where the residual is positive. Over an OLS fit every formula reduces to the refit’s above. The fit must set vcov: true and be unweighted or frequency-weighted, unpenalized (bar the leverage — above), without selection, resample, bounds or a robust covariance (PULSE_MODEL_SCORE_INVALID reason params_invalid, details.requires naming the missing piece); a REG_BAYES_LINEAR or extension fit is type_unsupported, and so — by design, not as a gap — is REG_MMM_BAYES: classical hat-matrix figures need a point estimate’s (XᵀWX)⁻¹, which a posterior does not have. A frequency-weighted fit reads each record as w identical observations: its vcov already carries the prior weights ((XᵀW*X)⁻¹) and its dispersion the Σw − p′ df, so with df = Σw − p′ every figure is the rep()-expanded unweighted fit’s for ONE copy of a row — a scored row is one observation (the slot reads no weight of its own), so h is R’s hatvalues(glm(weights = f))/f and Σ f·h = p′; compare it with per-observation cut-offs such as 2p′/Σw (oracle: gen_glm_influence.R weighted_cases, R’s figures on the expansion). A probability weight is refused permanently (requires: unweighted), not as a gap: a sampling weight defines no observation to delete, so a model-based influence figure has no meaning under it — declare kind: frequency if the weights are replication counts, else refit with weight: null. A model file keeps the dispersion (feature dispersion) or a negative binomial’s θ (feature theta); a file an earlier build saved carries none and is refused (requires: dispersion) until re-saved.

A nonlinear fit. REG_MMM_HILL is a nonlinear least squares, so the same figures read its tangent plane (the Gauss–Newton linearisation R reads off an nls gradient): x̃ is replaced by g = ∂ŷ/∂θ at the optimum over every free parameter — the betas, each curve’s k and s and, under params.adstock, the kernel’s parameters (a parameter held on a bound has a null variance and joins nothing) — so h = gᵀ(vcov/σ̂²)g, with σ̂² = SSR/df its dispersion (which a HILL fit carries beside vcov: true), p′ the free parameter count and df the fit’s residual df; then the OLS formulas. Over the fit’s own rows the hat values sum to p′ and lie in [0, 1]; with every curve held on its bound the figures are the linear model’s. params.prior is a penalty (requires: unpenalized). Over an in-model adstock the slot carries it as ATTR_REG_FITTED does (carryover / order; carry-over). The R oracle is make reference-mmm-hill-adstock (hat values, rstandard, rstudent, cooks.distance and dffits of lm(e ~ J − 1), J checked against numDeriv::jacobian).

Error codes

Look up full prose via pulse_errors_lookup or pulse errors lookup CODE.

A fit that fails on its data — RANK_DEFICIENT, SEPARATION, NO_CONVERGE, SINGULAR_GRAM, INSUFFICIENT_DATA, ORDER — fails its slot alone: regressions[i] keeps name / type and carries error {code, message, details}, the other slots of the response survive, and a PULSE_SLOT_FAILED warning names it. Under Options.Strict the run fails with the fit’s own code instead. The configuration codes (INVALID_FAMILY, INVALID_LINK, PROCESSING_CONFIG) stay fatal. See Payload JSON Schema (Failed slots).

CodeMeaning (one-liner)
PROCESSING_REGRESSION_RANK_DEFICIENTXᵀX is singular; add regularization or drop a predictor.
PROCESSING_REGRESSION_SEPARATIONBinomial REG_GLM is separated (a predictor splits the outcome); details.predictors.
PROCESSING_REGRESSION_NO_CONVERGEIRLS or coordinate descent failed within max_iters.
PROCESSING_REGRESSION_SINGULAR_GRAMXᵀX non-invertible even after regularization; increase alpha.
PROCESSING_REGRESSION_INVALID_FAMILYREG_GLM Family outside {binomial, poisson, gamma, negative_binomial}.
PROCESSING_REGRESSION_INVALID_LINKLink not one of the chosen Family’s (details.allowed).
PROCESSING_REGRESSION_INSUFFICIENT_DATAFiltered set has fewer rows than predictors + 1, or below resample minimum.
PROCESSING_REGRESSION_ORDERAn ordered slot’s admitted rows repeat a period (duplicate) or skip one (gap); fails the slot alone.
PULSE_ADVISORY_PENALIZED_INFERENCE_UNDEFINEDAdvisory: l1 / elasticnet SEs, p-values and intervals are null (no valid analytical form); set resample for replicate ones.
PULSE_ADVISORY_CONSTRAINT_ACTIVEAdvisory: a REG_OLS bounds constraint binds, so SEs, p-values, intervals and vcov are null; set resample: bootstrap for replicate ones.
PROCESSING_REGRESSION_REGULARIZED_SELECTIONWarning: penalty != "" plus selection != "" is unusual.
PROCESSING_CONFIGInvalid spec combination (e.g. Bayes + Resample, gamma GLM + Penalty, theta off negative_binomial).
PULSE_REGRESSION_INVALIDThe slot’s type resolves to no regression on this instance (unregistered, hidden by the feature profile, or an unregistered extension model).
PULSE_MODEL_STAT_UNKNOWNcoef(fit, term, stat) names a stat other than point, lower, upper or se.
PULSE_MODEL_INTERVALS_UNAVAILABLEcoef() or a scoring bound reads an interval or SE from a bound fit that reports none (a degenerate fit); judged when the fit binds.

Worked examples

Every Indeed name has a runnable JSON file under internal/examples/regression/. Fetch via pulse_examples_get or read directly: