/* Durbin's Exact test for normality */ /* This program is a GAUSS version of Durbin's Exact test in 'gofnorm' */ /* (Fortran code by Paul Johnson) located in library 'fBasics' of R. */ new; cls; x=rndn(100,1); call DurbinsExact(x); proc DurbinsExact(x); local n,b,c,g,z,stat; if ismiss(x); errorlog "Warning: missing data found."; x=packr(x); endif; n=rows(x); x=sortc(x,1); x=(x-meanc(x))/stdc(x); b=cdfn(x); b=sortc(b,1); c=b[2:n]-b[1:n-1]; c=b[1]|c|(1-b[n]); c=sortc(c,1); g=seqa(n,-1,n-1).*(c[2:n]-c[1:n-1]); g=((n+1)*c[1])|g|(c[n+1]-c[n]); z=(seqa(1,1,n)/n)-cumsumc(g[1:n]); z=sortc(z,1); stat=z[n]; print "stat=" stat; retp(stat); endp;