Thanks i'll do that
Looks like there may be a discrepancy in coding from a text formula, as I get super large values as well, with the test data. Can you post a link to the formula?
Steve Denham
One thing is to initialize Right to 0 before the loop. If you have x+y and y is missing then the sum result will be missing.
I still get huge numbers. I think the code for the formula needs checked.
Steve Denham
Hi everyone !
I'm using the same formula on another database and I think I'm having the following probelm : THe number i cannot go higher than 1030. He writes an error message when nit is higher than 1030. Do you know about that ? Is there a way to solve it ? Thanks
The code:
Data database.lsvstock3;
set database.lsvstock2;
Af=0;
do i=0 to nit;
AF = comb(nit,i)*(Pt**i)*((1-Pt)**(nit-i))*abs((i/nit)-Pt)+AF;
end;
run;
The log error message:
NOTE: Invalid argument to function COMB at line 570 column 6.
NOTE: Missing values were generated as a result of performing an operation on missing values.
Each place is given by: (Number of times) at (Line):(Column).
205291 at 570:17 20144 at 570:59
NOTE: Mathematical operations could not be performed at the following places. The results of the
operations have been set to missing values.
Each place is given by: (Number of times) at (Line):(Column).
205291 at 570:6
NOTE: There were 170 observations read from the data set DATABASE.LSVSTOCK2.
NOTE: The data set DATABASE.LSVSTOCK3 has 170 observations and 11 variables.
NOTE: DATA statement used (Total process time):
real time 0.24 seconds
cpu time 0.21 seconds
Reparameterize using LFACT.
comb(a,b)=fact(a)/(fact(b)*fact(a-b)) so taking logs of both sides
lcomb(a,b)=lfact(a) - lfact(b) - lfact(a-b) and then exponentiating, I get the following
comb(a,b) = exp (lfact(a) - lfact(b) - lfact(a-b))
You will have to use something other than comb(a,b), but plugging into your formula:
AF = exp (lfact(nit) - lfact(i) - lfact(nit - i)) *(Pt**i)*((1-Pt)**(nit-i))*abs((i/nit)-Pt)+AF;
See if that helps.
Steve Denham
Thank you for your answer, unfortunately it's still not working.
Do you I any idea what the problem could be ?
Thanks
Is it the same error (overflow when nit>1030)? You might consider Stirling's approximation then rather than lfact.
AF = exp ((nit * log(nit) - nit) - (i * log(i) -i) - ((nit - i) * log(nit - i) - (nit - i))) *(Pt**i)*((1-Pt)**(nit-i))*abs((i/nit)-Pt)+AF;
If it is something else, I am afraid I am out of ideas.
Steve Denham
Thanks a lot, I tried but it's still not working.
I think it might be due to the computational limit of my computer
Yeah. Stirling's approximation for nit=1030 is 7.9254710873912267781487017602238e+2655. Might be a problem expressing that.
At this point, Python or Mathematica come to mind...
Steve Denham
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.