BookmarkSubscribeRSS Feed
Calcite | Level 5



Was trying to use PROC MODEL for this problem, but it is not converging. And so I was thinking of using either PROC GA or PROC OPTLSO but am having trouble modeling it. Below is my PROC MODEL code. Note that it converges if I don't weight it by the sample variance (i.e. divide by delta * (1-delta) ). But given this is a requirement, I'm guessing I'll need an alternative solution. The other thing is, I actually need to solve for two parameters - zt and rho. For zt, you can see I'm solving for a different zt for each i. And then rho needs to be chosen such that the standard deviations of the zt(s) is close to 1. So this would either be a constraint or a secondary objective. With the PROC MODEL code I was hoping to just solve using 100 different rho and then choose the best one. But if I'm going to use SAS/OR, I'm guessing I can solve both problems in parallel. 


Any thoughts? I've seen this solved before using Brent and/or Golden Section, but would like to find an alternative method using SAS/OR. For PROC OPTLSO, I see how the least squares problem could be solved, but would not know how to solve for rho, given it will depend on the set of Zts. With PROC GA, I'm just sort of at a loss syntax-wise as to how to model it. I was figuring PROC OPTMODEL would not be suitable for this problem but I could be wrong, in which case I'd be appreciative of any help modeling it that way as well. Thanks in advance for any help you can offer. 


%let pinf = 1.7976931348623157e307;
%let minf = (-1*(&pinf));
%let n = 10;
%let s = 10;
%let rho = 0.2;

data z0;

do i = 1 to &s.;

  do j = 1 to &n.;
     if j = 1 then do;
        ubz = &pinf.;
        lbz = 1 - probit(j/&n.);
  else if j = &n. then do;
        lbz = &minf.;
        ubz = 1 - probit((j-1)/&n.);
  else do;
       ubz = 1 - probit((j-1)/&n.);
       lbz = 1 - probit(j/&n.);
  zt = rand('normal');
  pg1 = probnorm( (ubz - sqrt(&rho.) * zt ) / sqrt(1-&rho.));
  pg0 = probnorm( (lbz - sqrt(&rho.) * zt ) / sqrt(1-&rho.));
  actl = pg1 - pg0;
  wt = int( (&s. * 2) / (1 + abs((i - j))));


proc sort data=z0; by i; 
ods output parameterestimates=est; proc model data=z0 ; by i; parms zt_; endogenous actl; rho = 0.2; pg1 = probnorm( (ubz - sqrt(rho) * zt_ ) / sqrt(1-rho)); pg0 = probnorm( (lbz - sqrt(rho) * zt_ ) / sqrt(1-rho)); delta = (pg1 - pg0) ; actl = delta / (delta * (1 - delta)) ; fit actl / ols out=_tst_ converge=0.01; weight wt; outvars rho zt zt_; run;



If I understand correctly, the following PROC OPTMODEL code should get you started:


proc optmodel;
   set OBS;
   num i {OBS}, j {OBS}, ubz {OBS}, lbz {OBS}, zt {OBS}, pg1 {OBS}, pg0 {OBS}, actl {OBS}, wt {OBS};
   read data z0 into OBS=[_N_] i j ubz lbz zt pg1 pg0 actl wt;

   set ISET = setof {o in OBS} i[o];
   var zt_ {ISET};
   var delta {OBS};
   var actl_ {OBS};
   var rho init 0.2;
/*   fix rho = 0.2;*/

   con Con1 {o in OBS}: pg1[o] = probnorm( (ubz[o] - sqrt(rho) * zt_[i[o]] ) / sqrt(1-rho));
   con Con2 {o in OBS}: pg0[o] = probnorm( (lbz[o] - sqrt(rho) * zt_[i[o]] ) / sqrt(1-rho));
   con Con3 {o in OBS}: delta[o] = (pg1[o] - pg0[o]);
   con Con4 {o in OBS}: actl_[o] = delta[o] / (delta[o] * (1 - delta[o]));

   min SSE = sum {o in OBS} wt[o] * (actl[o] - actl_[o])^2;


   create data _tst_optmodel from [o] i j ubz lbz zt pg1 pg0 actl wt rho zt_[i[o]] actl_ delta;

For the part involving standard deviation, you can use the expression std(of zt_[*]) in a constraint or objective.


Calcite | Level 5

Thanks very much !!!



Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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
  • 2 replies
  • 2 in conversation