/* Kolmogorov-Smirnov test for normality(Lilliefors' adjustment) */ /* This program is a GAUSS version of 'lillie.test' */ /* by Juergen Gross in library 'nortest' of R. */ new; cls; x=rndn(100,1); call Lilliefors(x); proc Lilliefors(x); local n,p,dplus,dminus,K,Kd,nd,KK,pval; if ismiss(x); errorlog "Warning: missing data found."; x=packr(x); endif; n=rows(x); x=sortc(x,1); p=cdfn((x-meanc(x))/stdc(x)); dplus=maxc(seqa(1,1,n)/n-p); dminus=maxc(p-(seqa(1,1,n)-1)/n); K=meanc(dplus|dminus); if n<=100; Kd=K; nd=n; else; Kd=K*((n/100)^0.49); nd=100; endif; pval=exp(-7.01256*Kd^2*(nd+2.78019)+2.99587*Kd*sqrt(nd+2.78019)-0.122119+0.974598/sqrt(nd)+1.67997/nd); if pval>0.1; KK=(sqrt(n)-0.01+0.85/sqrt(n))*K; if KK<=0.302; pval=1; elseif KK<=0.5; pval=2.76773-19.828315*KK+80.709644*KK^2-138.55152*KK^3+81.218052*KK^4; elseif KK<=0.9; pval=-4.901232+40.662806*KK-97.490286*KK^2+94.029866*KK^3-32.355711*KK^4; elseif KK<=1.31; pval=6.198765-19.558097*KK+23.186922*KK^2-12.234627*KK^3+2.423045*KK^4; else; pval=0; endif; endif; print "stat=" K; print "pval=" pval; retp(K); endp;