Skip to content

Confidence Intervals

synfit reports 95% confidence intervals on both individual parameters and the fitted curve for single-drug analyses.

Parameter Confidence Intervals

After fitting, each parameter (IC₅₀, Hill, effect₀, effect∞) is reported with a 95% CI:

\[ \hat{\theta}_i \pm z_{0.975} \cdot \text{SE}(\hat{\theta}_i) \]

where \(\text{SE}(\hat{\theta}_i) = \sqrt{\text{Cov}(\hat{\theta})_{ii}}\) and \(z_{0.975} \approx 1.96\).

IC₅₀ / EC₅₀

The potency parameter is optimized in log-space (\(\log_{10}\text{C}_{50}\)), so the CI is first computed on the log scale and then transformed back:

\[ \text{CI}(\text{C}_{50}) = \left[10^{\hat{\ell} - z \cdot \text{SE}(\hat{\ell})},\; 10^{\hat{\ell} + z \cdot \text{SE}(\hat{\ell})}\right] \]

This yields an asymmetric CI in linear space, which is the correct behaviour — potency estimates are right-skewed.

Curve Confidence Band

The dose-response plot shows a shaded region around the fitted curve representing the 95% confidence band. This is computed using the delta method:

\[ \text{Var}\!\left[\hat{y}(x)\right] = \mathbf{J}(x)\;\text{Cov}(\hat{\theta})\;\mathbf{J}(x)^{\!\top} \]

where \(\mathbf{J}(x)\) is the Jacobian (row vector of partial derivatives of the Hill curve with respect to each fitted parameter, evaluated at concentration \(x\)).

The band is:

\[ \hat{y}(x) \pm z_{0.975} \cdot \sqrt{\text{Var}[\hat{y}(x)]} \]

When a Gaussian linear or quadratic variance model is active, the displayed band is a prediction band: observation noise \(\sigma^2(\hat{y})\) is added inside the square root. That variance is anchored at the lower asymptote.

Analytic Jacobian

For efficiency and numerical stability, the Jacobian is computed analytically rather than by finite differences. Defining:

\[ H = \left(\frac{\text{C}_{50}}{x}\right)^{\text{hill}}, \quad f = \frac{1}{(1+H)^s}, \quad g = \frac{H \cdot f}{1+H} \]

the partial derivatives for the 4-parameter model are:

Parameter \(\partial \hat{y} / \partial \theta\)
effect_0 \(1 - f\)
effect_inf \(f\)
log_c50 \(-(\text{effect}_0 - \text{effect}_\infty) \cdot s \cdot \text{hill} \cdot \ln 10 \cdot g\)
hill \(-(\text{effect}_0 - \text{effect}_\infty) \cdot s \cdot \ln 10 \cdot g \cdot (\log_{10}\text{C}_{50} - \log_{10} x)\)

For the 5-parameter model, an additional term for the asymmetry parameter \(s\) is included.

Covariance Estimation

The parameter covariance matrix is estimated from the observed Fisher information at the optimum:

\[ \text{Cov}(\hat{\theta}) \approx \mathbf{H}^{-1} \]

where \(\mathbf{H}\) is the Hessian of the negative log-likelihood (data term only, excluding the soft boundary prior). The Hessian is computed via central finite differences at the MLE.

The Hessian is evaluated under the active error and variance model. For example, a Gaussian fit with a linear or quadratic \(\sigma^2(\mu)\) model uses that fitted weighting when estimating parameter covariance; a lognormal fit estimates covariance in log-response likelihood space.

If the Hessian is singular or the resulting covariance has negative diagonal entries (non-positive-definite), CIs are not reported.

When CIs Are Unavailable

CIs may be absent when:

  • The Hessian is numerically singular (nearly flat likelihood surface)
  • The fit converged at or near a boundary
  • The data has too few points relative to the number of parameters

In these cases, the analysis detail page shows parameter estimates without brackets.

Further Reading

Implementation details

Covariance estimation (synfit.fitting.FitBase._estimate_covariance):

  • Computes the Hessian of -log_prob_data (no prior) via nested approx_fprime calls with step size 1e-5.
  • Symmetrises with 0.5 * (H + H.T).
  • Returns np.linalg.inv(H) or None if inversion fails or any diagonal entry is negative.

Parameter CIs (synfit.data.FitResult.param_ci):

  • Reads param_cov and param_names from the result.
  • Computes val ± z * sqrt(diag(cov)) for each parameter.
  • For log_c50, adds a c50 key via monotonic transform 10^x.

Curve CIs (synfit.data.FitResult.predict_ci):

  • Builds the analytic Jacobian matrix J (n_conc × n_params).
  • Computes var_y = einsum("ij,jk,ik->i", J, pcov, J).
  • Returns (y_hat - z*std, y_hat + z*std).

Plotting (synfit.plotting.dose_response_plot):

  • Calls result.predict_ci(conc_fine) and renders the band with fill_between.
  • Displays parameter CIs in the annotation box if available.