Dear Madam/Sir,
I construct "r1" variable using financial data and calculate "pbp" with exponential function.
r1=-1.32-0.407 *size + 6.03*TLTA - 1.43*WCTA + 0.0757*CLCA - 2.37*NITA - 1.83*FUTL + 0.285*INTWO - 1.72*OENEG - 0.521*CHIN;
pbp=1/(1+exp(-r1));
However, I have the following error message and many "pbp" value generates missing values.
NOTE: Invalid argument to function EXP(1077.0290778) at line 226 column 10.
NOTE: Invalid argument to function EXP(730.03261995) at line 226 column 10.
NOTE: Invalid argument to function EXP(2948.7729907) at line 226 column 10.
NOTE: Invalid argument to function EXP(1961.5518226) at line 226 column 10.
NOTE: Invalid argument to function EXP(755.8640734) at line 226 column 10.
NOTE: Invalid argument to function EXP(1152.1594476) at line 226 column 10.
NOTE: Invalid argument to function EXP(950.27392335) at line 226 column 10.
NOTE: Invalid argument to function EXP(2908.9920974) at line 226 column 10.
NOTE: Invalid argument to function EXP(947.47746471) at line 226 column 10.
It will be highly appreciative if you can advise me how to resolve this issue.
Thanks
Joon1
Hello @joon1,
It looks like you're working with a logistic regression model and you want to apply the logistic function (i.e., the inverse of the logit function) to r1. You don't need to type in the formula for the logistic function because SAS has already implemented it in the LOGISTIC function.
Example:
data test;
do r1=-5, -10, -50, -100, -500, -1000;
pbp=logistic(r1);
output;
end;
run;
proc print data=test;
format pbp best21.;
run;
Result:
Obs r1 pbp 1 -5 0.00669285092428 2 -10 0.0000453978687 3 -50 1.9287498479639E-22 4 -100 3.7200759760208E-44 5 -500 7.1245764067411E-218 6 -1000 0
The result pbp=0 for r1=-1000 is, of course, rounded down from 5.076E-435, but the unavoidable rounding errors of the other results are much greater than this and you don't get missing values or pesky notes in the log.
EXP(755.8640734) is 1.851809 × 10^328
That's a number larger than 10^308 that IEEE 754 computers can store.
What do you want to do with a 328-digit number?
Take a look at documentation for the CONSTANT function (not the EXP function) at Constant Function
In there it says this about the constant "LOGBIG":
You can exponentiate any floating-point number less than or equal to CONSTANT('LOGBIG') by using the exponential function, EXP, without causing any overflows.
data _null_;
lb=constant('logbig');
put lb=;
run;
which generates:lb=709.78271289
Your arguments are too big to be exponentiated on a windows machine using double-precision floating point arithmetic, because they would exponentiate to a value larger than constant('big') [ =1.797693E308 on my machine].Thank you so much for your help, mkeintz.
Trying to calculate a power of e, which is about 2.718, with a large number like 1,000 will result in such an impossibly large number that SAS cannot handle. Even e to the power of 100 will result in a number with 43 zeroes on the end of it! You need to consider limiting the range of values being supplied to the EXP function to something reasonable. PBP will be very close to 0 for large values coming from EXP.
Thank you so much for your help, SASkiwi.
Hello @joon1,
It looks like you're working with a logistic regression model and you want to apply the logistic function (i.e., the inverse of the logit function) to r1. You don't need to type in the formula for the logistic function because SAS has already implemented it in the LOGISTIC function.
Example:
data test;
do r1=-5, -10, -50, -100, -500, -1000;
pbp=logistic(r1);
output;
end;
run;
proc print data=test;
format pbp best21.;
run;
Result:
Obs r1 pbp 1 -5 0.00669285092428 2 -10 0.0000453978687 3 -50 1.9287498479639E-22 4 -100 3.7200759760208E-44 5 -500 7.1245764067411E-218 6 -1000 0
The result pbp=0 for r1=-1000 is, of course, rounded down from 5.076E-435, but the unavoidable rounding errors of the other results are much greater than this and you don't get missing values or pesky notes in the log.
Thank you so much for your help, FreelanceReinhard.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.