Statistics tutorial · Chapter 08

Curve fitting

77 min read · 6 sections

This chapter is the curve fitting guide of Variance: it is the one opened by Help › Fitting Curves. It first presents the principles of nonlinear regression, then the Nonlinear Regression analysis in detail: the equation library, custom equations, the algorithm, weighting, constraints and global fitting, initial values, robust regression and outlier detection (ROUT), confidence intervals, bands, diagnostics, comparison of models and of data sets, and interpolation of unknowns. Three related analyses follow: Standard Curve Interpolation (calibration curve), Smoothing Curve (Spline, LOWESS) (a smooth curve without a model) and Function Curve (drawing an equation). All of them are found in Analysis › Curves and Regression. The regression line (simple linear regression) is covered in chapter 16.

The examples use the sample data of XY tables (welcome window, XY type, "an example"): "Dose-response (log dose, replicates)", "Exponential decay (time course)" and "Enzyme velocity vs. substrate".

Principles of nonlinear regression#

A model, parameters, a sum of squares#

Fitting a curve means choosing an equation Y = f(X; θ1, θ2, …, θp), then looking for the values of the parameters θ that bring the curve as close as possible to the data. You choose the equation, based on the biology or physics of the phenomenon (binding of a ligand to a site, decay of a concentration, growth of a population); the regression only finds the best values of the parameters of that model and tells you how precisely the data determine them.

The usual criterion is least squares: the best curve is the one that minimizes the sum of the squared vertical distances between the points and the curve,

SS(θ) = Σ wi · [ yi − f(xi; θ) ]²

yi, xi: observed values of point i
f(xi; θ): value of the curve at xi for the parameters θ
wi: weight of point i (wi = 1 without weighting)

If the scatter of the points around the true curve follows a normal distribution with the same standard deviation everywhere, the least-squares solution is also the maximum likelihood solution: this is what justifies it.

"Nonlinear" describes the way the parameters enter the equation. In Y = Bottom + (Top − Bottom)/(1 + 10^((LogEC50 − X)·HillSlope)), LogEC50 and HillSlope appear nonlinearly: there is no formula that directly gives their best values. The method is therefore iterative: start from initial values, improve them step by step, and stop when the sum of squares no longer decreases. A polynomial, by contrast, is linear in its parameters (even though its graph is curved): the solution is unique, and Variance obtains it with the same algorithm.

Initial values and local minima#

Picture the sum of squares as a landscape whose coordinates are the parameter values. The algorithm walks downhill from its starting point and stops at the bottom of the first valley it meets. If there are several valleys, it may stop in a secondary one (a local minimum) and return a clearly wrong curve, without any error message. Reasonable initial values almost always avoid this trap.

Variance automatically computes initial values for each equation in the library, from the data (for example Top = largest Y value). They are sufficient in the vast majority of cases. To check that they are sensible, choose the method "No fit: draw the curve of the initial values": Variance draws the starting curve without fitting. To change them, use the Initial values tab. Signs of a local minimum: a curve that does not follow the points, absurd parameters, an "Ambiguous" status, or results that change when you start from other initial values. The worked example of nonlinear regression shows one such case.

Golden rule: never draw conclusions from a fit without looking at the curve superimposed on the points.

Choosing a model#

  • Start from the science, not from the goodness of fit. A more complex model (with more parameters) always follows the points more closely; that does not prove it is right. To find out whether the extra complexity is justified, compare the models (F test or AICc, see below).
  • Prefer parameters that have a meaning (EC50, Kd, half-life): their confidence interval directly answers the question you asked.
  • The data must define each parameter. A dose-response curve whose doses do not cover both plateaus cannot estimate Bottom and Top; a decay stopped well before the plateau determines Plateau poorly. You must then fix the parameter at a known value (constraint), or complete the experiment.
  • Choose the right parameterization. For a dose-response curve, enter the logarithm of the concentrations in X and fit LogEC50 rather than EC50: the uncertainty of an EC50 is asymmetric (the interval extends much further toward high concentrations), whereas that of LogEC50 is roughly symmetric.

Nonlinear Regression#

The Nonlinear Regression analysis fits a model, chosen from the library of 104 equations or written by you, to each data set of an XY table. It uses least squares (Levenberg-Marquardt algorithm), with optional weighting, robust regression or Poisson regression. It gives the best value of each parameter and of the derived parameters (EC50, half-life…), their standard errors and confidence intervals (by profile likelihood or asymptotic), the goodness of fit (R², sum of squares, Sy.x, RMSE, AICc) and the fit status. It also lets you constrain or share parameters between data sets (global fitting), detect outliers (ROUT), draw confidence or prediction bands, test the residuals, compare two models, compare data sets with each other and interpolate unknowns. The fitted curve is superimposed on the data graph.

When to use it#

  • You have a model (an equation) that describes the phenomenon: dose-response curve, saturation or competition binding, association or dissociation kinetics, enzyme kinetics, exponential decay or growth, Gaussian peak…
  • You want the values of the model parameters and their precision (EC50 and its confidence interval, rate constant, Km).
  • You want to compare: two models (one site or two sites? one phase or two?), or several conditions (is the EC50 changed by the antagonist?).
  • Do not use it: for a simple straight line (Simple Linear Regression, chapter 16, which also gives the slope test and the comparison of lines); to draw a smooth curve without a model (Smoothing Curve (Spline, LOWESS)); when both X and Y are subject to error (Deming regression); for a binary 0/1 response (logistic regression).

Assumptions and checks#

  • The model is correct: the true relationship between X and the mean of Y follows the chosen equation. Check: the curve superimposed on the points; the residual plot ("Residuals" output table), which should show a horizontal band without pattern; the runs test ("Runs test"); the replicates test ("Lack-of-fit test (replicates)") if you have replicates.
  • X is known without error (or with an error negligible compared with the scatter of Y): this is the case for doses, times and prepared concentrations.
  • The scatter around the curve follows a normal distribution. Check: "Normality of residuals (D'Agostino-Pearson)". With few points, this test has little power.
  • The scatter is the same along the whole curve (homoscedasticity). Check: the residual plot (funnel shape?) and "Test for homoscedasticity (Breusch-Pagan on the residuals)". If the standard deviation increases with Y, use 1/Y² weighting (standard deviation proportional to Y) or 1/Y^K.
  • The points are independent. Replicates that measure the same sample several times (technical replicates) are not independent: choose "The mean of the replicates only" in that case. Repeated measurements over time on the same animal are not independent either.
  • No outlier pulling the curve. Check: the residuals; robust regression or the ROUT method.
  • The parameters are determined by the data. Check: the width of the confidence intervals, the status ("Ambiguous" flags a parameter that the data do not determine), Hougaard's skewness.

Step by step in Variance#

  1. Create an XY table. Put the X values in the X column (the logarithm of the concentrations if the name of the chosen equation says "log dose") and each condition in a data set. Y replicates (subcolumns) are accepted, as are summary formats (mean with SD, SEM or %CV): each row then gives a single point, its mean, and the corresponding SD (derived from the SEM only if N is entered) is used for 1/SD² weighting. To follow the example: welcome window, XY type, "an example", example "Dose-response (log dose, replicates)".
  2. Choose Analysis › Curves and Regression › Nonlinear Regression, the button of the Analyses group of the ribbon (tooltip "Nonlinear regression (curve fitting)"), or Analyze then "Nonlinear Regression" in the "Choose an Analysis" window.
  3. The "Nonlinear Regression – settings" window opens. Its tabs, in order:
    • Model: "Equation" presents the library, one family per expandable section, with a "Search:" field that filters by equation or family name; the "Selected: …" line recalls the choice and the text of the equation is displayed below it (it also appears as a tooltip on each name). Default: "Agonist, log dose, variable slope (4PL)". If the project contains saved equations, they appear at the top, under "Custom equations". The "Custom equation" field receives an equation written by you; if it is not empty, it replaces the library equation. Under this field, "Save in the project as" (a name) then Save equation save the equation in the project: it is checked, filed under "Custom equations" (an equation of the same name is replaced; a library name is refused), chosen for the analysis, and the field is emptied; it is then available to all the analyses of the project and is undone by Edit › Undo. The Manage saved equations… button, below the list, renames, edits or deletes these equations and sets their initial values (see "Custom equations"). The "Interpolate the unknowns on the standard curve" box (unchecked) computes the X of each row that has a Y value but no X.
    • Method: "Fitting method": "Least squares regression" (default), "Robust regression", "Poisson regression" (Y are counts) or "No fit: draw the curve of the initial values"; with Poisson regression, "Allow overdispersion (quasi-Poisson standard errors)" (unchecked, grayed out for the other methods). "Weighting": "No weighting" (default), "Weights 1/Y²", "Weights 1/Y^K" (with "K for 1/Y^K weighting", 1 by default, from 0 to 10), "Weights 1/X", "Weights 1/X²" or "Weights 1/SD²". "Replicates": "Each replicate as a separate point" (default) or "The mean of the replicates only". "Outliers": "Keep every point" (default), "Remove outliers (ROUT)" or "Detect and flag outliers (ROUT), fit all data", with "ROUT coefficient Q (%)" (1 by default, from 0.0001 to 10). "Convergence": "Quick", "Medium" (default) or "Strict".
    • Constrain: the "Constraints" field receives one constraint per line (syntax detailed below): Bottom = 0, HillSlope < 0, Top > 50, LogEC50 shared, B = column title.
    • Initial values: the "Initial values" field receives one value per line, for example LogEC50 = -6; parameters not mentioned keep their automatic value.
    • Compare: "Compare": "No comparison" (default), "Extra sum-of-squares F test" or "Akaike's Information Criterion (AICc)", with "Alternative equation (model 2)" (default "Agonist, log dose, slope 1 (3 parameters)"). "Compare the data sets": "No comparison of data sets" (default), "Single curve for all data sets" or "Does the value of a parameter differ between data sets?", with "Parameter compared between data sets" (the name of the parameter, LogEC50 by default; case does not matter).
    • Range: "Ignore points with X below" and "Ignore points with X above" (empty by default: no point excluded); "Points defining the curve" (150 by default, from 10 to 5000), the number of points evenly spaced in X used to draw the curve, from the smallest to the largest X value of the data set.
    • Confidence: "Confidence intervals of parameters": "Asymmetric (profile likelihood, recommended)" (default) or "Symmetric (asymptotic approximate)"; "Plot": "No bands" (default), "Confidence bands" or "Prediction bands".
    • Options: "Confidence level (%)" (95 by default), "Significant digits" (4 by default) and "P value format".
    • Output: "Table and graph of" (empty by default) takes the name of a parameter or of a value of the results (LogEC50, EC50, Top…): its best-fit value in each data set, with its standard error, in a tab and an output table ready to plot. "The titles of the data sets are": "Labels: a bar graph, one bar per data set" (the default; a One factor table "Mean, SEM", one bar per data set) or "X values: an XY graph, X read from the titles" (an XY table whose X are the titles of the data sets read as numbers, for example concentrations). "Compute Ki from IC50 (Cheng-Prusoff)" (unchecked), with "Radioligand concentration" and "Kd of the radioligand", in the unit of the IC50 (molar when X is the log of a molar concentration: 1e-9 for 1 nM). "Dose ratios and Schild plot" (unchecked): the first data set is the control without antagonist, the titles of the others are the antagonist concentrations, "As concentrations" (the default) or "As logarithms".
    • Diagnostics: five boxes unchecked by default, "Runs test", "Normality of residuals (D'Agostino-Pearson)", "Lack-of-fit test (replicates)", "Test for homoscedasticity (Breusch-Pagan on the residuals)" "Hougaard's skewness of the parameters" and "Dependency of each parameter", then "Table of residuals" (checked).
    • Flag: criteria that flag a doubtful fit, useful when fitting many data sets: "Flag fits with R squared below", "Flag fits with fewer points than", "Flag fits with a parameter dependency above" (0.9999 is a typical value), "Flag fits with more outliers than" (0 disables each of these criteria), "Flag fits whose residuals fail the normality test" and "Flag fits that fail the runs test" (check boxes), with "Significance level of the normality and runs tests" (0.05 by default: these two tests flag the fit if P < this threshold).
  4. Data sets tab: check the data sets to fit. Each data set is fitted separately, unless a parameter is shared (shared): all the checked data sets are then fitted together.
  5. Click OK. The results sheet is created and the curve of each data set (with its bands if you requested them) is added to the data graph. To change the choices: Format › Analysis Settings… (Ctrl+Shift+A).

You need at least as many points as free parameters; with exactly as many, the degrees of freedom are zero and neither standard error nor interval can be computed. If the fit of a data set fails (for example because the curve is not defined with the initial values, such as ln(X) for X ≤ 0), a warning is displayed at the top of the results (for example "Control: invalid argument: bad initial values"); the cells of that data set then stay empty (only the fixed constants are displayed).

Constraint syntax (Constrain tab, one line per constraint, parameter names are case-insensitive; the value can be a constant expression such as 10^-3*2):

  • Bottom = 0 fixes the parameter: it is no longer fitted, is displayed as "= 0" in the results and does not count in the degrees of freedom.
  • HillSlope < 0, Top > 50 (or <=, >=) bound the parameter; the bound itself is allowed (≤ or ≥). If the best fit stops on a bound, the status becomes "At a bound".
  • LogEC50 shared shares the parameter between all the checked data sets: a single value is fitted for all of them (global fitting), the other parameters remaining specific to each data set.
  • B = column title takes the value of the parameter from the title of each data set, which must be a number (for example the antagonist or inhibitor concentration of each curve).

The equation library#

The library contains 104 equations divided into 15 families, in the order of the list: "Lines and polynomials", "Exponentials", "Growth", "Dose-response: agonists", "Dose-response: inhibitors", "Dose-response: other models", "Saturation binding", "Competition binding", "Binding kinetics", "Enzyme kinetics", "Enzyme inhibition", "Peaks and distributions", "Periodic functions", "Linear-quadratic (radiobiology)" and "Standard curves". The equations are written in the language described below: log is the base-10 logarithm, ln the natural logarithm, zdist the cumulative distribution function of the standard normal distribution. Here are the main ones (exact name in quotation marks).

Dose-response. X is the logarithm of the concentration ("log dose" equations) or the concentration itself ("linear dose" equations):

"Agonist, log dose, variable slope (4PL)"
   Y = Bottom + (Top − Bottom) / (1 + 10^((LogEC50 − X) · HillSlope))
"Agonist, log dose, slope 1 (3 parameters)"  same equation, HillSlope = 1
"Agonist, log dose, 0-100%, variable slope"
   Y = 100 / (1 + 10^((LogEC50 − X) · HillSlope))
"Agonist, linear dose, variable slope (4PL)"
   Y = Bottom + X^HillSlope · (Top − Bottom) / (X^HillSlope + EC50^HillSlope)
"Inhibitor, log dose, variable slope (4PL)"
   Y = Bottom + (Top − Bottom) / (1 + 10^((LogIC50 − X) · HillSlope))
"Inhibitor, log dose, slope -1 (3 parameters)"
   Y = Bottom + (Top − Bottom) / (1 + 10^(X − LogIC50))
"Standard curve: 5PL, log dose"
   LogXb = LogEC50 + (1/HillSlope) · log(2^(1/S) − 1)
   Y = Bottom + (Top − Bottom) / (1 + 10^((LogXb − X) · HillSlope))^S
"Effective concentration at F%, log dose"
   LogEC50 = LogECF − (1/HillSlope) · log(F / (100 − F))      (F fixed, 80 by default)
   Y = Bottom + (Top − Bottom) / (1 + 10^((LogEC50 − X) · HillSlope))

Bottom and Top are the lower and upper plateaus (in the unit of Y), LogEC50 (or LogIC50) is the X value halfway between Bottom and Top, and HillSlope is the Hill slope (positive for an increasing curve, negative for a decreasing curve: in the "variable slope" inhibitor equations, the fitted slope is therefore negative). In the five-parameter model, S measures the asymmetry (S = 1 gives back the symmetric curve). The "Dose-response: other models" family also contains the biphasic and bell-shaped curves, the absolute IC50 ("Absolute IC50, log dose", with the constant Fifty, 50 by default), the Gaddum/Schild shift (Antag = 1 + (B/10^(−pA2))^SchildSlope and LogEC = LogEC50 + log(Antag), where B is the antagonist concentration), the EC50 shift and the operational model of partial agonism.

Binding and binding kinetics.

"Specific binding, one site"               Y = Bmax · X / (Kd + X)
"Total and nonspecific binding, one site"  Y = Bmax · X / (Kd + X) + NS · X + Background
"Specific binding, two sites"              Y = Bmax1 · X/(Kd1 + X) + Bmax2 · X/(Kd2 + X)
"Specific binding, cooperative (Hill)"     Y = Bmax · X^h / (Kd^h + X^h)
"One-site competition, logIC50"            Y = Bottom + (Top − Bottom) / (1 + 10^(X − LogIC50))
"One-site competition, Ki"                 LogEC50 = log(10^logKi · (1 + HotNM/HotKdNM))
                                             Y = Bottom + (Top − Bottom) / (1 + 10^(X − LogEC50))
"Dissociation rate (koff)"                 Y = (Y0 − NS) · exp(−K · X) + NS
"Association, one ligand concentration"    Y = Ymax · (1 − exp(−Kob · X))

Bmax is the maximum number of sites, Kd the dissociation constant (concentration that occupies half of the sites), NS the slope of nonspecific binding. "Two-site competition, logIC50" describes competition at two sites (fraction FractionHi of high-affinity sites). The "Fit Ki" equation applies the Cheng-Prusoff correction: HotNM (concentration of the radioligand, in nM) and HotKdNM (its Kd, in nM) are fixed constants, equal to 1 by default; give them the values of your experiment with constraints (HotNM = 2.5, HotKdNM = 1.2).

Enzyme kinetics.

"Michaelis-Menten"            Y = Vmax · X / (Km + X)
"Allosteric kinetics (Hill)"  Y = Vmax · X^h / (Khalf^h + X^h)
"Michaelis-Menten with kcat"  Y = Et · kcat · X / (Km + X)          (Et fixed, 1 by default)
"Substrate inhibition"        Y = Vmax · X / (Km + X · (1 + X/Ki))
"Competitive inhibition"      KmObs = Km · (1 + I/Ki)       Y = Vmax · X / (KmObs + X)

In the inhibition models ("Competitive inhibition", "Noncompetitive inhibition", "Uncompetitive inhibition", "Mixed inhibition"), I is the inhibitor concentration, read from the title of each data set (one data set per inhibitor concentration; to fit all the data sets together, share Vmax, Km and Ki with the constraints Vmax shared, Km shared and Ki shared). The Morrison equation ("Tight-binding inhibition (Morrison)") completes the family.

Exponentials and growth.

"Exponential decay, one phase"   Y = (Y0 − Plateau) · exp(−K · X) + Plateau
"Exponential rise, one phase"    Y = Y0 + (Plateau − Y0) · (1 − exp(−K · X))
"Exponential decay, two phases"  SpanFast = (Y0 − Plateau) · PercentFast · 0.01
                                   SpanSlow = (Y0 − Plateau) · (100 − PercentFast) · 0.01
                                   Y = Plateau + SpanFast · exp(−KFast · X) + SpanSlow · exp(−KSlow · X)
"Exponential growth"             Y = Y0 · exp(K · X)
"Logistic growth"                Y = YM · Y0 / ((YM − Y0) · exp(−K · X) + Y0)
"Gompertz growth"                Y = YM · (Y0/YM)^exp(−K · X)

Y0 is the value at X = 0, Plateau the value reached at long times, K the rate constant (in inverse units of X), YM the maximum value of the growth. The "Exponentials" family also contains the two-phase rise, the three-phase decay and the "… after a lag" variants (plateau up to X0, then decay or rise).

Peaks, classic sigmoids, polynomials.

"Gaussian peak"                 Y = Amplitude · exp(−0.5 · ((X − Mean)/SD)²)
"Lorentzian peak"               Y = Amplitude / (1 + ((X − Center)/Width)²)
"Lognormal peak"                Y = (A/X) · exp(−0.5 · (ln(X/GeoMean) / ln(GeoSD))²)
"Cumulative Gaussian, percent"  Y = 100 · zdist((X − Mean)/SD)
"Boltzmann sigmoid"             Y = Bottom + (Top − Bottom) / (1 + exp((V50 − X)/Slope))
"Polynomial, degree 2"          Y = B0 + B1 · X + B2 · X²

The "Lines and polynomials" family (straight line, line through the origin or through a fixed point, horizontal line, lines on log Y or on log X and log Y, two-segment line, hinge, two crossing lines, polynomials of degree 1 to 6, centered polynomials of degree 2 and 3 around MeanX, power series), "Growth" (including "Beta growth then decline"), "Periodic functions" and "Linear-quadratic (radiobiology)" (cell survival exp(−(A·X + B·X²)) and its variants) complete the list. The "Standard curves" family groups calibration models: straight line, line on log X, quadratic and cubic, hyperbola, four- and five-parameter sigmoids (log or linear dose), Padé approximant.

Derived parameters. Some equations also compute derived parameters, displayed after the fitted parameters: EC50 = 10^LogEC50 (likewise IC50, ECF, Ki, A2…), HalfLife = ln(2)/K and Tau = 1/K for exponentials, DoublingTime = ln(2)/K for exponential growth.

Constants fixed by default. A few equations contain constants that are not fitted: F (80) of "Effective concentration at F%", Fifty (50) of the absolute IC50, HotNM and HotKdNM (1) of "One-site competition, Ki", Et (1) of "Michaelis-Menten with kcat", Et, S and Km of the Morrison equation, X0 and Y0 of "Line through a fixed point (X0, Y0)", MeanX of the centered polynomials, X0 of the "… after a lag" models, HotNM and Time0 of "Association followed by dissociation". Some are computed from the data of each data set: MeanX is the mean of the X values of the data set, X0 of the "… after a lag" models the smallest X, Time0 the middle of the X range. They are displayed as "= value" in the results. Always check this value and impose that of your experiment with a constraint (for example F = 90 to obtain the EC90, Time0 = 10 for a dissociation started at 10 min).

Custom equations#

Type your equation in "Custom equation" (Model tab). The rules of the language:

  • the equation gives Y as a function of X: Y = …; you can define intermediate variables, one per line, before the Y = … line;
  • any name that is neither X, nor Y, nor an intermediate variable, nor a function is a parameter to fit; names are case-insensitive;
  • operators + - * / ^, comparisons < > <= >= = <>, AND OR NOT, constant PI, and IF(condition, value if true, value if false);
  • functions: abs sqrt exp ln log log10 log2 sin cos tan asin acos atan atan2 sinh cosh tanh int floor ceil round min max sign gamma gammaln erf erfc zdist tdist chidist fdist deg rad;
  • a comment begins with ; or //;
  • an implicit equation, where Y also appears to the right of the = sign, is solved numerically for each X (root search in Y);
  • a differential equation is written Y' = …: Variance integrates it with the 4th-order Runge-Kutta method, in 200 steps, from X0 where Y equals Y0; Y0 and X0 are parameters, and X0 almost always has to be fixed (X0 = 0 in the Constrain tab).

For example, Y = Span*exp(-K*X) + Plateau, or its differential form Y' = -K*(Y - Plateau) with the constraint X0 = 0 and the initial values Y0 = 100, Plateau = 10, K = 0.3, fitted to the "Exponential decay (time course)" data, give the same result as the "Exponential decay, one phase" equation of the library (K = 0.3592, Plateau = 10.90, sum of squares 38.43).

Automatic initial values of custom equations. Lacking an equation-specific rule, Variance guesses a value from the parameter name, testing the following rows in order:

Parameter nameInitial value
contains "bottom" or "min", or is called "Y0"smallest Y value
contains "top", "max", "plateau", "amplitude" or "span"largest Y value
contains "ec50", "ic50", "center" or "mean", or starts with "kd" or "km"X of the point whose Y is closest to the middle of the Y range
contains "hill"1
contains "slope"slope of the least-squares line of Y versus X
contains "intercept"intercept of that line
starts with "k"1 / (X range)
any other name1

These rules are crude: a parameter named "Slope" receives, for example, the slope of the least-squares line, which is very far from a Hill slope (the worked example shows the consequence); a name that contains "hill" (HillSlope) starts at 1. So give initial values to your own equations, in the Initial values tab of the analysis or, once and for all, with rules saved with the equation (below), and check them with "No fit".

Managing the saved equations. Analysis › Custom Equations…, or the Manage saved equations… button of the Model tab, opens the Custom Equations dialog. On the left, the list of the equations of the project, with New (write a new equation) and Delete; on the right, the chosen equation: Name, Equation (the parameters read are shown below, or the syntax error), then Initial values, one rule per parameter, which replaces the automatic rule (recalled in grey, for example "automatic: YMAX"). A rule is a number or an expression of the variables computed from the data of each data set: XMIN, XMAX, XMID (middle of the X range), XMEAN, YMIN, YMAX, YMID, YMEAN, XRANGE, YRANGE, XATYMID (X of the point whose Y is closest to YMID), YATXMIN and YATXMAX (Y at the smallest and the largest X), SLOPE and INTERCEPT (least-squares line), N (number of points); for example 0.5*YMAX or XMIN + XRANGE/3. The expandable list "Variables of the rules" recalls them, and ✔ or ⚠ tells whether the rule is valid. Save Changes saves (Revert goes back to the saved equation): the analyses that use the equation, listed by "Used by", are recomputed, and a change of name follows them. An equation used by an analysis cannot be deleted: first choose another equation in these analyses. Everything is undone by Edit › Undo. A value given in the Initial values tab of an analysis takes precedence over the rule of the equation.

Rules of the library equations. Each equation of the library has its own rules, computed on the data of each data set: for the sigmoids, Bottom = smallest Y value, Top = largest, LogEC50 = X of the point whose Y is closest to (Ymin + Ymax)/2, HillSlope = 1 or −1 depending on the sign of the slope of the data; for "Exponential decay, one phase", Y0 = Y at the smallest X, Plateau = Y at the largest X, K = 4/(X range); for "Exponential growth" and "Malthusian growth", Y0 = |Y at the smallest X| with the sign of Y at the largest X, and K = 1/(X range); for "Logistic growth" and "Gompertz growth", Y0 = |Y at the smallest X| with the sign of the largest Y value (a first point made negative by noise alone would start a positive growth from a negative curve, which the fit can only leave by sending K to −∞: a degenerate curve, status "Ambiguous"); for "Michaelis-Menten", Vmax = largest Y value and Km = X of the half-height point; for "Gaussian peak", Amplitude = largest Y value, Mean = X of the half-height point, SD = X range / 6. A value given in the Initial values tab replaces the rule; if the parameter is bounded, the initial value is brought back within the bounds.

Calculations#

Minimized function. For n points (xi, yi) and p free parameters θ (parameters fixed by a constraint do not count), Variance minimizes

SS(θ) = Σ ri(θ)²        with   ri(θ) = √(wi · ρi) · ( yi − f(xi; θ) )

wi: weight from the chosen weighting (1 without weighting)
ρi: robust weight (1 except in robust regression)

In a global fit (shared parameter), the sum runs over all the points of all the data sets, and θ gathers the shared parameters and the parameters specific to each data set.

Levenberg-Marquardt algorithm. At each iteration, Variance computes the Jacobian matrix J of the residuals (Jij = ∂ri/∂θj) by central finite differences, with a step h = 10⁻⁶ × max(|θj|, 10⁻⁶) (limited by any bounds), then solves the system

( JᵀJ + λ · diag(JᵀJ) ) · δ = − Jᵀ r

and tries θ + δ (brought back within the bounds if it leaves them). If the sum of squares does not increase, the step is accepted and λ is divided by 10 (minimum 10⁻¹²); otherwise λ is multiplied by 10 and the step recomputed. λ starts at 10⁻³. A small λ gives the Gauss-Newton step (fast near the minimum); a large λ gives a small step in the direction of steepest descent (safe far from the minimum).

Convergence criteria. An accepted step is judged "small" if the relative decrease of the sum of squares, (SSbefore − SSafter)/SSbefore, is below the tolerance ("Quick": 10⁻⁴; "Medium", the default: 10⁻¹²; "Strict": 10⁻¹⁵) or if no parameter changes by more than 10⁻¹² in relative value. The fit has converged after two consecutive small steps, or when no step can be accepted any more (λ exceeds 10¹⁶). Beyond 1000 iterations, it is declared not converged. The sum of squares varies as the square of the distance to the minimum: a tolerance of 10⁻¹² leaves the parameters about 10⁻⁶ × √df standard errors from their best values (10⁻² × √df with "Quick"), which secures every digit displayed. Scaling by diag(JᵀJ) itself makes the step independent of the parameters' units, even for a parameter whose effect per unit is tiny (a Y0 that must reach 10¹⁵ to multiply exp(−35)).

Status. The "Status" row is "Not converged" (1000 iterations reached), "Perfect fit" (sum of squares ≤ 10⁻²⁰ times the total sum of squares of Y: the curve passes exactly through the points), "At a bound" (a parameter stopped on one of its bounds), "Ambiguous" (a parameter has a dependency above 0.9999 or the matrix JᵀJ is not invertible: the data do not determine all the parameters), otherwise "Converged".

Weighting. The weights wi are:

"No weighting"         wi = 1
"Weights 1/Y²"       wi = 1 / Ŷi²          Ŷi = value of the curve at xi
"Weights 1/Y^K"      wi = 1 / |Ŷi|^K
"Weights 1/X"        wi = 1 / |xi|
"Weights 1/X²"       wi = 1 / xi²
"Weights 1/SD²"      wi = 1 / SDi²         SDi = standard deviation of row i

The Y weights use the value of the curve, not the measured value (a noisy measured value would give biased weights); they are therefore recomputed at each iteration. 1/Y² weighting is appropriate when the standard deviation is proportional to Y (constant coefficient of variation); 1/Y^K with K = 1 when the variance is proportional to Y (counts). 1/SD² requires an SD for each point: that of the replicates of the row with "The mean of the replicates only", or that of a table entered as mean and SD (or SEM and N, or %CV); with replicates considered individually, each replicate receives the 1/SD² weight of its row. A point without SD (a single value in its row, or a zero SD) prevents the fit: a message says so. With weighting, "Sum of Squares", "Sy.x", "RMSE" and "AICc" are computed on the weighted residuals: with 1/Y², Sy.x is a relative standard deviation (0.0175 means a scatter of about 1.75% of Y).

Poisson regression. For counts, Variance minimizes the Poisson deviance instead of the sum of squares (weighting is ignored):

D = Σ di        di = 2 · [ yi · ln(yi/μi) − (yi − μi) ]   (di = 2 μi if yi = 0)
μi = f(xi; θ)  (at least 10⁻¹²);  deviance residual ri = sign(yi − μi) · √di

The "Sum of Squares" row then displays the deviance, The standard errors are those of the Poisson distribution: the covariance matrix is the inverse of the Fisher information Σ (∂μi/∂θ)(∂μi/∂θ)ᵀ / μi, computed with the Jacobian of the Pearson residuals (yi − μi)/√μi at the fit (dispersion 1, like a classic Poisson regression). If the counts vary more than a Poisson distribution allows (overdispersion: Pearson χ² clearly above the df), check "Allow overdispersion (quasi-Poisson standard errors)": the covariance is then multiplied by φ = χ²/df, χ² = Σ (yi − μi)²/μi.

Robust regression. Variance first performs a least-squares fit, then repeats (at most 50 times): computation of the residuals ei; robust scale RSDR = P68 × n/(n − p), where P68 is the 68.27th percentile of the |ei| (the rank ⌈0.6827 n⌉ of the sorted |ei|); Cauchy (Lorentzian) weights ρi = 1/(1 + (ei/c)²) with c = 2.385 × RSDR; new weighted fit. It stops when no parameter changes by more than 10⁻⁸ in relative value. A very distant point receives a weight close to 0 and no longer pulls the curve. The "Sum of Squares" row is then the sum of squares weighted by ρi.

ROUT method (outliers). The ROUT method (Motulsky and Brown, 2006) combines robust regression and the false discovery rate:

  1. robust fit (above), which gives the residuals ei and the scale RSDR = P68 × n/(n − p);
  2. for each point, ti = |ei| / RSDR and Pi = two-tailed P of ti according to Student's distribution with n − p df;
  3. the residuals are sorted from largest to smallest; the point of rank i (i = 1 for the largest |ei|) is compared with the threshold Q × i / n, as in the Benjamini-Hochberg procedure. If the point of rank k is the last one whose Pk is below its threshold, the k largest residuals are declared outliers;
  4. with "Remove outliers (ROUT)", these points are removed and the curve is fitted again on the others, with the chosen method; with "Detect and flag outliers (ROUT), fit all data", they are only counted ("# outliers") and the fit uses all the points.

Q is the false discovery rate accepted among the points declared outliers: 1% is the recommended value; a larger value detects more points, at the cost of more false positives. Eliminated points appear as empty cells in the "Residuals" output table.

Standard errors and dependency. At the best fit, with J the Jacobian of the (weighted) residuals:

df = n − p                  s² = SS / df
Cov(θ) = s² · (JᵀJ)⁻¹       SE(θj) = √Cov(θ)jj
dependency(θj) = 1 − 1 / ( (JᵀJ)jj · ((JᵀJ)⁻¹)jj )

If JᵀJ, scaled to a unit diagonal (the parameters do not share their units), has an eigenvalue below 10⁻¹⁰ of the largest, the data do not determine the parameters in that direction (for example a slope that grows without end when a single point lies on the steep part of the curve: the sum of squares keeps decreasing, without a minimum); these parameters receive an infinite variance (standard error and asymptotic interval not displayed) and a dependency of 1, hence the status "Ambiguous". A pseudo-inverse would instead give them a zero variance, and an illusory precision. The dependency, between 0 and 1, measures how redundant a parameter is with the others: a value close to 1 means that other combinations of parameters describe the data almost as well. It is displayed with the "Dependency of each parameter" option ("Dependency" section, one row per parameter) and is used for the "Ambiguous" status (> 0.9999) and for the "Flag fits with a parameter dependency above" criterion.

Asymptotic confidence intervals ("Symmetric (asymptotic approximate)"):

θj ± t* · SE(θj)        t* = quantile (1 + C)/2 of Student's distribution with df degrees of freedom
                        (C = confidence level; t* = 2.045 for 95% and 29 df)

They assume that the sum of squares is a quadratic function of the parameters near the minimum; this is approximate for a nonlinear model, especially with few points.

Profile likelihood intervals ("Asymmetric (profile likelihood, recommended)", the default). For the parameter θj, the profile SSj(v) is the smallest sum of squares obtained when θj is fixed at v and all the other parameters are refitted. The bounds of the interval are the two values of v where this profile reaches

SS_target = SS_min · ( 1 + F*(1, df) / df )      F* = quantile C of the F(1, df) distribution = t*²

Variance starts from the best value and moves on each side in steps of SE × 1.6^k (at most 40 steps), without going beyond 100 × t* × SE: further out the profile is nearly flat, and where it would cross the target would depend on rounding and on the path of the refits. At each trial the other parameters are refitted (at most 1000 iterations) from their values at the last trial inside the interval; if the sum of squares reaches the target, the refit is done again from the best fit, then from the best fit with one other parameter multiplied or divided by 10, until it falls below the target, and the smallest sum of squares counts (the profile is a minimum over the other parameters: a refit can stop in another valley of the sum of squares, for example towards an infinite slope, and a lower valley can lie far from the path followed, especially with 1/Y² weighting and few points). The bound is then bracketed by bisection (relative precision 10⁻⁷), each refit starting from the last inside trial. It is kept only if a last refit at the outer end of the bracket, started from the nearest inside trial, confirms that the target is reached there; otherwise the search resumes outwards (a refit started far away can stop short of the minimum, when the effect of a parameter on the curve has fallen below rounding and its numerical derivative is zero). If the bound is not reached (constraint met, curve that cannot be computed, or 100 × t* × SE reached), it is unknown: the cell displays "???" in its place (for example "??? to 4.419"), or "(Very wide)" if both bounds are missing. These intervals can be asymmetric and are more reliable than asymptotic intervals (Bates and Watts, 1988). After a robust regression, the profile is computed by least squares with the final robust weights.

Derived parameters. A derived parameter that depends on a single free parameter (EC50 = 10^LogEC50, HalfLife = ln(2)/K) receives as its interval the transformation of the bounds of that parameter: for example [10^lower bound, 10^upper bound] for EC50. If it depends on several free parameters, its interval cell is empty.

Confidence and prediction bands. At each point x of the curve, with g the gradient of f with respect to the parameters (central differences):

Var(Ŷ(x)) = gᵀ · Cov(θ) · g
confidence band:  Ŷ(x) ± t* · √( gᵀ Cov(θ) g )
prediction band:  Ŷ(x) ± t* · √( gᵀ Cov(θ) g + s² / w(x) )

At each X, the confidence band contains the true value of the curve with probability C (pointwise band: the probability does not hold for the whole curve at once); the prediction band, wider, contains a new point at each X with probability C. The prediction band adds the variance of a new point, s²/w(x), where s² is the (weighted) residual variance of the fit and w(x) the weight a point at x would have (1 without weighting, 1/Ŷ(x)² with 1/Y², 1/x² with 1/X², etc.). With "Weights 1/SD²", the SD of a new point is unknown: the prediction band is not drawn, and a warning says so.

Goodness of fit. For each data set, on the fitted points (without eliminated outliers):

R squared = 1 − Σ ei² / Σ (yi − ȳ)²           (unweighted residuals ei = yi − Ŷi)
Sy.x      = √( SS / df )
RMSE      = √( SS / n )
AICc      = n · ln(SS/n) + 2K + 2K(K + 1) / (n − K − 1)      K = p + 1

K counts the free parameters plus one for the variance. In a global fit, "Degrees of Freedom", "Sum of Squares", "Sy.x", "RMSE" and "AICc" are those of the whole (same value in each column), whereas "R squared" is computed for each data set.

Diagnostics: runs test ("Runs test"). The residuals are ordered by increasing X (replicates of the same X in the order of the subcolumns); with n1 positive residuals, n2 negative residuals and R runs, P is the exact probability of observing R runs or fewer if the signs followed one another at random (calculation in chapter 16). Too few runs signals points that stay on the same side of the curve over ranges of X: the model does not follow the shape of the data.

Diagnostics: normality of residuals. D'Agostino-Pearson omnibus test (chapter 10), from 8 residuals ("Too few values" otherwise).

Diagnostics: replicates test (lack of fit). With k distinct X values and replicates, the scatter of the replicates around their mean (pure error) is compared with the scatter around the curve:

SSpe = Σ_groups Σ (y − ȳgroup)²             df_pe   = n − k
SSlack = SS − SSpe                          df_lack = k − p
F = (SSlack / df_lack) / (SSpe / df_pe)     P = P(F(df_lack, df_pe) ≥ F)

A small P means that the means deviate from the curve more than the scatter of the replicates explains: the model is inadequate. Without replicates, the cell displays "No replicates"; with weighting, "Not available with weighting". SS and p are those of the data set: the sum of squares of its residuals and its free parameters (in a global fit, shared parameters count for each data set).

Diagnostics: Breusch-Pagan test of homoscedasticity. Regression of the squared residuals ei² on the fitted values Ŷi; with R² of this regression, the statistic n · R² follows a χ² distribution with 1 df (Koenker's studentized form). A small P means that the scatter varies with Y (consider weighting). At least 5 points are required.

Diagnostics: Hougaard's skewness. For each parameter, with L = (JᵀJ)⁻¹, Jtj = ∂f(xt)/∂θj and Wjkl = Σt Jtj · ∂²f(xt)/∂θk∂θl (numerical derivatives; with weighting, the derivatives of each point are multiplied by the square root of its weight),

g(θi) = − s⁴ · Σj Σk Σl Lij Lik Lil (Wjkl + Wkjl + Wljk) / (s² · Lii)^(3/2)

This is the skewness of the sampling distribution of the estimator. Interpretation ("Interpretation" row, after Ratkowsky): |g| < 0.1, nearly linear behavior; 0.1 to 0.25, reasonable; > 0.25, prefer profile intervals; > 1, strongly nonlinear (consider another parameterization, for example LogEC50 rather than EC50).

Comparison of two models (Compare tab). The two models are fitted to the same points of each data set, those of the main fit (without eliminated outliers). Model 1 keeps its constraints and initial values; after a global fit (shared parameters), it is refitted to each data set alone, which a "Note" row indicates. Model 2 ("Alternative equation (model 2)") receives its automatic initial values and the lines of the Constrain tab that name its own parameters. The "simpler" model is the one with the fewest free parameters.

Extra sum-of-squares F test (nested models):
F = ( (SS1 − SS2) / (df1 − df2) ) / ( SS2 / df2 )
P = P( F(df1 − df2, df2) ≥ F )          1 = simple model, 2 = complex model

AICc:
Δ = AICc(complex) − AICc(simple)
probability that the simple model is correct = e^(Δ/2) / (1 + e^(Δ/2))

With the F test, the complex model is preferred if P < α, the "Significance level (alpha) of the F tests" threshold of the Compare tab (0.05 by default); with AICc, the simple model is preferred if its probability reaches 50%. The F test is valid only if the simple model is a special case of the complex one (nested models, for example HillSlope fixed at 1); if both models have the same number of parameters, the F test does not apply: "Preferred model" says "Same number of parameters: no F test" and F and P stay empty. AICc uses the number of fitted points. AICc also compares non-nested models.

Comparison of data sets ("Compare the data sets"). Variance fits each data set separately, with all its parameters (sum SSsep of the sums of squares, sum dfsep of the df), then all the data sets together, sharing either all the parameters ("Single curve for all data sets") or the named parameter ("Does the value of a parameter differ between data sets?"): sum of squares SSglob and dfglob. Sharing is the null hypothesis; the extra sum-of-squares F test compares it with the model of the separate fits:

F = ( (SSglob − SSsep) / (dfglob − dfsep) ) / ( SSsep / dfsep )
P = P( F(dfglob − dfsep, dfsep) ≥ F )

These fits use the method, weighting, constraints and initial values of the analysis (for a shared parameter, the automatic rules apply to all the points together), on the points of the main fit (without eliminated outliers). The conclusion compares P with the α threshold of the Compare tab. At least two data sets are required.

Interpolation. For each row that has a Y value (mean of the replicates) but no X, Variance looks for X such that f(X) = Y between Xmin − 10% and Xmax + 10% of the X range of the data set: it scans this interval in 400 steps, stops at the first sign change of f(X) − Y and refines the root with Brent's method. The confidence interval of X is formed by the abscissas where the horizontal line of ordinate Y crosses the two confidence bands of the curve (Ŷ(x) ± half-width = Y). It reflects the uncertainty of the curve, not the scatter of the measurement of the unknown itself.

Reading the results#

"Main results" tab, one column per data set; the first row recalls the name of the model.

  • "Fitted parameters": the best value of each parameter ("= value" for a fixed parameter), then the derived parameters (EC50, HalfLife…). A value only has meaning together with its confidence interval.
  • "Std. Error": asymptotic standard errors of the free parameters.
  • "95% CI (profile likelihood)" or "95% CI (asymptotic)" (the percentage follows the chosen level): intervals of the free parameters and of the derived parameters. A very wide interval, "???" or "(Very wide)" signals a parameter poorly determined by the data.
  • "Goodness of Fit": "Degrees of Freedom" (n − p), "R squared", "Sum of Squares", "Sy.x" (standard deviation of the points around the curve, in the unit of Y without weighting), "RMSE" and "AICc". R² measures the share of the variance of Y followed by the curve; a high R² does not prove that the model is right (a wrong curve can give 0.94, see the example) and it is not used to compare models. AICc has no meaning on its own: it is used to compare models fitted to the same data.
  • "Number of points": "X values" (distinct X values), "Y values analyzed" (points used, without eliminated outliers) and, with ROUT, "# outliers".
  • "Status": "Converged", or a warning (see Calculations) that should make you look closely at the curve.
  • Depending on the options: "Diagnostics" with "Homoscedasticity P (Breusch-Pagan)", "Runs test P value", "Residuals normality P (D'Agostino-Pearson)" and "Replicates test P (lack of fit)"; "Hougaard's skewness" (one row per parameter, then "Interpretation"); "Flags" with "Flagged?" ("No", or "Yes:" followed by the reasons, for example "R² < 0.9; runs test failed").

Other tabs: "Interpolated X values" (columns "Y", "X" and "95% CI", one section per data set; "Out of range" if the Y value is not reached by the curve); "Comparison of models" ("Model 1: …", "Model 2: …", "Note" after a global fit, "Preferred model", then "F", "DFn", "DFd", "P value" or "AICc (simpler model)", "AICc (more complex model)", "Probability simpler model is correct (%)", and "SS (simpler model)", "SS (more complex model)"); "Comparison of data sets" ("Value" column: the question asked, "Null hypothesis", "Alternative hypothesis", "P value", "Conclusion at α = 0.05" (with the chosen threshold), "Preferred model", "F", "DFn", "DFd", the parameters of the shared fit under "Curve shared by all data sets" or "Shared value", then "Sums of squares": "SS (shared parameters)", "SS (separate fits)", "DF (shared parameters)", "DF (separate fits)").

According to the choices of the Output tab: "Summary of LogEC50" (for example; columns of the parameter and "Std. Error", one row per data set) with its output table of the same name; "Ki (Cheng-Prusoff)" ("IC50", "Ki", "LogKi", the confidence interval of Ki, then the concentration and the Kd used); "Dose ratios" ("EC50", "log[Antagonist]", "Dose ratio", "log(Dose ratio - 1)" for each data set, then "Schild slope", "pA2 (minus the X-intercept)" and "Number of points") with the "Schild plot" output table. A warning at the top of the results explains what is missing (parameter not found, titles that are not numbers, concentrations not entered, fewer than two antagonist concentrations).

"Residuals" output table ("Table of residuals" option, checked by default): an XY table whose X column repeats the X of the points and in which each data set (for example "Control residuals") contains the unweighted residuals yi − Ŷi. Plot it (Plot These Results): the residuals should form a horizontal band centered on 0.

On the data graph, each data set receives its curve (for example "Control fit") and, if requested, its bands.

The last tab, "Narrative results", states in sentences, for each data set, the share of the variance followed by the curve (R²) and the status of the fit, then, according to the Compare tab, the preferred model (with the P value of the F test or the probability of the AICc) or the comparison of the data sets (one curve for all, or a shared parameter).

Worked example#

The data. XY example "Dose-response (log dose, replicates)": 11 agonist concentrations, from 10⁻⁹ to 10⁻⁴ M, entered as logarithms (X from −9 to −4 in steps of 0.5), response measured in triplicate, without antagonist ("Control") and in the presence of an antagonist ("With antagonist").

The fit. Analysis › Curves and Regression › Nonlinear Regression, default options ("Agonist, log dose, variable slope (4PL)", least squares, profile intervals). Both fits converge ("Converged"), with n = 33 points and 33 − 4 = 29 df:

ParameterControl95% CIWith antagonist95% CI
Bottom2.2790.363 to 4.1102.1660.858 to 3.449
Top101.499.96 to 103.099.4196.82 to 102.2
LogEC50−6.780−6.819 to −6.740−5.605−5.649 to −5.558
HillSlope1.0410.956 to 1.1361.0710.975 to 1.177
EC50 (M)1.661 × 10⁻⁷1.517 to 1.818 × 10⁻⁷2.485 × 10⁻⁶2.242 to 2.765 × 10⁻⁶
R squared0.99760.9969
Sum of Squares135.4145.8
Sy.x2.1612.242
AICc58.8161.26

The initial values ("No fit" method) were, for Control: Bottom = 2.009 (smallest Y), Top = 103.6 (largest Y), LogEC50 = −7 (the Y closest to (2.009 + 103.6)/2 = 52.80 is 40.97, at X = −7) and HillSlope = 1.

Check by hand (Control). With SS = 135.415:

Sy.x  = √(135.415 / 29) = √4.6695 = 2.161          RMSE = √(135.415 / 33) = 2.026
AICc  = 33 · ln(135.415/33) + 2·5 + 2·5·6/(33 − 5 − 1)
      = 33 × 1.41184 + 10 + 2.222 = 58.81                 (K = 4 + 1 = 5)
Asymptotic CI of LogEC50: −6.7796 ± 2.0452 × 0.019222 = −6.819 to −6.740
profile: SS_target = 135.415 × (1 + 4.1830/29) = 154.95 → −6.8191 to −6.7404
EC50  = 10^−6.7796 = 1.661 × 10⁻⁷ M (166 nM); CI: 10^−6.8191 to 10^−6.7404 = 152 to 182 nM

The two intervals of LogEC50 almost coincide: Hougaard's skewness of LogEC50 is minimal (−0.0099), whereas the interval of the EC50 itself is asymmetric (166 − 152 = 14 nM on one side, 182 − 166 = 16 nM on the other).

Diagnostics (the five boxes checked):

DiagnosticControlWith antagonist
Runs test P value0.50000.5174
Residuals normality P (D'Agostino-Pearson)0.20240.0381
Replicates test P (lack of fit)0.67220.7354
Homoscedasticity P (Breusch-Pagan)0.01060.3573
Hougaard's skewness, the largest (HillSlope)0.1420.154

The replicates test can be checked by hand for Control: the sum of squares of the replicates around their mean is SSpe = 110.76 (33 − 11 = 22 df), hence SSlack = 135.42 − 110.76 = 24.65 (11 − 4 = 7 df) and F = (24.65/7)/(110.76/22) = 3.522/5.035 = 0.699, P = 0.67: the means do not deviate from the curve more than the scatter of the replicates predicts. The runs test (17 runs for 16 positive and 17 negative residuals) flags nothing either. Two P values are below 0.05: normality for With antagonist (two replicates are exactly 0 at the bottom of the curve) and homoscedasticity for Control, whose triplicates are more scattered at the top of the curve (standard deviation of 2.2 to 3.3 for X ≥ −6) than at the bottom (0.1 to 2.2 for X ≤ −7.5). Among these eight tests, one or two P < 0.05 may occur by chance; 1/Y² weighting would be excessive here, because it would assume a standard deviation tens of times larger at the top (Y ≈ 100) than at the bottom (Y ≈ 3). Hougaard's skewness values are all below 0.25: the intervals are reliable.

Are three parameters enough? Compare tab, "Extra sum-of-squares F test", model 2 "Agonist, log dose, slope 1 (3 parameters)" (HillSlope fixed at 1). For Control, SS goes from 139.778 (3 parameters, 30 df) to 135.415 (4 parameters, 29 df):

F = ((139.778 − 135.415) / (30 − 29)) / (135.415 / 29) = 4.3626 / 4.6695 = 0.934
P = 0.3417 (F with 1 and 29 df)          With antagonist: F = 2.240, P = 0.1453
AICc: 57.07 (3 parameters) versus 58.81; Δ = 1.747
probability that the 3-parameter model is correct = e^0.874 / (1 + e^0.874) = 70.55%
                                      (With antagonist: 60.92 versus 61.26, 54.21%)

"Preferred model" indicates the three-parameter model for both data sets. The data are compatible with a Hill slope equal to 1 (the HillSlope intervals contain 1), but a P > 0.05 does not prove that the slope is exactly 1.

Does the antagonist change the EC50? Compare tab, "Does the value of a parameter differ between data sets?", parameter LogEC50. The separate fits total SSsep = 135.415 + 145.817 = 281.232 (58 df); with a common LogEC50, SSglob = 4968.4 (59 df): F = (4968.4 − 281.23)/(281.232/58) = 4687.2/4.849 = 966.7, F(1, 58), P < 0.0001. The difference is massive: the LogEC50 values differ by 1.175 log units, an EC50 ratio of 10^1.175 = 15. With the HillSlope parameter, on the other hand, F = (282.230 − 281.232)/4.849 = 0.206, P = 0.6517 (common slope 1.055); with Top, F = 1.772, P = 0.1884; and "Single curve for all data sets" gives F = 783.8 (4, 58), P < 0.0001. A parallel shift of the curve, without change of slope or maximum, is what you expect from a competitive antagonist. To estimate the parameters with a common slope, add the constraint HillSlope shared: the global fit gives HillSlope = 1.055 (95% CI 0.992 to 1.123), with 66 − 7 = 59 df.

A local minimum. Type the same equation in "Custom equation": Y = Bottom + (Top-Bottom)/(1+10^((LogEC50-X)*Slope)) (Control data set). Lacking a specific rule, Slope starts from the slope of the least-squares line, 24.88. The fit stops in another valley: Slope = 223.2 (a vertical staircase step at X = −7), Sum of Squares = 3085 instead of 135.4, status "Ambiguous", Slope interval "(Very wide)"… and yet R² = 0.9448. With Slope = 1 in the Initial values tab, or by naming the parameter HillSlope (which then starts at 1), you get exactly the library result back.

An outlier. In Control, replace the first replicate of X = −7 (36.67) with 60. Without treatment, LogEC50 = −6.853 and Sy.x = 4.045. With "Remove outliers (ROUT)" and Q = 1%, "# outliers" is 1 and "Y values analyzed" 32: the curve, fitted without this point, gives LogEC50 = −6.789 (−6.831 to −6.747) and Sy.x = 2.142, close to the original values. In the robust fit, the residual of this point is 19.81 and RSDR = 2.397: t = 8.27 (29 df), P ≈ 4 × 10⁻⁹, far below the threshold 0.01 × 1/33 = 0.0003. The next residual (4.21; t = 1.76; P = 0.090) stays well above its threshold (0.01 × 2/33 = 0.0006): a single point is declared an outlier.

Weighting. With the "Enzyme velocity vs. substrate" example (8 substrate concentrations in duplicate) and the "Michaelis-Menten" equation, the fit without weighting gives Vmax = 119.8 and Km = 5.974 µM (95% CI 5.669 to 6.294), Sy.x = 1.202. But the difference between duplicates grows with velocity (0.13 at X = 0.5; 3.6 at X = 32): the scatter is roughly proportional to Y, and "Weights 1/Y²" weighting is more appropriate: Vmax = 119.7, Km = 5.943 µM (5.761 to 6.132), and Sy.x = 0.0175, a scatter of about 1.75% of Y. The Km interval is narrower, because the precise points at low concentrations carry more weight.

Writing up the results#

"The concentration-response curves were fitted by nonlinear regression (four-parameter logistic model, least squares, Variance; 11 concentrations in triplicate). Without antagonist, LogEC50 = −6.78 (95% profile likelihood CI −6.82 to −6.74), that is EC50 = 166 nM (152 to 182 nM), Hill slope 1.04 (0.96 to 1.14). The antagonist shifted the curve to the right (LogEC50 = −5.60; −5.65 to −5.56; EC50 ratio = 15; extra sum-of-squares F test, F(1, 58) = 966.7, P < 0.0001) without changing the slope (F(1, 58) = 0.21, P = 0.65) or the maximum (F(1, 58) = 1.77, P = 0.19)."

Always state the equation, the method (weighting, constraints, parameter sharing, outlier handling), the number of points and the method of the intervals.

Common pitfalls#

  • Not looking at the curve. A "Converged" status and a high R² rule out neither a local minimum nor an inadequate model (see the example: R² = 0.94 for a wrong curve).
  • Undefined plateaus. Without doses low enough or high enough, Bottom or Top are poorly determined: huge intervals, "Ambiguous" status. Fix the plateau at a value justified by controls (Bottom = 0), or extend the dose range.
  • An equation that does not match X. The "log(…)" equations expect the logarithm of the concentrations in X; the "[Agonist]" and "X is concentration" equations expect the concentrations. A zero concentration has no logarithm: the corresponding row cannot be used with a log equation.
  • Choosing the model by R²: a model with more parameters always has a smaller sum of squares. Compare with the F test (nested models) or AICc.
  • Non-independent replicates treated as independent points: the intervals are falsely narrow. Use the mean of each point ("The mean of the replicates only").
  • A model too rich for the data (two sites, two phases, five parameters with ten points): absurd parameters, "Ambiguous" status, "(Very wide)" intervals.
  • Eliminating points for no reason. ROUT should remain a safeguard decided before the analysis, with a low Q (1%); always report the number of points eliminated.
  • Choosing the weighting after the fact, to improve the result. It should reflect what is known about the variability of the measurement.
  • Extrapolating the curve beyond the measured X: nothing guarantees that the model remains valid there.
  • Forgetting the units: the EC50 is in the unit of 10^X (in M if X is the log of molar concentrations); a rate constant K is in inverse units of X.

Standard Curve Interpolation#

A calibration curve relates a measured signal (absorbance, fluorescence, radioactivity, Ct) to known quantities (the standards). The Standard Curve Interpolation analysis fits a model to the standards, then reads off the curve the quantity X of each unknown sample from its signal Y, with a confidence interval. It is the same analysis as Nonlinear Regression, with two different defaults: the equation "Standard curve: 4PL, log dose" and the "Interpolate the unknowns on the standard curve" box checked. All the options described above (weighting, constraints, ROUT, intervals, diagnostics) therefore apply.

When to use it#

  • Immunoassays (ELISA, RIA), protein assays (Bradford, BCA), calibration curves for qPCR, chromatography, spectrophotometry…
  • Choose the model according to the shape of the calibration curve, preferably from the "Standard curves" family: "Standard curve: line" in the linear range of an assay; "Standard curve: quadratic" for slight curvature; "Standard curve: 4PL, log dose" or its asymmetric five-parameter version for immunoassays, which give a sigmoid in logarithmic X; "Standard curve: hyperbola" for saturation.
  • For a straight line, Simple Linear Regression (chapter 16) also offers interpolation.
  • Do not use it for samples whose signal falls outside the range of the standards: dilute them and assay them again.

Assumptions and checks#

  • The model describes the standards correctly over the whole range: look at the curve and the residuals, check "Runs test"; with standards in replicates, "Lack-of-fit test (replicates)".
  • The unknowns are measured under the same conditions as the standards (same plate, same matrix, same dilution or dilution taken into account).
  • The signal of the unknown is within the range of the standards. Variance only searches for the solution between the smallest and the largest X value of the standards, extended by 10% of their range on each side; beyond that, it displays "Out of range". Between the ends and these 10%, it is already an extrapolation, which is unreliable.
  • The curve is monotonic over the range (always increasing or always decreasing). Otherwise, several X values give the same Y; Variance keeps the first solution met when starting from the small X.
  • The assumptions of regression (normal scatter, homoscedasticity or suitable weighting, independence) apply to the fit of the standards; immunoassays often have a scatter that grows with the signal (consider 1/Y² weighting).

Step by step in Variance#

  1. Create an XY table. In the first rows, enter the standards: the known quantity in X (its logarithm if the name of the equation says "log dose"), the signal in Y (replicates accepted). In the following rows, enter the unknowns: empty X, signal in Y in the same data set as the standards (if there are replicates, their mean is interpolated). Give a title to each unknown row (row labels column): it will identify the sample in the results (otherwise "Row n"). Rows without X do not take part in the fit.
  2. Choose Analysis › Curves and Regression › Standard Curve Interpolation (or Analyze, then "Standard Curve Interpolation" in the "Choose an Analysis" window).
  3. The "Standard Curve Interpolation – settings" window has the same tabs as that of Nonlinear Regression. Model tab: choose the equation (default "Standard curve: 4PL, log dose"); "Interpolate the unknowns on the standard curve" is checked. Options tab: "Confidence level (%)" sets the level of the interval of the interpolated X. The other tabs are set as for a nonlinear regression (for example weighting in the Method tab, confidence bands in the Confidence tab to visualize the uncertainty of the curve).
  4. Data sets tab: check the data set or sets that contain standards and unknowns (each data set has its own curve and its own unknowns).
  5. Click OK.

Calculations#

The fit of the standards is that of Nonlinear Regression (least squares by the Levenberg-Marquardt algorithm, see above). For each unknown with signal Y:

Interpolated X: solution of f(X; θ̂) = Y, searched between Xmin − 0.1·(Xmax − Xmin)
                and Xmax + 0.1·(Xmax − Xmin): scan in 400 steps, first sign change
                of f(X) − Y, then Brent's method (tolerance 10⁻¹²)

interval:       abscissas where f(X) + h(X) = Y and where f(X) − h(X) = Y
                h(X) = t* · √( gᵀ Cov(θ) g )   (half-width of the confidence band)

The computation is numerical for all the equations, but it gives back the inverse formula when one exists. For the four-parameter model:

X = LogEC50 − log( (Top − Bottom) / (Y − Bottom) − 1 ) / HillSlope

The confidence interval of X does not depend on the method chosen for the parameter intervals: it always comes from the asymptotic confidence bands. It reflects the uncertainty of the calibration curve, but not the variability of the measurement of the unknown (nor its replicates): the total uncertainty on the quantity of a sample is larger. If a band is not crossed within the search interval, the cell displays "(Very wide)".

Reading the results#

  • The "Main results" tab gives the fit of the calibration curve, as for a nonlinear regression: check the status, the curve, the residuals.
  • The "Interpolated X values" tab has three columns, "Y" (signal of the unknown), "X" (interpolated value) and "95% CI" (the label follows the confidence level), with one section per data set and one row per unknown, titled after the row label. "Out of range" flags a signal outside the range.
  • If X is a logarithm, the quantity is 10^X, and its interval [10^lower bound, 10^upper bound] (asymmetric). Variance does not perform this transformation: do it yourself (or with a computed column).

Worked example#

Data: XY example "Dose-response (log dose, replicates)", "Control" data set, used as a calibration curve (11 standards from 10⁻⁹ to 10⁻⁴ M, in triplicate, X = log of the concentration). Add three rows at the end of the table, titled "Unknown 1", "Unknown 2" and "Unknown 3", without X, with the signals 25, 50 and 80 in the first subcolumn of Control. Run Standard Curve Interpolation with the default options (Control data set checked).

The fit is that of the previous example: Bottom = 2.2792, Top = 101.4364, LogEC50 = −6.7796, HillSlope = 1.04134. The "Interpolated X values" tab gives:

UnknownYX (log M)95% CI of XConcentration 10^X95% CI
Unknown 125−7.286−7.330 to −7.24251.8 nM46.7 to 57.3 nM
Unknown 250−6.811−6.841 to −6.781154.6 nM144.1 to 165.7 nM
Unknown 380−6.242−6.287 to −6.196572 nM516 to 637 nM

Check by hand for Y = 50.

(Top − Bottom)/(Y − Bottom) − 1 = 99.1573 / 47.7208 − 1 = 1.07786
log(1.07786) = 0.032562        0.032562 / 1.04134 = 0.031270
X = −6.7796 − 0.0313 = −6.8109          10^−6.8109 = 1.546 × 10⁻⁷ M

The interval can be roughly recovered: at X = −6.811, the half-width of the confidence band is h = 1.795 (units of Y) and the slope of the curve is 59.36 units of Y per log unit; ΔX ≈ 1.795/59.36 = 0.030, hence −6.841 to −6.781. Note that Y = 50 does not correspond exactly to LogEC50 (−6.780): the middle of the curve is (Bottom + Top)/2 = 51.86, not 50. The interval is narrowest in the middle of the curve, where it is steepest, and widens toward the plateaus, where a small difference in Y corresponds to a large difference in X.

Writing up the results#

"The concentrations were determined by interpolation on a four-parameter logistic calibration curve (11 standards in triplicate, X = log of the concentration, least squares; Variance). Sample 2 contained 155 nM (95% CI 144 to 166 nM; the interval accounts only for the uncertainty of the calibration curve)."

Common pitfalls#

  • Unknowns in another data set: they must be in the same data set as the standards, without an X value; a data set that contains only unknowns has no curve and is ignored.
  • Forgetting to return to the original scale when X is a logarithm (10^X), or forgetting the dilution factor of the sample.
  • Extrapolating: a signal beyond the last standard gives an unreliable value or "Out of range". Dilute and assay again.
  • Interpolating on a plateau: near Bottom or Top, the curve is almost horizontal and the interval of X becomes huge; the useful zone of a sigmoidal assay is its central part.
  • Judging the curve by R²: an R² of 0.999 does not rule out a systematic error at one end. Check trueness by also entering the signal of a few standards as unknowns: the back-calculated concentration should be close to the nominal value.
  • Underestimating the uncertainty: the displayed interval ignores the scatter of the measurement of the unknown; measure the unknowns in replicates and report their variability.

Smoothing Curve (Spline, LOWESS)#

The Smoothing Curve (Spline, LOWESS) analysis draws a smooth curve through the points, or close to them, without a model: natural cubic spline, Akima spline, regression spline (smoothing), LOWESS or a simple broken line. It estimates no parameter and performs no test: it is a descriptive tool, which gives a curve on the graph and an output table of its coordinates, reusable in other analyses (area under the curve, derivative…).

When to use it#

  • To show the shape of the data without a mechanistic model, or before choosing one.
  • To join precise points with a regular curve (cubic or Akima spline), for example a calibration curve without a simple equation, whose values you then read in the output table.
  • To bring out a trend in a large number of noisy points (LOWESS, regression spline).
  • Do not use it to estimate a quantity with its precision or to compare conditions: you need a model (Nonlinear Regression).

Assumptions and checks#

  • There is neither a statistical model nor a test, so no assumption to check in the strict sense; but each method has its requirements.
  • Interpolating splines (cubic, Akima) and the broken line pass exactly through each point (the mean of the replicates): they reproduce the noise. They are only suitable for precise data.
  • Smoothing methods (regression spline, LOWESS) attenuate the noise, but the degree of smoothing (number of knots, fraction of points) is a user choice that changes the curve: choose it before looking at the result, and report it.
  • LOWESS needs many points (several dozen); with few points, its robust iterations may discard legitimate points (see the example).
  • The curve is drawn only between the smallest and the largest X value: there is no extrapolation.

Step by step in Variance#

  1. Create an XY table (X in the X column, one curve per data set). If a data set has replicates, Variance uses the mean of each row; for the interpolating splines and the broken line, rows that have the same X are in addition averaged. To follow the example: XY example "Exponential decay (time course)".
  2. Choose Analysis › Curves and Regression › Smoothing Curve (Spline, LOWESS) (or Analyze, then "Smoothing Curve (Spline, LOWESS)" in the "Choose an Analysis" window).
  3. The "Smoothing Curve (Spline, LOWESS) – settings" window opens on the Options tab:
    • "Method": "Cubic spline (natural)" (default), "Akima spline", "Smoothing spline (regression spline)", "LOWESS" or "Point to point (straight segments)";
    • "Number of knots (smoothing spline)" (4 by default, from 1 to 50): number of interior knots of the regression spline;
    • "LOWESS smoothing (fraction of points)" (0.33 by default, from 0.05 to 1): fraction of the points used for each local regression;
    • "Points defining the curve" (200 by default, from 10 to 5000): number of evenly spaced points that describe the curve;
    • "Create a table of the curve" (checked): creates the "Curve" output table;
    • "Significant digits" and "P value format".
  4. Data sets tab: check the data sets to process (at least two distinct points are required per data set; a data set that does not have enough is ignored).
  5. Click OK: the curve of each data set is added to the data graph.

Calculations#

For each data set, the points (xi, yi) are sorted by increasing X (i = 1 … n): the replicate means for the interpolating splines and the broken line, each replicate for the regression spline and LOWESS, which smooth a scatter of points and the curve is evaluated at N evenly spaced points (N = "Points defining the curve"): xk = Xmin + (Xmax − Xmin) · k/(N − 1), k = 0 … N − 1.

Natural cubic spline. A degree-3 polynomial between two consecutive points, joined so that the curve and its first and second derivatives are continuous; the second derivative is zero at both ends (the "natural" condition). With hi = xi+1 − xi, the second derivatives Mi at the points solve the tridiagonal system

h(i−1) · M(i−1) + 2 · (h(i−1) + hi) · Mi + hi · M(i+1) = 6 · [ (y(i+1) − yi)/hi − (yi − y(i−1))/h(i−1) ]
M1 = Mn = 0
between xi and xi+1:  S(x) = a·yi + b·y(i+1) + [ (a³ − a)·Mi + (b³ − b)·M(i+1) ] · hi² / 6
                      a = (x(i+1) − x)/hi ,  b = 1 − a

Akima spline (Akima, 1970). A Hermite cubic between two points, whose slope ti at each point is an average of the slopes of the neighboring segments, weighted to follow the smoother side. With mi the slope of the segment [xi, xi+1]:

ti = ( |m(i+1) − mi| · m(i−1) + |m(i−1) − m(i−2)| · mi ) / ( |m(i+1) − mi| + |m(i−1) − m(i−2)| )

(simple average of m(i−1) and mi if the denominator is zero; at the ends, two additional slopes are extrapolated linearly). It oscillates much less than the cubic spline between irregular points. With fewer than three points, Variance joins the points with segments.

Regression spline ("Smoothing spline (regression spline)"). A cubic spline fitted by least squares on the truncated power basis, with K interior knots placed at the k/(K + 1) quantiles of X (k = 1 … K):

S(x) = b0 + b1·x + b2·x² + b3·x³ + Σk ck · max(x − knotk, 0)³

At least K + 4 points are needed in each data set a data set that has fewer is left aside, and a warning at the top of the results names it ("… : not enough data: too few points for this number of knots"); the analysis stops only if no data set can be processed. This is not a penalized smoothing spline: the smoothing is set by the number of knots (fewer knots, smoother curve).

LOWESS (Cleveland, 1979). At each point xi, a weighted linear regression is fitted on the r nearest points, r = ⌈f · n⌉ (between 2 and n, f = chosen fraction), with the tricube weights wj = (1 − (dj/h)³)³ for dj < h (0 beyond), dj = |xj − xi|, h = distance to the r-th neighbor; the smoothed value is the local line evaluated at xi. Then three robust iterations: with ej the residuals and s their median absolute value, each point receives the bisquare weight (1 − (ej/(6s))²)² (0 if |ej| ≥ 6s), which multiplies the tricube weights. Between the points, the curve joins the smoothed values with segments.

Broken line ("Point to point (straight segments)"). Linear interpolation between consecutive points.

Reading the results#

  • "Summary" tab: one row per data set, with the columns "Method" (the name of the method, as in the "Method" list) and "Points" (number of points used: the replicate means for the interpolating splines and the broken line, all the replicates for the regression spline and LOWESS).
  • "Curve" output table ("Create a table of the curve" option): the X column spans the X range of all the data sets ("Points defining the curve" evenly spaced values), and each data set has a column of values of its curve, empty outside its X range. It can be plotted, analyzed (for example Area Under Curve) or consulted to read Y at a given X.
  • On the graph, each data set receives its curve, named after the data set and the method code ("Concentration cubic", for example).
  • There is no parameter, no standard error and no R².

Worked example#

Data: XY example "Exponential decay (time course)" (concentration measured in duplicate every hour, from 0 to 11 h). Variance works on the 12 means: 100.75, 72.74, 56.135, 41.56, 31.045, 26.15, 21.65, 17.175, 16.035, 15.295, 12.46, 13.32.

Interpolating splines. With "Points defining the curve" = 23 (one point every half hour), the "Curve" table gives at X = 0.5: 85.63 for the cubic spline, 84.82 for the Akima spline and 86.745 for the broken line ((100.75 + 72.74)/2). All three curves pass through the 12 means. For the cubic spline, the tridiagonal system gives M1 = 0 and M2 = 17.761 (second derivative at X = 1), hence, with a = b = 0.5 and h = 1:

S(0.5) = 0.5 × 100.75 + 0.5 × 72.74 + [ (0.125 − 0.5) × 0 + (0.125 − 0.5) × 17.761 ] × 1/6
       = 86.745 − 1.110 = 85.635

The following second derivatives change sign several times (−2.61, 4.88, 7.47, −1.03…): the spline follows the noise of the measurements and undulates slightly.

Regression spline. The 24 replicates are used ("Points" = 24). With 4 knots, placed at the 0.2, 0.4, 0.6 and 0.8 quantiles of the 24 X values (2, 4, 7, 9 h; for example (24 + 1) × 0.2 = 5: the fifth of the sorted X values, 0, 0, 1, 1, 2…, is 2), the curve no longer passes exactly through the points: 100.71 at X = 0 (measured mean 100.75), 73.06 at X = 1 (72.74), 55.31 at X = 2 (56.135).

LOWESS. The 24 replicates are used: with the default fraction (0.33), each local regression covers r = ⌈0.33 × 24⌉ = 8 points. The curve is 100.06 at X = 0 (measured mean 100.75) and 77.28 at X = 1 (72.74): the local line smooths the strong curvature at the start of the decay. With a fraction of 0.6 (r = 15), the curve starts at 82.43 instead of 100.75. On such a curved decay, LOWESS therefore distorts the curve; a spline, or better the "Exponential decay, one phase" model of nonlinear regression (half-life 1.93 h, 95% CI 1.83 to 2.04 h), is much more suitable.

Writing up the results#

"The kinetics are shown by a natural cubic spline passing through the means (Variance), for descriptive purposes only." For smoothing, specify the method and its setting: "trend estimated by LOWESS (smoothing fraction 0.5, local linear regression, three robust iterations)".

Common pitfalls#

  • Mistaking a spline for a model: it gives no parameter, no confidence interval and no test; you cannot compare two conditions with it.
  • The oscillations of the cubic spline between irregular or noisy points: prefer the Akima spline, the broken line or a smoothing method.
  • LOWESS on few points: see the example. Keep LOWESS for clouds of tens or hundreds of points.
  • Adjusting the smoothing until you get the expected curve: the choice must be made a priori and reported.
  • Forgetting that replicates are averaged: the curve does not show the scatter; plot the points (mean and SD) with the curve.
  • Reading the "Curve" table of several data sets with different ranges: the X grid is that of the first data set; the other data sets are described there only within that range (the graph, for its part, draws each curve over its own full range).

Function Curve#

The Function Curve analysis draws the graph of an equation (from the library or written by you) for parameter values that you set, over the X range of your choice, without any data. It can draw a family of curves (one parameter takes several values in turn) and, in addition to the function, its first derivative, second derivative or integral. It creates a "Function" output table and its line graph.

When to use it#

  • To see the shape of a model before fitting it: what does a dose-response curve with a Hill slope of 0.5, 1 or 2 look like? How does the constant K change a decay?
  • For teaching, or to superimpose a theoretical curve on data (by adding the "Function" table to the data graph).
  • To obtain numerically the derivative (a rate) or the integral (a cumulative quantity, an area) of a function.
  • Do not use it to fit a model (Nonlinear Regression), nor to produce realistic noisy data (Random XY Data).

Assumptions and checks#

There is no statistical assumption: the computation is deterministic. Only check that:

  • all the parameters have the intended value ("Function" tab of the results): a forgotten parameter takes an arbitrary default value;
  • the equation is defined over the whole X range (log(X) and ln(X) require X > 0, a division by zero is undefined): undefined values leave empty cells and gaps in the curve;
  • the grid is fine enough for the derivative or the integral (see Calculations).

Step by step in Variance#

  1. Open any data table (its values are not used), then choose Analysis › Curves and Regression › Function Curve (or Analyze, then "Function Curve" in the "Choose an Analysis" window).
  2. The "Function Curve – settings" window has the following tabs.
    • Function: "Equation" (the library selector described above; "Gaussian peak" by default); "Custom equation" (an equation written in the language of custom equations, which replaces that of the library); "Parameter values": one value per line, for example Mean = 0 (the value can be a constant expression).
    • Range: "Starting X" (−5 by default), "Ending X" (5 by default) and "Number of segments" (200 by default, from 2 to 10000): the curve is computed at "Number of segments" + 1 evenly spaced points.
    • Family: "Plot a family of curves: parameter to vary" (name of the parameter, empty by default) and "Values (comma separated)" (values separated by commas or semicolons); if both fields are filled in, one curve is drawn for each value.
    • Options: "Also plot": "Function only" (default), "First derivative", "Second derivative" or "Integral"; "Significant digits" and "P value format".
  3. Click OK: the results sheet and a line graph of the "Function" table are created.

Calculations#

grid:        xk = a + (b − a) · k / N        k = 0 … N
             a = Starting X, b = Ending X, N = Number of segments
function:    yk = f(xk; parameters)
derivative:  y'k = (y(k+1) − y(k−1)) / (x(k+1) − x(k−1))     (central difference)
             y'0 = (y1 − y0)/(x1 − x0)   and   y'N = (yN − y(N−1))/(xN − x(N−1))
second derivative: the same formula applied to the first derivative
integral:    I0 = 0,   Ik = I(k−1) + (xk − x(k−1)) · (yk + y(k−1)) / 2     (trapezoids)

The integral is therefore cumulated from "Starting X" (where it equals 0): the last value is the signed area under the curve between a and b. Central differences and the trapezoidal method have an error proportional to the square of the step (b − a)/N: doubling the number of segments divides the error by about four.

Parameter values. A parameter named in "Parameter values" takes that value. Otherwise, for a library equation, it receives the value of its initial value rule, computed as if the data ran from X = −5 to 5 and from Y = 0 to 1 (smallest X −5, largest X 5, X range 10, smallest Y 0, largest Y 1, half-height X 0, slope 0.1), whatever the range chosen in the Range tab; for a custom equation, it equals 1. With a family of curves, the chosen parameter takes each value of the list in turn, the others keeping theirs.

Reading the results#

  • "Function" tab ("Value" column): the "Equation" row (the text of the equation), then one row per parameter with the value used. With a family of curves, the row of the varying parameter shows "family:" followed by the list of values.
  • "Function" output table: the X column, then one column per curve, named after the equation (its name in the library, or "Custom equation"), or "SD = 0.5" for a family; the derivative or integral follows each curve in a column suffixed "(d1)", "(d2)" or "(integral)".
  • Graph: the columns of the table, as lines. To superimpose a theoretical curve on data, add the "Function" table to the data graph (Format › Plotted Data Sets…, with the graph displayed).

Worked example#

The default Gaussian. Without changing anything, Variance draws "Gaussian peak" with Amplitude = 1 (largest Y), Mean = 0 (half-height X) and SD = 10/6 = 1.667 (X range / 6), from −5 to 5 in 200 segments (201 points). At X = −5: Y = exp(−0.5 × (5/1.6667)²) = exp(−4.5) = 0.011109, the first value of the table.

A family of Gaussians and their derivative. "Parameter values": Amplitude = 1, Mean = 0, SD = 1; "Plot a family of curves: parameter to vary": SD; "Values (comma separated)": 0.5, 1, 2; "Starting X" −2, "Ending X" 2, "Number of segments" 10; "Also plot": "First derivative". The "Function" table has six columns: "SD = 0.5", "SD = 0.5 (d1)", "SD = 1", "SD = 1 (d1)", "SD = 2", "SD = 2 (d1)". For SD = 1, at X = −0.4 (step of 0.4):

Y          = exp(−0.5 × 0.4²) = exp(−0.08) = 0.923116
derivative = (Y(0) − Y(−0.8)) / 0.8 = (1 − 0.726149) / 0.8 = 0.342314
exact      = −X/SD² × Y = 0.4 × 0.923116 = 0.369246        (7% error)

With 200 segments (step of 0.02), the central difference at X = −0.4 is (Y(−0.38) − Y(−0.42))/0.04 = 0.369177, within 0.02% of the exact value.

An integral. "Custom equation": Y = A*X^2 + B; "Parameter values": A = 3 (B, not named, equals 1); X from 0 to 2 in 4 segments; "Also plot": "Integral". The "Custom equation (integral)" column equals 0, 0.6875, 2.125, 5.0625, 10.25. The exact integral of 3X² + 1 between 0 and 2 is 2³ + 2 = 10: the trapezoidal method overestimates the area of this convex function by 0.25 (error (b − a) · h² · f''/12 = 2 × 0.5² × 6/12 = 0.25). With 200 segments, the error falls to 0.0001.

Writing up the results#

"The theoretical curves (Gaussians of amplitude 1 and standard deviation 0.5, 1 and 2) were drawn with Variance (Function Curve)." For a numerical derivative or integral, state the method and the step: "derivative computed by central differences, step of 0.02".

Common pitfalls#

  • Unspecified parameters: their default value is arbitrary (library rule evaluated on X from −5 to 5, or 1) and does not adapt to the chosen range. Fill in all the parameters and check the "Function" tab.
  • A misspelled parameter name in "Plot a family of curves: parameter to vary": Variance displays a message that lists the parameters of the equation. A list in which no value is numeric, on the other hand, gives a single curve, without a message.
  • A grid too coarse for the derivative, especially the second derivative, or for the integral: increase "Number of segments".
  • Confusing the cumulative integral with an antiderivative: the "(integral)" column equals 0 at "Starting X"; for the area between two other bounds, take the difference of the cumulated values.
  • A forgotten domain of definition: log(X) with a negative "Starting X" leaves empty cells.

References#

Books:

  • Motulsky H, Christopoulos A. Fitting Models to Biological Data Using Linear and Nonlinear Regression: A Practical Guide to Curve Fitting. Oxford University Press, 2004.
  • Bates DM, Watts DG. Nonlinear Regression Analysis and Its Applications. Wiley, 1988.
  • Seber GAF, Wild CJ. Nonlinear Regression. Wiley, 1989.
  • Ratkowsky DA. Handbook of Nonlinear Regression Models. Marcel Dekker, 1990.
  • Draper NR, Smith H. Applied Regression Analysis, 3rd ed. Wiley, 1998.
  • Burnham KP, Anderson DR. Model Selection and Multimodel Inference: A Practical Information-Theoretic Approach, 2nd ed. Springer, 2002.
  • Motulsky H. Intuitive Biostatistics, 4th ed. Oxford University Press, 2018.
  • Press WH, Teukolsky SA, Vetterling WT, Flannery BP. Numerical Recipes: The Art of Scientific Computing, 3rd ed. Cambridge University Press, 2007.
  • Brent RP. Algorithms for Minimization without Derivatives. Prentice-Hall, 1973.
  • de Boor C. A Practical Guide to Splines. Springer, 1978.

Articles:

  • Levenberg K. A method for the solution of certain non-linear problems in least squares. Quarterly of Applied Mathematics 1944;2:164-168.
  • Marquardt DW. An algorithm for least-squares estimation of nonlinear parameters. Journal of the Society for Industrial and Applied Mathematics 1963;11:431-441.
  • Motulsky HJ, Ransnas LA. Fitting curves to data using nonlinear regression: a practical and nonmathematical review. FASEB Journal 1987;1:365-374.
  • Motulsky HJ, Brown RE. Detecting outliers when fitting data with nonlinear regression – a new method based on robust nonlinear regression and the false discovery rate. BMC Bioinformatics 2006;7:123.
  • Benjamini Y, Hochberg Y. Controlling the false discovery rate: a practical and powerful approach to multiple testing. Journal of the Royal Statistical Society B 1995;57:289-300.
  • Holland PW, Welsch RE. Robust regression using iteratively reweighted least-squares. Communications in Statistics – Theory and Methods 1977;6:813-827.
  • Hougaard P. The appropriateness of the asymptotic distribution in a nonlinear regression model in relation to curvature. Journal of the Royal Statistical Society B 1985;47:103-114.
  • Akaike H. A new look at the statistical model identification. IEEE Transactions on Automatic Control 1974;19:716-723.
  • Hurvich CM, Tsai CL. Regression and time series model selection in small samples. Biometrika 1989;76:297-307.
  • Wald A, Wolfowitz J. On a test whether two samples are from the same population. Annals of Mathematical Statistics 1940;11:147-162.
  • D'Agostino RB, Belanger A, D'Agostino RB Jr. A suggestion for using powerful and informative tests of normality. The American Statistician 1990;44:316-321.
  • Breusch TS, Pagan AR. A simple test for heteroscedasticity and random coefficient variation. Econometrica 1979;47:1287-1294.
  • Koenker R. A note on studentizing a test for heteroscedasticity. Journal of Econometrics 1981;17:107-112.
  • Cheng Y, Prusoff WH. Relationship between the inhibition constant (K1) and the concentration of inhibitor which causes 50 per cent inhibition (I50) of an enzymatic reaction. Biochemical Pharmacology 1973;22:3099-3108.
  • Arunlakshana O, Schild HO. Some quantitative uses of drug antagonists. British Journal of Pharmacology and Chemotherapy 1959;14:48-58.
  • Akima H. A new method of interpolation and smooth curve fitting based on local procedures. Journal of the ACM 1970;17:589-602.
  • Cleveland WS. Robust locally weighted regression and smoothing scatterplots. Journal of the American Statistical Association 1979;74:829-836.