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 | ||||
Test | Statistic | p Value | ||
Kolmogorov-Smirnov | D | 0.0819588 | Pr > D | <0.010 |
Cramer-von Mises | W-Sq | 0.2144147 | Pr > W-Sq | <0.005 |
Anderson-Darling | A-Sq | 1.2362929 | Pr > A-Sq | <0.005 |
Results from Matlab | ||||
Goodness-of-Fit Tests for Lognormal Distribution | ||||
Test | Statistic | p Value | ||
Kolmogorov-Smirnov | D | 0.082 | Pr > D | 0.1237 |
Cramer-von Mises | W-Sq | 0.2935 | Pr > W-Sq | 0.141 |
Anderson-Darling | A-Sq | 1.2409 | Pr > A-Sq | 0.0031 |
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
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.
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;
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.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.