SPB Git

spb/metrika Public

Stata-class statistics, GPU-accelerated by Apple Silicon. Native Swift — no Electron, no Python runtime, no compromises.

Swift 92.4% HTML 3.3% R 3% Shell 1.3%

History of MetrikaKit/Sources/ZQStats/GLM.swift · clear filter

  1. feat(engine): margins dydx() with delta-method standard errors
    - ZQOLSResult/ZQGLMResult expose the full covariance matrix (column-major
      k x k aligned with coefficients); IV passes it through
    - EstimationState carries vce, inference df, and the estimation-sample
      design (GLMs only — AMEs need it)
    - margins, dydx(varlist): OLS/IV effects are the coefficients with their
      SEs; GLM average marginal effects with analytic delta gradients
      (logit p(1-p)(1-2p), probit -xb*phi, poisson exp) over the estimation
      sample; t or z inference per model kind
    - factor/interaction dydx rejected with a clear message (discrete-change
      margins later); continuous terms of factor models work
    - R fixtures mirror the exact formulas at the converged coefficients;
      logit/poisson AME and delta SE match at 1e-10
    - 98 tests green (swift test and xcodebuild with GPU suites)
    
    Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
    simon-pierre boucher committed 6 days ago (Aug 5, 2026) · 1 file changed +8 −2
  2. feat(stats): logit/probit/poisson MLE, tabulate, correlate
    - ZQGLM: Fisher-scoring IRLS through the LAPACK QR path (X'WX never
      formed), converged to |Δll| < 1e-13; classical, robust (HC0 score
      sandwich, Stata ML convention), and cluster (G/(G−1)) VCE; LR/Wald
      chi2, McFadden pseudo-R²; information matrix re-evaluated at the
      converged beta (R's vcov carries last-iteration weights and is only
      ~1e-6-accurate by its own stopping rule — fixtures compute expected
      information at the optimum explicitly)
    - Distributions: regularized incomplete gamma, chi-square CDF/p-value,
      normal quantile
    - ZQCorrelate: Pearson matrix on listwise-complete data
    - Engine: logit/probit/poisson tables (z, P>|z|, LR chi2, pseudo R²),
      one-way and two-way tabulate with totals, Stata-style lower-triangle
      correlate
    - Fixtures: binomial/poisson outcomes drawn after existing draws (earlier
      golden values bit-identical); glm at epsilon 1e-12
    - 56 tests green (12 new)
    
    Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
    simon-pierre boucher committed 6 days ago (Aug 5, 2026) · 1 file changed +445