## IML solve function as in PROC FCMP

Solved
Occasional Contributor
Posts: 15

# IML solve function as in PROC FCMP

Hi,

I've used PROC FCMP to solve the following problem:

Find x such that PRBBNRM(x, -0.2, 0.5) = 0.1.

What is the analogous solution in IML?

Accepted Solutions
Solution
‎08-23-2013 06:38 AM
SAS Super FREQ
Posts: 4,171

## Re: IML solve function as in PROC FCMP

A few thoughts:

1) To answer your original question, you can use any root-finding algorithm. If you have SAS/IML 12.1 or later, you can use the FROOT function. For earlier releases, you can use a bisection method. (You don't say which book of mine you have, but in my "blue book" on simulating data, I show root-finding examples in Chapter 7. In the "red book," see the example of the golden section search.)

2) I originally misread your question, I thought you were asking to find the contour of PROBBNRM(x, y, 0.5). But from your follow-up, it looks like that is indeed what you want.  For the a bivariate CDF, you can reduce the problem of finding a contour to a series of 1D line searches, as you've done in the FCMP example.

3) I Haven't read the Genz and Bretz paper for a multivaraite CDF. Could you give a more complete reference? They have several papers in this general area.

All Replies
SAS Super FREQ
Posts: 4,171

## Re: IML solve function as in PROC FCMP

I'd be interested in hearing how you solved this problem with FCMP.

I want to make sure that you want the contours of the CUMULATIVE bivariate distribution function that are shown in this article: Visualize the bivariate normal cumulative distribution - The DO Loop These are going to be "L-shaped" curves.

I'm double-checking because you could also want the contours of the bivariate density function, which are ellipses.

Occasional Contributor
Posts: 15

## Re: IML solve function as in PROC FCMP

Hi Rick, Thanks for your reply (Love your book, BTW). I am, in fact, looking for contours on the cdf, per your Do Loop post. Here is a greatly simplified example. I would like to do this in IML, but instead of the ProbBnrm function, I'd like to try the multivariate normal cdf module developed by Author : ALAN GENZ and FRANK BRETZ. To do this, I believe that I'll have to code the procedure in IML. proc fcmp outlib = work.funcs.math; function Intersection(_y, _x); return(ProbBnrm(_x,_y,0.5)); endsub; function SolveIntersect(_Perc,_x); array solveopts[5] initial abconv relconv maxiter solvstat (.4 .001 1.0e-6 10000); y = solve("Intersection",solveopts, _Perc,.,_x); return(y); endsub; options cmplib=work.funcs; run; quit; data Solved; do x = -1 to 1 by 0.5; Intersection10 = SolveIntersect(0.1,x); output; end; run;

Solution
‎08-23-2013 06:38 AM
SAS Super FREQ
Posts: 4,171

## Re: IML solve function as in PROC FCMP

A few thoughts:

1) To answer your original question, you can use any root-finding algorithm. If you have SAS/IML 12.1 or later, you can use the FROOT function. For earlier releases, you can use a bisection method. (You don't say which book of mine you have, but in my "blue book" on simulating data, I show root-finding examples in Chapter 7. In the "red book," see the example of the golden section search.)

2) I originally misread your question, I thought you were asking to find the contour of PROBBNRM(x, y, 0.5). But from your follow-up, it looks like that is indeed what you want.  For the a bivariate CDF, you can reduce the problem of finding a contour to a series of 1D line searches, as you've done in the FCMP example.

3) I Haven't read the Genz and Bretz paper for a multivaraite CDF. Could you give a more complete reference? They have several papers in this general area.

Occasional Contributor
Posts: 15

## Re: IML solve function as in PROC FCMP

Thanks. I have the red book. I also only have IML 9.3, so clearly I'm getting behind.

The Genz and Bretz reference was from one of your posts in this forum regarding MVN tail probabilities. I've also worked from some of the papers Genz has on his website: www.math.wsu.edu/faculty/genz/homepage.

In general, my problem is to find points on the surface X such that F(X<= x) = 0.1. For my particular clinical application, I can tolerate a small amount of inaccuracy in those points. It's easy enough to find the curve in 2D using the fcmp solve function for the toy example that I provided (and a small number of applications that I work on). I'd like to develop the method for an arbitrary dimension.

Since I have an older version of IML, I will work with the bisection approach that you described.

Thanks very much for your insights!

SAS Super FREQ
Posts: 4,171

## Re: IML solve function as in PROC FCMP

I describe an algorithm (complete with SAS/IML code)  for computing contours of the standardized bivariate normal CDF in this article: Compute contours of the bivariate normal CDF - The DO Loop

🔒 This topic is solved and locked.