/* Kolmogorov-Smirnov test modified for normality */ /* This program is a GAUSS version of Fortran code by Paul Johnson. */ new; cls; x=rndn(100,1); call KStest(x); proc KStest(x); local n,fx,z,d1,t,d2,dmax,KS; if ismiss(x); errorlog "Warning: missing data found."; x=packr(x); endif; n=rows(x); x=(x-meanc(x))/stdc(x); fx=cdfn(x); z=seqa(1,1,n)/n-fx; z=sortc(z,1); d1=z[n]; t=fx-(seqa(1,1,n)-1)/n; t=sortc(t,1); d2=t[n]; dmax=maxc(d1|d2); KS=dmax*(sqrt(n)+(0.85/sqrt(n))-0.01); print "stat=" KS; retp(KS); endp;