SOLVE / OPTIMIZE Example for PROC MODEL
/*--------------------------------------------------------------
SAS Sample Library
Name: modoslv.sas
Description: Example program from SAS/ETS User's Guide,
The MODEL Procedure
Title: SOLVE / OPTIMIZE Example for PROC MODEL
Product: SAS/ETS Software
Keys: nonlinear simultaneous equation models
PROC: MODEL
Notes:
--------------------------------------------------------------*/
title 'Constrained SOLVE Variable';
data d;
do i = 1 to 20;
rate = 0.2;
if i > 1 then rate = .;
output;
end;
run;
data s;
_name_ = "stock"; rate = 0; stock = 1; output;
_name_ = "rate"; rate = 1; stock = 0; output;
run;
proc model data=d sdata=s;
dependent rate stock;
parms theta 0.2
kappa 0.002
sigma 0.4
sinit 1
vol .1;
id i;
bounds rate >= 0;
rate = zlag(rate) + kappa*(theta - zlag(rate));
h.rate = sigma**2 * zlag(rate);
eq.stock = log(stock/sinit) - (rate + vol*vol/2);
h.stock = vol**2;
solve / optimize converge=1e-6 seed=1 random=1 out=o outobjvals outviolations;
quit;
proc print data=o(where=(_objval_>1e-6));
run;
data test1;
do t=1 to 50;
x1 = sqrt(t) ;
y = .;
output;
end;
proc model data=test1;
exogenous x1 ;
control a1 -1 b1 -29 c1 -4 ;
y = a1 * sqrt(y) + b1 * x1 * x1 + c1 * lag(x1);
solve y / out=sim forecast dynamic ;
run;
proc model data=test1;
exogenous x1 ;
control a1 -1 b1 -29 c1 -4 ;
y = a1 * sqrt(abs(y)) + b1 * x1 * x1 + c1 * lag(x1);
solve y / out=sim forecast dynamic itprint;
run;