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%
-
feat(stats): elastic net and lasso via coordinate descent
…
- ZQElasticNet: cyclic coordinate descent with residual updates, glmnet-convention objective ((1/2n)RSS + lambda(alpha*l1 + (1-alpha)/2*l2)), internal predictor standardization (1/n variance), unpenalized intercept, coefficients reported on the original scale; lambdaMax helper - matched glmnet's gaussian y-standardization quirk deliberately: the L1 penalty is invariant to it but the effective ridge penalty scales by 1/sd(y) — without this, alpha<1 fits diverge from glmnet by ~10% - engine: 'elasticnet y x…, lambda(#) [alpha(#)]' and 'lasso' (alpha fixed at 1); missing lambda() errors with the data's lambda_max as a hint; predict works afterwards, margins refuses (no VCE) - fixtures: glmnet 5.0 at thresh 1e-15 over deliberately correlated regressors; coefficients match at 1e-6 (documented tolerance for penalized iterative solvers) and the selection pattern (which coefficients are exactly zero) matches exactly - ZQCoefficient gains a public initializer - 104 tests green (swift test and xcodebuild with GPU suites) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
-
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>
-
feat: bootstrap Metrika v0.1 skeleton with working ZQL vertical slice
…
- MetrikaKit SPM package: ZQParser, ZQPlanner, ZQEngine, ZQData, ZQStats, ZQGPU, ZQGraphics, ZQPlugins (Swift 6, strict concurrency) - ZQL parser: lexer, Pratt expressions, factor variables, prefix commands, column-cited errors with Levenshtein verb suggestions - ZQData: DuckDB-backed load/save (parquet, csv, json, arrow) - ZQStats: OLS via LAPACK QR, HC0-HC3 and cluster-robust SE, summarize, t/F distributions accurate in the far tails - ZQGPU: Philox4x32-10 reference RNG, counter-addressable bootstrap - ZQEngine: session actor with use/save/gen/replace/drop/keep/summarize/ regress/count/list/graph/bootstrap/set seed/xtset/log - SwiftUI app (xcodegen): console with history, variables sidebar, Swift Charts plots; sandboxed + hardened runtime entitlements - Tests: 44 green (parser golden, R fixtures at 1e-10, Philox KAT, end-to-end engine); Tests/Fixtures/generate.R; Tests/Bench harness - scripts: check_headers.sh + pre-commit hook, make_icns.sh, release.sh Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>