Error Models¶
The choice of error model determines how residuals (differences between observed and predicted responses) are computed and weighted. This matters because biological assays have characteristic noise patterns.
Gaussian (Additive Noise)¶
Assumes constant additive noise independent of signal level:
Residuals are computed on the original scale: \(r_i = y_i - \hat{y}_i\).
When to use: absorbance or fluorescence measurements where the noise floor is dominated by instrument noise (constant regardless of signal amplitude).
Lognormal (Multiplicative Noise)¶
Assumes noise scales proportionally with the signal (constant coefficient of variation):
Included responses must be positive. Exclude zero or negative wells or switch the error model.
Residuals are computed in log-space: \(r_i = \log y_i - \log \hat{y}_i\).
When to use: most biological assays. In cell viability, luminescence, and similar assays, a 10% error at high signal is much larger in absolute terms than a 10% error at low signal — but both represent the same relative uncertainty.
This is the default because it is the more common noise structure in pharmacological data.
Profiled Variance¶
In constant Gaussian and Lognormal models, the variance \(\sigma^2\) is profiled out (analytically maximized) rather than treated as a free parameter. The MLE variance is:
And the profiled log-likelihood becomes:
This reduces the optimization from \(k+1\) to \(k\) parameters (where \(k\) is the number of Hill equation parameters), improving numerical stability without loss of information.
Variance Shapes¶
For Gaussian fits, synfit can also model variance as a function of the predicted response \(\mu = \hat{y}\), anchored at the lower asymptote \(m = \min(\text{effect}_0, \text{effect}_\infty)\). Let \(d = \mu - m\):
- constant: \(\sigma^2(\mu) = a\) (profiled out)
- poisson-like: \(\sigma^2(\mu) = a + b\,d\)
- proportional: \(\sigma^2(\mu) = a + b\,d + c\,d^2\)
Hill predictions sit between the two asymptotes, so \(d \ge 0\) and \(\sigma^2 \ge a > 0\). Coefficients satisfy \(a > 0\), \(b \ge 0\), \(c \ge 0\).
Variance coefficients cannot be fixed or given equal bounds. If supplying a list of fitted parameters through the API, either omit all variance coefficients or include exactly those used by the selected model.
These choices affect both the weighted fit and the displayed uncertainty band. Non-constant variance shapes are available only with the Gaussian error model; Lognormal already represents multiplicative noise in log space.
Per-Point Errors¶
When explicit error bars (\(\sigma_i\)) are provided for each data point, a weighted log-likelihood is used instead:
For the lognormal model with per-point errors, error propagation gives \(\sigma_{\log,i} \approx \sigma_i / y_i\) (delta method).
Auto Selection¶
When Auto is selected, synfit runs the fit twice — once with each error model — as independent candidates. Each candidate gets its own data-derived bounds (for example, lognormal floors asymptote lower bounds at a strictly positive value). The fit flags and initial values you set are kept for both candidates, so a parameter you uncheck stays fixed at that value. The provisional bounds shown in the dialog while Auto is selected are gaussian-only and are not used for the comparison; likewise, any bounds you edit by hand are not applied under Auto — each candidate re-derives its own, then widens them if needed so your initial sits inside, without leaving that candidate's valid domain. A candidate that cannot represent a value you set (fixed or free) — the usual case: Lognormal when Bottom is 0 or negative, because lognormal needs strictly positive predicted responses — is skipped, and the reason is shown next to the error model on the analysis page. The dialog stays on Auto after Fit; Save records that choice so a later re-fit re-runs the comparison. To fit with custom bounds, choose a concrete error model (gaussian or lognormal) instead. The model with the lower AIC (Akaike Information Criterion) wins. Since both models have the same number of free Hill parameters, AIC comparison reduces to which likelihood better explains the data.
The chosen model is shown on the analysis detail page as Auto (Gaussian) or Auto (Lognormal). If a candidate was skipped, the skip reason appears under that label.
Jacobian correction
For a fair comparison between gaussian and lognormal likelihoods, the lognormal log-likelihood includes the change-of-variables Jacobian correction \(-\sum \log y_i\). Without this term, the two likelihoods are on different scales and AIC comparison is invalid.
Further Reading¶
- Wikipedia: Maximum likelihood estimation — the statistical framework underlying both error models
- Wikipedia: Profile likelihood — how profiling eliminates nuisance parameters
Implementation details
Noise module (synfit.noise):
NoiseSpec— tagged union of frozen dataclasses:GaussianConstant,GaussianLinear,GaussianQuadratic,Lognormal, andCompoundAddMult. JSON usesfit_config.noise, for example{ "kind": "gaussian_quadratic" }(omitteda_init/b_init/c_initmean synfit derives them from the data). An explicit value is kept.from_dict(),to_dict(), anddefault_for_kind()handle serialization. The app also accepts legacyerror_model+variance_modelrows through a temporary issue #58 compatibility seam; omittedvar_a/var_b/var_con that path stayNone.log_prob(y, y_pred, noise=..., mask=None, y_err=None, variance_params=None)→float— computes the log-likelihood. Constant Gaussian/Lognormal use profiled variance wheny_erris absent; Gaussian linear/quadratic use the anchored variance polynomial;maskexcludes points.variance_at(mu, a, b, c, anchor)evaluates \(\sigma^2 = a + b d + c d^2\), \(d = \mu - \text{anchor}\). Fitters passanchor = min(effect_0, effect_inf)._transform(y, y_pred, noise)applies the log-space transform for lognormal. Clamps values to1e-12to avoidlog(0); logs a warning if any non-positive values were clamped.
How the fitter uses it (synfit.single):
SingleDrugFit._log_prob_data(x, valids)callsnoise.log_prob()with the current parameter vector's predictions. The noise spec is taken fromself.config.noise.SingleDrugFitWithError— variant that accepts a DataFrame with ay_errcolumn and passes it through tonoise.log_prob(); supports the same optionalvalidsmask asSingleDrugFit.fit().