- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I need to calculate Geom. mean and Geom. CV and I'm using PROC TTEST for it.
However, often we have cases where the following error occurs:
ERROR: Computations would cause floating point overflow.
I assume that this is caused by the confidence interval calculation leading to too small numbers, but I cannot bypass this even if not calling the CI in the procedure.
Here is an example code to test the issue:
data check;
AVAL=10.4;
output;
AVAL=1.3; *Works on AVAL=5;
output;
run;
proc ttest data=check dist=lognormal ci=NONE cl=NONE;
var aval;
ods output ConfLimits=_COUNT_STAT_GEOMM_00(rename=(GeomMean=GEOMM CV=GCV));
run;
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello @roskaasia and welcome to the SAS Support Communities!
It's indeed the upper confidence limit for the geometric coefficient of variation which is causing the issue: According to the formulas in the documentation, SAS would try to compute
sqrt(exp(s**2/cinv(0.025,1))-1)
for your sample dataset, where (using your initial test data)
s=log(10.4/1.3)/sqrt(2)
But then exp(s**2/cinv(0.025,1))=exp(2201.5136...)=1.274...E956, which exceeds constant('big')=1.797...E308 by orders of magnitude, hence the overflow error.
With 3.1934 instead of 1.3 the exp(...) term is slightly below constant('big'): 1.786...E308.
I'd suggest that you compute mean and standard deviation of the log-transformed data and then transform back to the original scale, as described in the documentation linked above:
data logcheck;
set check;
if aval>0 then log_aval=log(aval);
run;
proc summary data=logcheck;
var log_aval;
output out=logstats(drop=_:) n=n mean=m std=s;
run;
data want(drop=m s);
set logstats;
geomm=exp(m);
gcv=sqrt(exp(s**2)-1);
run;
proc print data=want;
run;
You could also compute the other statistics (confidence intervals), if needed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
aval=round(aval,0.01);
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the input! Rounding doesn't solve the issue unfortunately.
For the second dummy value in the example code, using anything less than 3.1934 will lead into the floating point overflow error.
So for example, this works just fine, creating the below output:
data check;
AVAL=10.4;
output;
AVAL=3.1934; *Works on AVAL=5 or if AVAL>=3.1934;
output;
run;
proc ttest data=check dist=lognormal;
var aval;
ods output ConfLimits=_COUNT_STAT_GEOMM_00(rename=(GeomMean=GEOMM CV=GCV));
run;
Probably the issue is that the confidence interval for the CV becomes too large when the second dummy value is less than 3.1934. But I still need to calculate the Geometric mean with the original example values, so is there any way to disable the confidence limits from this procedure, as I don't even need them?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello @roskaasia and welcome to the SAS Support Communities!
It's indeed the upper confidence limit for the geometric coefficient of variation which is causing the issue: According to the formulas in the documentation, SAS would try to compute
sqrt(exp(s**2/cinv(0.025,1))-1)
for your sample dataset, where (using your initial test data)
s=log(10.4/1.3)/sqrt(2)
But then exp(s**2/cinv(0.025,1))=exp(2201.5136...)=1.274...E956, which exceeds constant('big')=1.797...E308 by orders of magnitude, hence the overflow error.
With 3.1934 instead of 1.3 the exp(...) term is slightly below constant('big'): 1.786...E308.
I'd suggest that you compute mean and standard deviation of the log-transformed data and then transform back to the original scale, as described in the documentation linked above:
data logcheck;
set check;
if aval>0 then log_aval=log(aval);
run;
proc summary data=logcheck;
var log_aval;
output out=logstats(drop=_:) n=n mean=m std=s;
run;
data want(drop=m s);
set logstats;
geomm=exp(m);
gcv=sqrt(exp(s**2)-1);
run;
proc print data=want;
run;
You could also compute the other statistics (confidence intervals), if needed.