This example further illustrates the use of external data sets that are specified in the OBJECTIVE= option. For this example, a data set that contains randomly generated observations is used to estimate the parameters for the Johnson family of distributions (Bowman and Shenton, 1983). The objective is the log likelihood for the family, which involves four variables, :
where
Here, denotes the value of in the th observation of the data set that is generated by the following DATA step.
data sudata; n=20000; theta=-1; sigma=1; delta=3; gamma=5; rngSeed=123; do i = 1 to n; z = rannor(rngSeed); a = exp( (z - gamma)/delta ); d = sigma * ( (a**2 - 1)/(2*a) ) + theta; output; end; keep d; run;
This generates a data set called sudata
that contains observations. You can modify to increase or decrease the computational work per function evaluation. The following call to PROC FCMP defines the corresponding
FCMP function definition:
proc fcmp outlib=sasuser.myfuncs.mypkg; function jsu(x4,x2,f1); return (20000*(log(x4) - log(x2)) + f1); endsub; function jsu1(x1,x2,x3,x4,d); yk = (d - x1)/x2; zk = yk + sqrt(1 + yk**2); return (-0.5*(x3 + x4*log(zk))**2 -0.5*log(1 + yk**2)); endsub; run; options cmplib = sasuser.myfuncs;
In the following steps, the assumption for the definition of jsu
and jsu1
is that jsu1
is called once for each line of data and cumulatively summed. The resulting value is then provided to the function jsu
for a final calculation, which is called only once per evaluation of .
data objdata; input _id_ $ _function_ $ _sense_ $ _dataset_ $; datalines; f1 jsu1 . sudata f jsu max . ; data vardata; input _id_ $ _lb_ _ub_; datalines; x1 . . x2 1e-12 . x3 . . x4 1e-12 . ;
proc optlso objective=objdata variables=vardata logfreq=100 maxgen=1000; performance nodes=4 nthreads=8; run;
Output 3.8.1 shows the output from running these steps.
Output 3.8.1: Estimation for Johnson Family of Distributions
Performance Information | |
---|---|
Host Node | wintergreen.unx.sas.com |
Execution Mode | Distributed |
Grid Mode | Symmetric |
Number of Compute Nodes | 4 |
Number of Threads per Node | 8 |
Parallel Mode | Deterministic |
Problem Summary | |
---|---|
Problem Type | NLP |
Objective Definition Set | OBJDATA |
Variables | VARDATA |
Number of Variables | 4 |
Integer Variables | 0 |
Continuous Variables | 4 |
Number of Constraints | 0 |
Linear Constraints | 0 |
Nonlinear Constraints | 0 |
Objective Definition Source | OBJDATA |
Objective Sense | Maximize |
Objective Intermediate Functions | 1 |
Objective Data Set | sudata |
Solution Summary | |
---|---|
Solution Status | Function convergence |
Objective | -8423.731546 |
Infeasibility | 0 |
Iterations | 868 |
Evaluations | 75601 |
Cached Evaluations | 21004 |
Global Searches | 1 |
Population Size | 120 |
Seed | 1 |