Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 06-29-2018 09:48 AM
(813 views)

Hi,

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.);
end;
else if j = &n. then do;
lbz = &minf.;
ubz = 1 - probit((j-1)/&n.);
end;
else do;
ubz = 1 - probit((j-1)/&n.);
lbz = 1 - probit(j/&n.);
end;
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))));
output;
end;
end;
run;
proc sort data=z0; by i;
```

run;

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;

2 REPLIES 2

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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;
solve;
create data _tst_optmodel from [o] i j ubz lbz zt pg1 pg0 actl wt rho zt_[i[o]] actl_ delta;
quit;
```

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Thanks very much !!!

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!

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.