BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sasuser2417
Calcite | Level 5

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 = omega + alpha*epsilonsq[j-1] + beta*sigtsq[j-1];  end;

    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 + alpha*epsilonsq[k-1] + beta*sigtsq[k-1])));

    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.

    1 ACCEPTED SOLUTION

    Accepted Solutions
    RobPratt
    SAS Super FREQ

    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

  • ) else omega + alpha*epsilonsq[j-
  • 1] + beta*sigtsq[j-1]);

    See the IMPVAR statement in the PROC OPTMODEL documentation:

    SAS/OR(R) 13.2 User's Guide: Mathematical Programming

    View solution in original post

    3 REPLIES 3
    RobPratt
    SAS Super FREQ

    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

  • ) else omega + alpha*epsilonsq[j-
  • 1] + beta*sigtsq[j-1]);

    See the IMPVAR statement in the PROC OPTMODEL documentation:

    SAS/OR(R) 13.2 User's Guide: Mathematical Programming

    sasuser2417
    Calcite | Level 5

    Thanks Rob!

    RobPratt
    SAS Super FREQ

    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

    sas-innovate-2024.png

    Don't miss out on SAS Innovate - Register now for the FREE Livestream!

    Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

     

    Register now!

    Multiple Linear Regression in SAS

    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.

    Discussion stats
    • 3 replies
    • 1967 views
    • 0 likes
    • 2 in conversation