I am a newbie in sas and trying to write a simplistic version of garch model in proc optmodel, here is the attached code,
proc optmodel;
number n = 8926;
/* var omega init 0.01, alpha init 0.02, beta init 0.92; */
var omega, alpha, beta, mu;
number epsilonsq{1..n}, y{1..n}, llh{1..n}, sigtsq{1..n};
read data ret into [_n_] y; llh[1] = 0;
for{i in 1..n} do; epsilonsq = (y-0.0005)**2; end;
sigtsq[1] = mean(of epsilonsq
for{j in 2..n} do;
sigtsq
min z = sum{k in 2..n}(0.5*(log(2*3.14156)
+ log(omega + alpha*epsilonsq[k-1] + beta*sigtsq[k-1])
+ epsilonsq
omega.lb = 1e-06; alpha.lb = 1e-06; beta.lb = 1e-06;
omega.ub = 1-1e-06; alpha.ub = 1-1e-06; beta.ub = 1-1e-06;
con c: alpha + beta <= 1-1e-06;
solve with nlp / tech=ip; print sigtsq;
quit;
I want sigstq matrix (its defined as an array using the number declaration) to change as the parameters (omega, alpha, beta) changes at every step of optimization. However, it remains constant throughout the optimization.
Please point me in the right direction. Thanks.
If you want sigtsq to depend on decision variables, you should declare it as an implicit variable:
impvar sigtsq {j in 1..n} =
(if j = 1 then mean(of epsilonsq
See the IMPVAR statement in the PROC OPTMODEL documentation:
If you want sigtsq to depend on decision variables, you should declare it as an implicit variable:
impvar sigtsq {j in 1..n} =
(if j = 1 then mean(of epsilonsq
See the IMPVAR statement in the PROC OPTMODEL documentation:
Thanks Rob!
Glad to help. You might also be interested in this book of 29 examples that illustrate various features of PROC OPTMODEL:
SAS/OR(R) 13.2 User's Guide: Mathematical Programming Examples
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!