14.03.2014 Views

Modeling and Multivariate Methods - SAS

Modeling and Multivariate Methods - SAS

Modeling and Multivariate Methods - SAS

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

274 Performing Nonlinear Regression Chapter 9<br />

Statistical Details<br />

Prediction Model:<br />

b0 * First(T#1=1-(T#2=Exp(-b1*X)), T#3=-(-1*T#2*X))<br />

The Derivative of Model with respect to the parameters is:<br />

{T#1, T#3*b0}<br />

The derivative facility works like this:<br />

• In order to avoid calculating subexpressions repeatedly, the prediction model is threaded with<br />

assignments to store the values of subexpressions that it needs for derivative calculations. The<br />

assignments are made to names like T#1, T#2, <strong>and</strong> so on.<br />

• When the prediction model needs additional subexpressions evaluated, it uses the First function,<br />

which returns the value of the first argument expression, <strong>and</strong> also evaluates the other arguments. In this<br />

case additional assignments are needed for derivatives.<br />

• The derivative table itself is a list of expressions, one expression for each parameter to be fit. For<br />

example, the derivative of the model with respect to b0 is T#1; its thread in the prediction model is<br />

1–(Exp(-b1*X)). The derivative with respect to b1 is T#3*b0, which is –(–1*Exp(-b1*X)*X)*b0 if<br />

you substitute in the assignments above. Although many optimizations are made, it does not always<br />

combine the operations optimally. You can see this by the expression for T#3, which does not remove a<br />

double negation.<br />

If you ask for second derivatives, then you get a list of (m(m + 1))/2 second derivative expressions in a list,<br />

where m is the number of parameters.<br />

If you specify a loss function, then the formula editor takes derivatives with respect to parameters, if it has<br />

any. And it takes first <strong>and</strong> second derivatives with respect to the model, if there is one.<br />

If the derivative mechanism does not know how to take the analytic derivative of a function, then it takes<br />

numerical derivatives, using the NumDeriv function. If this occurs, the platform shows the delta that it used<br />

to evaluate the change in the function with respect to a delta change in the arguments. You might need to<br />

experiment with different delta settings to obtain good numerical derivatives.<br />

Tips<br />

There are always many ways to represent a given model, <strong>and</strong> some ways behave much better than other<br />

forms. Ratkowsky (1990) covers alternative forms in his text.<br />

If you have repeated subexpressions that occur several places in a formula, then it is better to make an<br />

assignment to a temporary variable. Then refer to it later in the formula. For example, one of the model<br />

formulas above was this:<br />

If(Y==0, Log(1/(1+Exp(model))), Log(1 - 1/(1 + Exp(model))));<br />

This could be simplified by factoring out an expression <strong>and</strong> assigning it to a local variable:<br />

temp=1/(1+Exp(model));<br />

If(Y==0, Log(temp), Log(1-temp));<br />

The derivative facility can track derivatives across assignments <strong>and</strong> conditionals.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!