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 03-10-2015 01:33 PM
(859 views)

Hi,

The following code finds the root of an objective function when the INTERVAL (see in red below) is chosen carefully to be {1,3} but fails to produce when the interval is chosen as {0 3} for example. The problem is that in order for function FUN1 to work (C+ZBETA1-U) has to be > 0; is there any way to specify a general interval like {-3,3} but the code can still work?

PROC IML;

START FUN1(U) GLOBAL(C,ZBETA1,H,K,ALPHA);

/*SELECT THE VALUE OF C SUCH THAT THE DENOMINATOR BECOMES POSITIVE*/;

IF (C+ZBETA1-U)>0 THEN DO;

ARG = (C*(C+ZBETA1)-U**2)/SQRT((C+ZBETA1)**2-U**2);

YY = CDF("NORMAL", ARG)*PDF("NORMAL", U);

END;

IF (C+ZBETA1-U)<=0 THEN RETURN(0);;

RETURN(YY);

FINISH;

START FUN2(PARAM) GLOBAL(C,ZBETA1,H,K,ALPHA);

C = PARAM;

K1 = K><(C+ZBETA1);

CALL QUAD(INT,"FUN1", H || K1);

FF = 1 - CDF("NORMAL",H) - ALPHA - INT;

RETURN(FF);

FINISH;

H = 1;

K = 2.76;

ALPHA = 0.025;

BETA1 = 0.2;

ZBETA1 = QUANTILE("NORMAL",1-BETA1);

INTERVALS = {0,3}; /*THIS INTERVAL SHOULD BE SET SUCH THAT THE DENOMINATOR OF INTEGRAND REMAINS POSITIVE*/

Z = FROOT("FUN2", INTERVALS);

PRINT Z;

QUIT;

1 ACCEPTED SOLUTION

Accepted Solutions

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

How do the limits of integration, H and K, depend on C? The integrand is defined only when -(C+Z) < u < C+Z, so the integral does not make sense if H and K are outside of that interval. In FUN1, you are trying to protect against negative square roots by declaring that FUN1=0 when the term under the square root is negative. This creates a point of discontinuity since lim u->C+Z from the left is -infinity, but from the right is zero (because of your artificial definition)..

I think I would try to determine valid values for H and K inside of FUN2 and avoid setting FUN1=0 when the integrand is undefined.

3 REPLIES 3

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

What problem are you trying to solve?

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

Hi Rick,

The basic problem is to find the value of C from the equation below where h, k, alpha are provided, capital/small phi are CDF/PDF of normal. The value of C is known to be 1.923 for beta1 = 0.2.

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

How do the limits of integration, H and K, depend on C? The integrand is defined only when -(C+Z) < u < C+Z, so the integral does not make sense if H and K are outside of that interval. In FUN1, you are trying to protect against negative square roots by declaring that FUN1=0 when the term under the square root is negative. This creates a point of discontinuity since lim u->C+Z from the left is -infinity, but from the right is zero (because of your artificial definition)..

I think I would try to determine valid values for H and K inside of FUN2 and avoid setting FUN1=0 when the integrand is undefined.

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.