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

🔒 This topic is **solved** and **locked**.
Need further help from the community? Please
sign in and ask a **new** question.

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

Posted 02-25-2016 02:30 PM
(1440 views)

It looks that the objective function used in nonlinear optimization routines can only have one input vector. However, what if I need to pass some other parameters to the objective function. For example, I want to minimize the sum of square of difference between a function value and a target value, and the target value is user defined. Let me use a simple case, suppose x is a 3*1 vector I want to find to minimize the following funciton.

z=(x[1]-y[1])**2 + (x[2]-y[2])**3 + (x[3]-y[3])**2, where y is the vector of target specified by users. Therefore, it is better not hard coded in the objective function.

Ideally, the objective function should have two arguments, x and y;

start obj_func(x,y);

z=(x[1]-y[1])**2 + (x[2]-y[2])**3 + (x[3]-y[3])**2;

return(z);

finish obj_func;

The reason I cannot put x and y together as a single vector is that I only need to search for x, for a given y. In MATLAB, all the optimization routines allow passing extra arguements to the objective function. I am not sure if I can do similar things in SAS.

Thanks a bunch.

1 ACCEPTED SOLUTION

Accepted Solutions

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

3 REPLIES 3

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

Use the GLOBAL clause to list parameters that are important to evaluate the function, but that are not optimized:

start obj_func(x) GLOBAL(y);

See the article "Maximum likelihood estimation in SAS/IML" or these other blog posts:

http://blogs.sas.com/content/iml/tag/optimization

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

Thanks, Rick.

I am reading your article, once I found there is a similar question posted earlier on the forum. Here is a quick related question. If I have mutiple extra arguments, which are difficult to be written as a single matrix, how should I write the global clause? Should it be like

global (y1,y2,...)

or global (y1) global (y2) .... ?

Thanks

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

Use commas, as in

global(y1, y2, y3);

**SAS Innovate 2025** is scheduled for May 6-9 in Orlando, FL. Sign up to be **first to learn** about the agenda and registration!

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.