General Syntax Conventions: Loss Function
The specification of the loss function is quite straightforward. In the estimation procedure, the specified value will be computed for each case in the data file; the estimation procedure will then attempt to find parameters that minimize the sum of those values across all cases.
In general, all rules apply as outlined for the specification of the regression equation for the model. In addition, the two keywords Pred and Obs (the case is ignored) are available to allow you to refer to the predicted and observed values, respectively, for the dependent variable. For example, the default least squares loss function can be specified as:
L = (Obs - Pred)2
- Constraining Parameters (Penalty Function)
-
When specifying regression functions, you can assess a penalty function in the loss function in order to constrain parameter values (see Penalty Functions). This example will demonstrate how you can constrain the parameters b0 and b1 to be greater than or equal to zero.
- In the Estimated Function and Loss Function dialog, specify the regression model:
v3 = b0 + b1 *v1 + b3 *exp(b1 *v2)
- Now, specify the desired loss function with a penalty assessment as follows:
L = (obs-pred)2 + (b0 <0)*100000 + (b1 <0)*10000
Note how the logical operators are used in this loss function. If either b0 or b1 is less than zero, then the program adds a large number, thus assessing a penalty to the loss function. As a result, the various estimation procedures move away from the regions that produce those functions.
- Math Errors
- If a math error such as division by zero or square root of a negative number is detected during the evaluation of an equation, then STATISTICA will automatically assign a very large number to the loss function. This way of dealing with invalid parameter estimates is also referred to as assigning a penalty function (see the Introductory Overviews). In most cases, the penalty function will "entice" the parameters back into the realm of valid values.