I use Kolmogorov-Smirnov, Cramer-von Mises and Anderson-Darling tests to examine the normality of residuals of an OLS regression. It puzzles me that R and SAS, despite giving the same test-statistics for all tests, produce quite different p values. Below is a summary of my results
Test | Test-Statistic | p-value in R | p-value in SAS
Kolmogorov-Smirnov| 0.12607 | 0.3506 | 0.038
Cramer-von Mises | 0.14958 | 0.3919 | 0.023
Anderson-Darling | 0.80307 | 0.4782 | 0.037
The R commands that I used to generate the results are
ks.test(model$residuals, 'pnorm',mean(model$residuals), sd(model$residuals))
library(goftest)
ad.test(model$residuals, 'pnorm',mean(model$residuals), sd(model$residuals))
cvm.test(model$residuals, 'pnorm',mean(model$residuals), sd(model$residuals))
The following codes in SAS are part of a macro to generate the results
data _ar_norm2_(drop=testlab);
set _ar_normality_(where=(testlab='D') keep=testlab pvalue;
run;
data _ar_norm3_(drop=testlab);
set _ar_normality_(where=(testlab='W-Sq') keep=testlab pvalue;
run;
data _ar_norm4_(drop=testlab);
set _ar_normality_(where=(testlab='A-Sq') keep=testlab pvalue;
run;
What is the root cause of this difference?
Edit
Thank you very much Glen_b! Your answer is spot on.
library(nortest)
lillie.test(model$residuals)
ad.test(model$residuals)
cvm.test(model$residuals)
p-value = 0.0382
p-value = 0.03513
p-value = 0.02311