BookmarkSubscribeRSS Feed
Lidz
Calcite | Level 5

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
5 REPLIES 5
SteveDenham
Jade | Level 19

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

Rick_SAS
SAS Super FREQ

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.

SteveDenham
Jade | Level 19

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

Steve Denham

Lidz
Calcite | Level 5

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;

Rick_SAS
SAS Super FREQ

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.

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

What is Bayesian Analysis?

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 2049 views
  • 1 like
  • 3 in conversation