BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
AlexeyS
Pyrite | Level 9

Hi All,

I run a non-linear regression using proc model. Proc model as you know have two options of restrictions on parameters: bound and restrict.

I have almost same restriction that returns 100 times, for example :

x1*x2*a+x3*b*t = k(t), when t=0.25,0.5,0.75,....,25 and k is fixed(number) for each t. i.e each t has different k

x1, x2, x3 - parameters

It looks like :

x1*x2*a+x3*b*0.25 = 60

x1*x2*a+x3*b*0.5 = 75

x1*x2*a+x3*b*0.75 = 79

...

Is there any way to write these restrictions in proc model in one restrict? Maybe put t and k into  a dataset, that i could take the values from there?

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
kessler
SAS Employee

Alexey,

If you want to programmatically generate your list of restrictions then you can use the SAS macro language.  Here's an example that shows how a RESTRICT statement could be generated from values stored in a data set.

Marc

data d;
   do t = 2 to 12 by 2;
	   output;
	end;
run;

data _null_;
   length eqs $ 1024;
   set d;
	eqname = 'eq'||left(put(_n_,6.));
	call symput(eqname, "lhs = " || t);
run;


%macro restricts;
   restrict
   %do i = 1 %to 6; 
		%unquote(&eq&i)
		%if &i ne 6 %then,
   %end;
	;
%mend restricts; 


proc tmodel;
... your model code ... %restricts; quit;

View solution in original post

3 REPLIES 3
kessler
SAS Employee

Yes. You can specify multiple restrictions by separating them with commas on the RESTRICT statement:

restrict x1*x2*a+x3*b*0.25 = 60,
   x1*x2*a+x3*b*0.5 = 75,
   x1*x2*a+x3*b*0.75 = 79;

Also, you may be interested in using PROC TMODEL to estimate your model. PROC TMODEL uses the same syntax as PROC MODEL, but it has an improved non-linear optimization engine that is well suited to problems with nonlinear restrictions.

Marc

AlexeyS
Pyrite | Level 9
Of course, i can write these restrictions, but it not looks nice to write 100 restrictions, therefore i asked a question if there are any other way to write these restriction in more "normal" way.
kessler
SAS Employee

Alexey,

If you want to programmatically generate your list of restrictions then you can use the SAS macro language.  Here's an example that shows how a RESTRICT statement could be generated from values stored in a data set.

Marc

data d;
   do t = 2 to 12 by 2;
	   output;
	end;
run;

data _null_;
   length eqs $ 1024;
   set d;
	eqname = 'eq'||left(put(_n_,6.));
	call symput(eqname, "lhs = " || t);
run;


%macro restricts;
   restrict
   %do i = 1 %to 6; 
		%unquote(&eq&i)
		%if &i ne 6 %then,
   %end;
	;
%mend restricts; 


proc tmodel;
... your model code ... %restricts; quit;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 1760 views
  • 1 like
  • 2 in conversation