BookmarkSubscribeRSS Feed
abbaskashif
Calcite | Level 5
/*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. 

2 REPLIES 2
Rick_SAS
SAS Super FREQ

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

 

 

abbaskashif
Calcite | Level 5

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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

From The DO Loop
Want more? Visit our blog for more articles like these.
Discussion stats
  • 2 replies
  • 817 views
  • 0 likes
  • 2 in conversation