![]() |
spa |
|
Constraining variables in user-defined equations
Why constrain? Prism has no common sense. When it finds the best-fit of an equation to your data, it doesn't know which values are reasonable. For example, if your data are quite scattered (or the initial values are way off) Prism might report that the best-fit value of a rate constant or a plateau is a negative number. Prism doesn't know that negative numbers are impossible. All it knows is that setting that variable to a negative number reduces the sum-of-squares as much as possible. But your goal is not just to reduce the sum-of-squares, but to do so in a way that results in best-fit values that are scientifically sensible. If Prism reports results that are not sensible, consider adding constraints to your model (also consider using a different model). Setting a parameter to a constant value The most severe constraint is to set a parameter to a constant value. For example, you can set a plateau variable to zero if you have already subtracted out any baseline or nonspecific data. You can do this in two ways. The direct approach is to edit the equation to set a parameter to a constant value. In the example below, the variable Plateau is fixed to a constant value, so its value is not altered by nonlinear regression.
A simple approach is to use the Constants dialog. After selecting the equation in the nonlinear regression parameters dialog, click the Constants button to bring up a second dialog. In that dialog, you may set any of the parameters in the equation to a constant value. Constraining to a positive value A common constraint is to tell Prism that a variable must be positive. For example, you may wish to constrain the bottom plateau of an exponential dissociation curve to be positive. Here is an equation that does that using the IF function (see Using the IF function).
The first line defines the intermediate variable Bottom to be zero if the variable Baseline is negative. Otherwise it sets Bottom equal to Baseline.You can achieve the same effect using the MAX function. The following equation is equivalent to the previous one.
The first line of the equation defines the intermediate variable BOTTOM to be the maximum of the variable BASELINE and zero. This means that the variable BOTTOM can never be negative (because 0.0 is larger than any negative number). There is no particular reason to favor using either the IF function or MAX functions. Use whichever you find easier to remember. Constraining a variable to a range of values You can constrain a variable to fall within a range of values. For example, the equation below fits a dose-response curve, constraining the bottom plateau to be between -10 to 10, and the top plateau to be between 90 to 110.
The logic of the nested If statements can be hard to follow. Here is the logic of the first line above, written in the Basic computer language (you cannot use this Basic syntax when entering models into Prism):
If you find the IF statements hard to follow, you might prefer to establish constraints using the Max and Min functions. The following equation is equivalent to the previous one. To understand the logic, try evaluating the first line setting the variable TopP to 85, 95, 105 and 115. The variable Top will equal 90, 95, 105 and 110 respectively. Top=MAX(90, MIN(TopP, 110))Bottom=MAX(-10, MIN(BottomP, 10))Y=Bottom + (Top-Bottom)/(1+10^((LogEC50-X)*HillSlope)) An alternative approach to constraining a variable to a range of values Hilborn and Mangel suggested an alternative approach to constraining a variable to a range of values (The Ecological Detective, Princeton University Press, 1997). Say you want to constrain the variable F to be between 0 and 1. Before using F in your user-defined equation, define it as a function of the variable FF. But rather than use an IF statement, or Min and Max functions, to constrain the variables, use this equation:
Why does this work? No matter what value FF has, the arctangent is between -pi/2 to pi/2. Therefore, F will be between 0.0 and 1.0. Prism fits the value FF, which has no constraint. To make sense of the results, transform the best-fit value of FF into F, which will always be between 0.0 and 1.0. Do the same thing for both ends of the confidence interval for FF.You can generalize this equation for use with any range of values.
ULimit and LLimit are the upper and lower limits of your constraint. Substitute values or constraint those parameters to be constant. Prism cannot fit ULimit and LLimit. |
| All contents copyright © 1999 by GraphPad Software, Inc. All rights reserved. |