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 01-25-2013 03:26 PM
(1128 views)

Dear all;

I am running a proc iml program where i am minimizing a numerical integration. I have asked many questions concerning this program till I reached the current program.

1-My program now gives parameter estimates at the "optimization results" stage that satisfy the constraint(with a minor violation) but on the otherhand, these parameter estimates should give me another objective value than that displayed in the output (i.e.: when i substitute with the optimal parameter estimates in the objective function i don't get the displayed objective value) . I noticed that the objective value i got at the "optimization results" stage is the same objective value i got at the "optimization start" stage although the parameter estimates at the "optimization results" stage are different from the initial values i set for the parameters.

2-I noticed that even when i changed the minimization problem to maximization problem the objective value i got at the "optimization results" stage is the same as when the problem is a minimization problem. The value is exactly the same as that in the "optimization start" stage.

What might be the reason behind this?

I really need help,

The output file is attached,

Thanks

Emara

1 ACCEPTED SOLUTION

Accepted Solutions

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

I now see what your problem was. You defined FUNI using the variable hr as the parameter. IML was then treating hr inside FUN1 as a local, not a global parameter. When FUN is called from FUNI it uses the global value of hr in its calculations, and that wasn't being changed. I think what you really meant to do was define FUNI as:

start FUNI(hrx) global( hr);

hr = hrx;

<rest of your funtion as-is>

When I tried this I got objective values that were self-consistent and seemed reasonable.

7 REPLIES 7

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

Coudl you attach your latest program that produced these results?

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

Thank you,

The program is attached,

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

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

Thanks alot for your reply, but could you please explain more? I run my syntax again, the optimal parameters I got are **{3.087771**, **0.731934**}, when i substituted with these values in the objective function module, I got the value "136.461", although the displayed optimal objective value of my program is "2827.940918". However, when i substitute with the initial values {**4** **0.8**}in the objective function module i got the value ""2827.940918".What is wrong with my program , I can't figure out the errors and I really need help with this syntax.

This is the output of my program:

Optimization Start

Parameter Estimates

Lower Upper

Bound Bound

N Parameter Estimate Constraint Constraint

1 X1 4.000000 0 10.000000

2 X2 0.800000 0 1.000000

Value of Objective Function = 2827.940918

Optimization Results

Parameter Estimates

N Parameter Estimate

1 X1 3.087771

2 X2 0.731934

Value of Objective Function = 2827.940918

and here is the output when substituting with the optimal parameter estimates in the objective function module:

K

136.461

I attached the syntax of the objective function module(the syntax in which i substituted with the optimal parameter estimates in the objective function)

Thanks too much,

Waiting for your reply and help,

Emara

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

I now see what your problem was. You defined FUNI using the variable hr as the parameter. IML was then treating hr inside FUN1 as a local, not a global parameter. When FUN is called from FUNI it uses the global value of hr in its calculations, and that wasn't being changed. I think what you really meant to do was define FUNI as:

start FUNI(hrx) global( hr);

hr = hrx;

<rest of your funtion as-is>

When I tried this I got objective values that were self-consistent and seemed reasonable.

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

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

You can look at the IML doc on this at SAS/IML(R) 12.1 User's Guide to get the full explanation on how to specify global and local variables. Basically, local variables are used inside a module when you want to encapsulate those calculations so that you know what the inputs and outputs are and don't want to affect any other variables outside that module. Global variables exist above the scope of the module, and can be accessed inside a module if its definition doesn't have any parameters, or if they are specified explicitly with a global clause, such as

start foo; /* all variables inside foo are global */

or

start foo(a,b) global(m); /*a and b and any other variables inside foo are local, except that m is global */

Global parameter are useful for common data that may be used across several modules, but should be used with care. It is easy to introduce obscure errors in your program by accidentally modifying a global parameter that is normally assumed to be constant.

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. **

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.