turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

Topic Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-28-2016 04:07 PM - edited 11-28-2016 04:08 PM

```
/*NORMINV of Random Binomial Probability of Default*/
%let N = 10;
%let M= 3;
proc iml;
call randseed(123);
x = j(&N,&M);
q=j(&N,&M);
p = {.100 .200 .500};
p_mat = repeat(p, &N);
stdev_mat=p_mat#(1-p_mat);
N_mat = repeat(&N, &N, &M);
call randgen(x, "Binomial", p_mat, N_mat);
x=x/&N;/*Random probability of default*/
q = quantile("Normal", x); /*Quantile of the probability
from normal distribution (Distance to default)*/
mean=mean(x);
max=x[<>,];
min=x[><,];
print p,mean,max,min,x,q;
Quit;
```

I have generated random variables using Binnomial distribution and converted them into a matrix of probabilities of default (x=x/&N). Now I want to calculate distance to default by finding the quantile of these probabilities ( matrix q) assuming standard normal distribution. However, I am getting an error on the Quantile function (q) i.e. **ERROR: (execution) Invalid argument to function. **Please help and thanks in advance.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to abbaskashif

11-28-2016 04:14 PM

The inverse CDF of 0 is not defined when elements of X are zero. The error is that you are trying to evaluate a function (QUANTILE) for values that are outside the domain of the function, which is (0, 1).

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Rick_SAS

11-29-2016 12:23 PM

Ture. I'll have to try to get around this, perhaps by replacing zeros with infinitesimally small probabilities.