Help using Base SAS procedures

PROC Univariate - Goodness of fit

Reply
Occasional Contributor
Posts: 6

PROC Univariate - Goodness of fit

The P-Value and statistic value obtained for 3 Goodness of fit tests (Kolmogrov-Smirnov, Cramer-Von-Mises and Ander-Darling test) doesn't match with the value calculated from Matlab software.

Probably the table used for calculation of P-Value (or Critical value) is different because the formula for calculation of Test statistics seems to be same.

Can one guide with the table used for calculation of P-value in each test. Or wat else could be the problem....something that I'm missing on.... Plz help!!!

Results from SAS
Goodness-of-Fit Tests for Lognormal Distribution
TestStatisticp Value
Kolmogorov-SmirnovD0.0819588Pr > D<0.010
Cramer-von MisesW-Sq0.2144147Pr > W-Sq<0.005
Anderson-DarlingA-Sq1.2362929Pr > A-Sq<0.005

Results from Matlab
Goodness-of-Fit Tests for Lognormal Distribution
TestStatisticp Value
Kolmogorov-SmirnovD0.082Pr > D0.1237
Cramer-von MisesW-Sq0.2935Pr > W-Sq0.141
Anderson-DarlingA-Sq1.2409Pr > A-Sq0.0031
Respected Advisor
Posts: 2,655

Re: PROC Univariate - Goodness of fit

How did you get SAS to give the p values, which are ordinarily for tests of normality?  Did you pre-transform the data, such as adding a constant, and then taking the log?  Or am I missing something new in PROC UNIVARIATE?

If you are transforming, check what goes in, especially the constant to eliminate zeroes.  Different values will definitely affect how this will work.  And what kind of results are you seeing for the Wilcoxon test?

Steve Denham

SAS Super FREQ
Posts: 3,753

Re: PROC Univariate - Goodness of fit

Showing your program statement is always helpful to those who are trying to answer your questions.

Regarding "Why are they different," it is hard to say since I don't know what commands you submitted in SAS, nor what you did in MATLAB.  One possibility is that SAS is very careful to adjust the the test based on the number of known and unknown parameters.  Thus you will get a different test statistic for each of the following four tests.  Not all software takes known parameters into account.

proc univariate data=sim;

var x;

histogram x/

   gamma(alpha=EST sigma=EST)  /* 0 parameters known  */

   gamma(alpha=4 sigma=EST)    /* 1 shape param known */

   gamma(alpha=EST sigma=1)    /* 1 scale param known */

   gamma(alpha=4 sigma=1);     /* 2 parameters known  */

run;

@SteveDenham The UNIVARIATE procedure produces GOF statistics, including p-values for many non-normal distributions based on the ECDF. The details of the GOF tests in SAS are available in the documentation. For distributions for which the distribution of the Kolmogorov-D or Anderson-Darling W statistics is not known asymptotically, resampling methods are used to estimate p-values. You can control the number of  bootstrap resamples by using the EDFNSAMPLE= option.

Respected Advisor
Posts: 2,655

Re: PROC Univariate - Goodness of fit

Thank you .  This is one that I didn't know about and I really appreciate the heads up!

Steve Denham

Occasional Contributor
Posts: 6

Re: PROC Univariate - Goodness of fit

Both the parameters are unknwn.

I used following program in SAS:

ods select ParameterEstimates GoodnessOfFit ;

proc univariate data= Test;

   var x1;

   histogram / lognormal

ods output parameterestimates= Param_est          

run;

SAS Super FREQ
Posts: 3,753

Re: PROC Univariate - Goodness of fit

Is x1 the only variable in the Test data set?  If not, you might be looking at the EDF test for  a different variable.  To make sure, use

histogram x1 / lognormal;

The SAS documentation says that the p-value uses "probability levels similar to those given by D’Agostino and Stephens (1986)."  When you tell us what MATLAB commands you are using, perhaps a comparison will be possible.

Ask a Question
Discussion stats
  • 5 replies
  • 638 views
  • 1 like
  • 3 in conversation