BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
phongpham
Fluorite | Level 6

Hi every one,

I am writing  a function using probit function to convert probabilities to a z_normal values like this:

phongpham_0-1633046986095.png

When I use probabilities that smaller than 1 and greater than 0, Probit works well. 

( for this I use this piece of code: z_inv = probit(Cum_TM[2:6,1:6]); )

but when I use probabilities that equal 1 or 0, Probit does not work  any more.

( for this I use this piece of code:  z_inv = probit(Cum_TM[1:8,1:7]); ) and I got this error:

ERROR: (execution) Invalid argument to function.

count : number of occurrences is 23
operation : PROBIT at line 42 column 17
operands : _TEM1003

phongpham_1-1633047258311.png

I just wonder if you please help me to solve this error.

Thank you very much for your help!

 

Here is my complete code and data for your reference:

proc import datafile = '/proj/sas/sasdata/risk/discovery/grm/ifrs/au/sme/phase2/OLL/OLL_transition_matrix_1.xlsx'
replace dbms = xlsx out = Calibrated_matrix_OLL;
run;

%let tm_in = Calibrated_matrix_OLL;;
%let z_in = z_25;
%let w =0.06;
%let TM_out = matrix_ca_da_oll_out;

proc iml;
use &TM_in.;
read all var _ALL_ into TM_Input;
close &TM_in.;
TM = TM_Input[,3:10]; *print TM;
Start rowcumsum(x);
Step1 = cusum(x);
Step2 = 0 // Step1[1:nrow(Step1)-1,ncol(Step1)];
Output = Step1 - repeat(Step2,1,ncol(Step1));
return(Output);
Finish rowcumsum;
do i = 1 to 1; *number of quarters;
Pre_cycle_adj = TM[(1+8*(i-1)):(8*i),1:8]; print Pre_cycle_adj;
Cum_TM = rowcumsum(Pre_cycle_adj); print Cum_TM;
z_inv = probit(Cum_TM[1:8,1:7]); print z_inv;
end;

quit;

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Read the documentation:

Required Argument

p

is a numeric probability.

Range 0 < p < 1

The reason that 0 and 1 are excluded is because the normal distribution for probability 0 would be negative infinity and the 1 would be from positive infinity.

 

So you have to test the value of P before giving the function a 0 or 1 value. Assign whatever value you want for the result when the parameter would be either 0 or 1.

 

 

View solution in original post

2 REPLIES 2
ballardw
Super User

Read the documentation:

Required Argument

p

is a numeric probability.

Range 0 < p < 1

The reason that 0 and 1 are excluded is because the normal distribution for probability 0 would be negative infinity and the 1 would be from positive infinity.

 

So you have to test the value of P before giving the function a 0 or 1 value. Assign whatever value you want for the result when the parameter would be either 0 or 1.

 

 

phongpham
Fluorite | Level 6
HI Ballardw, thank you very much for your help! Very much appreciate that!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 600 views
  • 1 like
  • 2 in conversation