Harmonic, client-side additive models with uncertainty bands

cmackle2 pts0 comments

HARMONIC: trend curves, computed on your machine

01Data

Bring a comma-separated file, or start from one of three example datasets. Parsing happens in this tab; the file is never transmitted anywhere.

Drop a CSV file anywhere on this page

or

Choose a file…

Or load an example

02Model

Choose one target column and one to several predictor columns. Loading an example fits it immediately; changing columns requires pressing Fit.

Load data in 01 to configure a model.

Target column

Predictor columns

Fit model

03Curves

One panel per predictor: the fitted effect fj, a ±2 standard-error band, and a rug of the observed values. Hover a curve for its exact reading.

Fit a model in 02 to see component curves.

04Fit

Summary statistics for the selected model, and a residual check.

Fit a model in 02 to see fit statistics.

Residuals vs. fitted values

05Method

HARMONIC fits an additive model, y = f1(x1) + f2(x2) + … + fp(xp), using the closed-form Fourier-basis method described in a 1992 paper on Fourier smoothers and additive models (OpenAlex ID W2024658605). Each predictor is rescaled to the interval zero to one, then represented as a linear term plus a fixed set of cosine waves. Fitting the weights on this fixed basis is a single linear solve, not an iterative search.

How smoothness is chosen

Two settings govern how flexible a curve is allowed to be: K, the number of cosine terms, and λ, a ridge penalty on the higher-frequency terms. HARMONIC does not ask the user to tune either. It fits a fixed grid of candidates (K in four, eight, twelve, and twenty-five log-spaced values of λ), scores each by generalised cross-validation, and keeps the candidate with the lowest score. This is a grid search over closed-form fits, not an iterative optimiser.

Two honest limitations

Boundary bias. A cosine basis has zero slope at both ends of the rescaled interval by construction. Where a true effect has a non-zero slope at the edge of the observed data, the fitted curve can flatten out artificially in the outermost values of a predictor. Read the extreme low and high end of each curve with that in mind.

Weak components. When a predictor's true effect is small relative to noise, its fitted curve carries a wide ±2 standard-error band. A flat curve with a wide band is not evidence of a flat effect; it is evidence that this dataset does not pin the effect down. The band is the honest answer, not the curve alone.

Measured against the incumbents

Smoothing n = 100,000 points in the browser, measured 2026-07-13 (protocol and raw numbers in the repository under bench/):

HARMONICVega-Lite loessPyodide + statsmodels<br>payload19.4 KB272.8 KB36.8 MB<br>cold start63 ms362 ms (warm CDN)58.2 s<br>fit, n=100k1.41 s, auto smoothnessfroze >8 min; 4.60 s at n=10k0.76 s, fixed parameters<br>additive p>1 + bandsyesnonot timed

Read fairly in both directions: once Pyodide has paid its 36.8 MB and 58-second entry price, compiled LOWESS wins the warm fit (0.76 s to 1.41 s, with hand-fixed smoothing where HARMONIC selects its own). HARMONIC's case is the other four rows.

06Export

Download a single self-contained HTML file with the fitted curves, the fit statistics, and the data provenance. It has no external references and opens offline.

Download report<br>Fit a model first.

Drop to load CSV

model curve harmonic predictor file fitted

Related Articles