Curve Fitting Toolbox: Getting started

Fit your first curve, inspect parameter confidence intervals, switch between scientific model families, lock parameters, and evaluate residual diagnostics.

← Curve Fitting Toolbox overview · Modeling guide · Methods guide · Examples · Reference

What you will learn

By following this guide, you will:

  • Execute a reproducible first solve fitting an enzyme kinetics curve in Excel.
  • Switch between six scientific model families using the Start controls sheet.
  • Apply robust loss functions (Huber, Cauchy, Soft L1) to suppress measurement outliers without manual point deletion.
  • Lock known physical constants using parameter locking (Fixed = TRUE).
  • Interpret statistical outputs: asymptotic standard errors, Student-t statistics, p-values, and 95% confidence intervals.
  • Evaluate the 7-check automated Diagnostics Suite to verify fit validity and residual integrity.

Prerequisites and setup

Before running the toolbox:

  1. Open curve-fitting-toolbox.xlsx in Excel with the Boardflare add-in enabled, or load the workbook in the Boardflare development workspace.
  2. Ensure the Python for Excel notebook task pane is active.
  3. Review the six worksheets:
    • Start: Control panel for model selection, loss functions, confidence levels, and model catalog.
    • Data: Experimental observations table (\(X\), \(Y\), optional \(Weight\), and \(Sigma\)).
    • Parameters: Initial guesses, box bounds, parameter locking flags, and physical descriptions.
    • Results: Published fit summary metrics and parameter estimation table.
    • Fitted Curve: High-resolution 50-point evaluation grid, 95% confidence bands, and derivatives.
    • Diagnostics: 7-check automated diagnostic evaluation with severity ratings and diagnostic details.

Reproducible first solve: Michaelis-Menten enzyme kinetics

The default workbook configuration fits the Henri-Michaelis-Menten equation describing substrate saturation enzyme velocity:

\[v = \frac{V_{\max} [S]}{K_m + [S]}\]

where \([S]\) is the substrate concentration (mM), \(v\) is the reaction rate (\(\mu\text{mol} / \text{min}\)), \(V_{\max}\) is the asymptotic maximum reaction velocity, and \(K_m\) is the substrate concentration at which the velocity reaches half of \(V_{\max}\).

Step 1: Verify the input configuration

  1. Navigate to the Start sheet.
  2. Confirm cell B6 (Active model) is set to michaelis_menten.
  3. Confirm cell B7 (Loss function) is set to Linear.
  4. Confirm cell B8 (Confidence level) is set to 0.95.
  5. Switch to the Data sheet. Notice the 9 rows of concentration (\(X\)) and measured reaction rate (\(Y\)) pairs for michaelis_menten starting at row 6:
Model X (Substrate mM) Y (Rate \(\mu\text{mol/min}\)) Weight Sigma
michaelis_menten 0.5 12.6 1.0 0.5
michaelis_menten 1.0 20.3 1.0 0.5
michaelis_menten 2.0 35.3 1.0 0.5
michaelis_menten 3.0 42.1 1.0 0.5
michaelis_menten 5.0 55.3 1.0 0.5
michaelis_menten 7.0 61.0 1.0 0.5
michaelis_menten 10.0 69.7 1.0 0.5
michaelis_menten 15.0 74.3 1.0 0.5
michaelis_menten 20.0 79.0 1.0 0.5

Step 2: Inspect initial guesses and bounds

Switch to the Parameters sheet. The two parameters defining the Michaelis-Menten model have sensible initial guesses and physiological bounds:

Model Parameter InitialValue LowerBound UpperBound Fixed Description
michaelis_menten Vmax 85.0 0.1 500.0 FALSE Maximum asymptotic velocity
michaelis_menten Km 4.0 0.01 100.0 FALSE Substrate half-saturation constant

Both parameters have Fixed = FALSE, allowing the nonlinear least squares solver to estimate both parameters freely.

Step 3: Run the notebook and examine Results

Click Run in the Python for Excel notebook (or allow automatic recalculation). Within milliseconds, the solver converges using SciPy’s Trust Region Reflective (TRF) algorithm.

Navigate to the Results sheet to inspect the published tables:

Fit summary (Results!A5:B17)

  • Active model: Enzyme Kinetics — Michaelis-Menten
  • Fit status: OPTIMAL
  • Family: Saturation
  • Formula: Vmax * x / (Km + x)
  • SSE (Sum of Squared Errors): 6.4062
  • RMSE: 0.8437
  • R-squared: 0.9986 (accounting for > 99.8% of observed variance)
  • Adjusted R-squared: 0.9984
  • AIC / BIC: 0.9404 / 1.3348
  • Data points: 9
  • Residual DoF: 7 (\(n - p_{\text{free}} = 9 - 2 = 7\))

Parameter estimates (Results!D5:J7)

Parameter Estimate StdError tStat pValue CI_Lower CI_Upper
Vmax 91.9265 1.1392 80.69 1.18e-11 89.2326 94.6204
Km 3.3842 0.1285 26.33 2.92e-8 3.0802 3.6881

The 95% confidence intervals indicate that true \(V_{\max}\) lies between 89.23 and 94.62 \(\mu\text{mol/min}\), while \(K_m\) is bounded between 3.08 and 3.69 mM.


Switching models

Switching models requires changing only one control cell:

  1. Navigate to the Start sheet.
  2. Click cell B6 (Active model). A dropdown list appears containing all pre-configured models:
    • michaelis_menten
    • exponential_decay
    • polynomial_3
    • gaussian_peak
    • logistic_4p
    • power_law
  3. Select exponential_decay.
  4. Observe the automatic recalculation:
    • The notebook extracts the 7 observations corresponding to exponential_decay on the Data sheet.
    • It matches the initial parameters on Parameters (\(y_0 = 100.0, k = 0.5\)).
    • The Results sheet updates immediately:
      • y0 ≈ 99.95 ± 0.08
      • k ≈ 0.5000 ± 0.0008
      • R² > 0.999, SSE ≈ 0.0294
    • The Fitted Curve sheet updates its 50-point grid spanning \(x \in [0.0, 6.0]\), with negative first derivatives reflecting pure exponential clearance.

Selecting robust loss functions

Experimental data frequently contains outliers caused by pipetting errors, detector saturation, or bubble formation in flow cells. Rather than arbitrarily deleting data points, the toolbox supports robust loss functions that automatically down-weight influential residuals:

  1. Navigate to Start!B7 (Loss function).
  2. Choose from the available options:
    • Linear: Standard quadratic least squares (\(\rho(z) = z^2\)). Optimal for normally distributed errors without outliers.
    • Huber: Quadratic for small residuals (\(|z| \le 1\)), linear for larger residuals (\(2|z| - 1\)). Balances efficiency near zero with resistance to moderate outliers.
    • Soft L1: Smooth approximation to absolute deviation loss (\(\rho(z) = 2(\sqrt{1 + z^2} - 1)\)). Gradual outlier dampening.
    • Cauchy: Lorentzian robust loss (\(\rho(z) = \ln(1 + z^2)\)). Heavily down-weights severe outliers and measurement spikes.
  3. Test Huber loss on the Michaelis-Menten model:
    • On Start, keep michaelis_menten active and change Loss function (B7) to Huber.
    • On Results, observe how the estimates adjust slightly: \(V_{\max} \approx 92.05\), \(K_m \approx 3.38\). The influence of slight experimental discrepancies is suppressed without altering the underlying model structure.

Locking parameters (Fixed = TRUE)

In many physical, biochemical, or engineering experiments, certain parameters are known a priori from calibration or baseline runs. For example: - Holding the baseline response \(y_0 = 100.0\) in an exponential decay clearance assay. - Fixing the lower plateau bottom = 0.0 in an immunoassay where non-specific binding is fully subtracted.

How to lock a parameter:

  1. Navigate to the Parameters sheet.
  2. Find the row for the parameter you want to lock.
  3. In the Fixed column (column F), change the value from FALSE to TRUE.
  4. Re-run or observe the instant recalculation:
    • Optimization: The solver excludes the locked parameter from the free optimization vector, fitting only the remaining free parameters.
    • Estimate: The locked parameter retains its exact InitialValue.
    • Standard Error: Reported as 0.0 because the parameter is not subject to estimation uncertainty.
    • Residual Degrees of Freedom: Increases by 1 because one fewer degree of freedom is consumed.
    • Confidence Intervals: Upper and lower bounds equal the fixed value.

Example: Locking \(V_{\max} = 85.0\) in Michaelis-Menten:

  • On Parameters, set Fixed for Vmax (cell F6) to TRUE.
  • On Results, observe:
    • Vmax: Estimate = 85.0, StdError = 0.0, CI = [85.0, 85.0].
    • Km: Freely fitted to 2.80 mM.
    • Residual DoF increases from 7 to 8 (\(9 - 1 = 8\)).
    • Diagnostics confirms: Observations: 9, Free parameters: 1, Fixed: 1, Residual DoF: 8.

Interpreting statistical outputs and confidence intervals

The Results and Fitted Curve sheets provide rigorous statistical metrics based on the asymptotic parameter covariance matrix:

\[\mathbf{C} = (\mathbf{J}^T \mathbf{W} \mathbf{J})^{-1} \cdot s^2\]

where \(\mathbf{J}\) is the Jacobian matrix evaluated at the optimal parameter vector, \(\mathbf{W}\) is the diagonal weight matrix, and \(s^2 = \frac{\text{SSE}}{n - p_{\text{free}}}\) is the residual variance.

1. Parameter estimates and inference

  • StdError: The square root of the diagonal elements of \(\mathbf{C}\): \(\text{SE}(p_j) = \sqrt{C_{jj}}\). Measures the precision of the parameter estimate.
  • tStat: Ratio of parameter estimate to standard error: \(t = \hat{p}_j / \text{SE}(p_j)\). Tests the null hypothesis \(H_0: p_j = 0\).
  • pValue: Two-tailed probability under Student’s t-distribution with \(\nu = n - p_{\text{free}}\) degrees of freedom. Values below \(0.05\) indicate statistical significance at the 95% level.
  • CI_Lower / CI_Upper: Asymptotic confidence interval: \(\hat{p}_j \pm t_{\alpha/2, \nu} \cdot \text{SE}(p_j)\).

2. Pointwise curve confidence bands

On the Fitted Curve sheet, columns CI_Lower and CI_Upper provide pointwise 95% confidence intervals along the entire evaluation domain. These are computed using the Delta method:

\[\text{SE}(\hat{y}(x)) = \sqrt{\nabla_{\mathbf{p}} f(x, \mathbf{p})^T \mathbf{C} \nabla_{\mathbf{p}} f(x, \mathbf{p})}\] \[\text{CI}(x) = \hat{y}(x) \pm t_{\alpha/2, \nu} \cdot \text{SE}(\hat{y}(x))\]

In the task pane plot, this confidence band is rendered as a shaded region surrounding the fitted curve, visually showing where parameter uncertainty is highest.


Reading the Diagnostics sheet

Navigate to the Diagnostics sheet. The toolbox automatically performs seven diagnostic checks, each tagged with a severity level (PASS, WARN, FAIL):

Check Severity Detail Interpretation
Model validation PASS Observations: 9, Free parameters: 2, Fixed: 0, Residual DoF: 7. Verifies \(n \ge p_{\text{free}} + 1\). Prevents under-determined fits.
Convergence PASS Optimal convergence achieved within parameter bounds. Flags if solver failed or if any free parameter is stuck against its box bounds.
Goodness of fit PASS R-squared: 0.9986, Adjusted R-squared: 0.9984. Assesses variance explained (\(R^2 \ge 0.95\) PASS, \(0.80 \le R^2 < 0.95\) WARN, \(< 0.80\) FAIL).
Jacobian conditioning PASS Scaled Jacobian condition number \(\kappa = 4.01\). Detects collinearity and parameter over-specification (\(\kappa < 1000\) PASS, \(1000 \le \kappa < 10000\) WARN, \(\ge 10000\) FAIL).
Residual normality PASS Shapiro-Wilk W = 0.8780, p-value = 0.1494. Tests if residuals follow a normal distribution (\(p \ge 0.05\) PASS).
Residual autocorrelation WARN Durbin-Watson statistic d = 3.6039 indicates negative autocorrelation (alternating residual signs in small sample N=9). Tests for serial correlation across sorted observations (\(1.5 \le d \le 2.5\) PASS). In small sample sizes (\(N=9\)), alternating residual signs produce \(d > 3.0\), yielding WARN rather than FAIL.
Outlier detection PASS No standardized residuals exceed 2.5 std. Detects observations with \(|r_i| / \text{RMSE} > 2.5\).

Next steps

  • Read the Modeling guide to structure your own experimental datasets and add custom equations.
  • Explore the Methods guide for detailed mathematical algorithms, robust loss formulas, and comparison with MATLAB’s Curve Fitting Toolbox.
  • Walk through all 6 scientific models in the Worked examples.
  • Review complete schemas and troubleshooting in the Reference guide.