Date: Sun, 30 Aug 2009 21:19:19 -0700 Dale McLerran "SAS(r) Discussion" Dale McLerran Re: Fastest Steps for Simulating: Anderson-Darling Goodness of Fit test for Non-typical distn <6eca73440908302014p298b9358l52ef2e829617d858@mail.gmail.com> text/plain; charset=iso-8859-1

One million times? Why? I really think that is overkill. I would try to cover more parameter combinations if it were me.

But you should be able to use a single data step to generate A-D statistics for all of your parameter combinations. The code below should be pretty efficient.

%macro AD(N=); do i=1 to &N; /* The next line needs completion with the appropriate G */ _x&N{i} = G(ranuni(6923479,S)); end;

call sortn(of _X&N(*)); mu = mean(of x1-x&N); var = var(of x1-x&N); sd = sqrt(var); S=0; do i=1 to &N; S + ((2*i - 1)/&N) * (log(cdf('normal',x{i},mu,sd)) + log(1 - cdf('normal',x{&N+1-i},mu,sd))); end; AD = -&N - S; output AD_&N; %mend;

/* Generate 10000 samples of same size (N=9 in this case) following */ /* a normal distribution and compute AD statistic for each sample. */ data AD_50 AD_100 AD_200 AD_300; array _x50 {50} x1-x50; array _x100 {100} x1-x100; array _x200 {200} x1-x200; array _X300 {300} x1-x300; do S={S1 S2 S3}; /* This line needs correct specification */ do rep=1 to 10000; %AD(N=50) %AD(N=100) %AD(N=200) %AD(N=300) end; end; keep S AD; run;

/* Determine probability of observed data */ /* using simulated data AD distribution. */ proc sort data=AD_50; by S AD; run;