Statistical Procedures

Programming the statistical procedures from SAS
BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
roskaasia
Calcite | Level 5

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;

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

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.

View solution in original post

3 REPLIES 3
Ksharp
Super User
Maybe you need to round this variable before PROC TTEST .

aval=round(aval,0.01);
roskaasia
Calcite | Level 5

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;

roskaasia_0-1684936607620.png

 

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?

FreelanceReinh
Jade | Level 19

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.

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 3048 views
  • 1 like
  • 3 in conversation