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
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.
Find more tutorials on the SAS Users YouTube channel.