Skip to main content
added 689 characters in body
Source Link
Scortchi
  • 31.6k
  • 9
  • 102
  • 281

Quicker to write the code than search for a function. You only need to

  1. Calculate plotting positions for your sample size. $\frac{k}{n+1}$ for $k =1, \ldots, n$ is a common method—or pick from the dozens of methods in ppoints.

  2. Calculate the corresponding theoretical quantiles from your distribution, whatever it is (normal, Weibull, &c), & whether its parameters are pre-specified or estimated from the data.

  3. Plot the sorted sample data against the sorted theoretical quantiles

Here's some R code:

# make up some data
rnorm(40, mean=2, sd=2) -> x
length(x) -> n
# calculate plotting positions
plot.pos <- (1:n)/(n+1)
# calculate theoretical quantiles, say from N(2,3)
qnorm(plot.pos, mean=2, sd=3) -> theor.quantiles
# sort & plot
plot(sort(theor.quantiles), sort(x))
abline(a=0,b=1)

With regard to formal tests, Stephens (1974) says that for tests of normality based on the empirical distribution function you get higher power (against some alternatives he selects as being typically of interest) when estimating the mean & variance from the data than when using the known mean & variance (comparing the observed value of the test statistic with the appropriate null distribution for each case, of course). So, perhaps surprisingly, you might want to carry out a different test when you're only interested in departures from a hypothesized shape given an assumed location & scale from when you're interested in any kind of departure from a hypothesized, fully specified, distribution.

For any goodness-of-fit test statistic that takes your fancy you can simulate its distribution under a fully specified null distribution easily enough; furthermore, EDF tests are distribution-free in this case. (It's perhaps largely a matter of historical accident that when people say "the Kolmogorov–Smirnov test" they usually mean the test for a fully specified null distribution, but when they say "the Anderson–Darling" test they usually mean the test for a normal null distribution with parameters estimated from the data.) That means you only need to run one simulation, of a uniform random variate for speed, for any given sample size & can store it for future use.

Stephens (1974), "EDF Statistics for goodness of fit and some comparisons", JASA, 69, 347

Quicker to write the code than search for a function. You only need to

  1. Calculate plotting positions for your sample size. $\frac{k}{n+1}$ for $k =1, \ldots, n$ is a common method—or pick from the dozens of methods in ppoints.

  2. Calculate the corresponding theoretical quantiles from your distribution, whatever it is (normal, Weibull, &c), & whether its parameters are pre-specified or estimated from the data.

  3. Plot the sorted sample data against the sorted theoretical quantiles

Here's some R code:

# make up some data
rnorm(40, mean=2, sd=2) -> x
length(x) -> n
# calculate plotting positions
plot.pos <- (1:n)/(n+1)
# calculate theoretical quantiles, say from N(2,3)
qnorm(plot.pos, mean=2, sd=3) -> theor.quantiles
# sort & plot
plot(sort(theor.quantiles), sort(x))
abline(a=0,b=1)

With regard to formal tests, Stephens (1974) says that for tests of normality based on the empirical distribution function you get higher power (against some alternatives he selects as being typically of interest) when estimating the mean & variance from the data than when using the known mean & variance (comparing the observed value of the test statistic with the appropriate null distribution for each case, of course). So, perhaps surprisingly, you might want to carry out a different test when you're only interested in departures from a hypothesized shape given an assumed location & scale from when you're interested in any kind of departure from a hypothesized, fully specified, distribution.

Stephens (1974), "EDF Statistics for goodness of fit and some comparisons", JASA, 69, 347

Quicker to write the code than search for a function. You only need to

  1. Calculate plotting positions for your sample size. $\frac{k}{n+1}$ for $k =1, \ldots, n$ is a common method—or pick from the dozens of methods in ppoints.

  2. Calculate the corresponding theoretical quantiles from your distribution, whatever it is (normal, Weibull, &c), & whether its parameters are pre-specified or estimated from the data.

  3. Plot the sorted sample data against the sorted theoretical quantiles

Here's some R code:

# make up some data
rnorm(40, mean=2, sd=2) -> x
length(x) -> n
# calculate plotting positions
plot.pos <- (1:n)/(n+1)
# calculate theoretical quantiles, say from N(2,3)
qnorm(plot.pos, mean=2, sd=3) -> theor.quantiles
# sort & plot
plot(sort(theor.quantiles), sort(x))
abline(a=0,b=1)

With regard to formal tests, Stephens (1974) says that for tests of normality based on the empirical distribution function you get higher power (against some alternatives he selects as being typically of interest) when estimating the mean & variance from the data than when using the known mean & variance (comparing the observed value of the test statistic with the appropriate null distribution for each case, of course). So, perhaps surprisingly, you might want to carry out a different test when you're only interested in departures from a hypothesized shape given an assumed location & scale from when you're interested in any kind of departure from a hypothesized, fully specified, distribution.

For any goodness-of-fit test statistic that takes your fancy you can simulate its distribution under a fully specified null distribution easily enough; furthermore, EDF tests are distribution-free in this case. (It's perhaps largely a matter of historical accident that when people say "the Kolmogorov–Smirnov test" they usually mean the test for a fully specified null distribution, but when they say "the Anderson–Darling" test they usually mean the test for a normal null distribution with parameters estimated from the data.) That means you only need to run one simulation, of a uniform random variate for speed, for any given sample size & can store it for future use.

Stephens (1974), "EDF Statistics for goodness of fit and some comparisons", JASA, 69, 347

added 851 characters in body
Source Link
Scortchi
  • 31.6k
  • 9
  • 102
  • 281

Quicker to write the code than search for a function. You only need to

  1. Calculate plotting positions for your sample size. $\frac{k}{n+1}$ for $k =1, \ldots, n$ is a common method—or pick from the dozens of methods in ppoints.

  2. Calculate the corresponding theoretical quantiles from your distribution, whatever it is (normal, Weibull, &c), & whether its parameters are pre-specified or estimated from the data.

  3. Plot the sorted sample data against the sorted theoretical quantiles

Here's some R code:

# make up some data
rnorm(40, mean=2, sd=2) -> x
length(x) -> n
# calculate plotting positions
plot.pos <- (1:n)/(n+1)
# calculate theoretical quantiles, say from N(2,3)
qnorm(plot.pos, mean=2, sd=3) -> theor.quantiles
# sort & plot
plot(sort(theor.quantiles), sort(x))
abline(a=0,b=1)

With regard to formal tests, Stephens (1974) says that for tests of normality based on the empirical distribution function you get higher power (against some alternatives he selects as being typically of interest) when estimating the mean & variance from the data than when using the known mean & variance (comparing the observed value of the test statistic with the appropriate null distribution for each case, of course). So, perhaps surprisingly, you might want to carry out a different test when you're only interested in departures from a hypothesized shape given an assumed location & scale from when you're interested in any kind of departure from a hypothesized, fully specified, distribution.

Stephens (1974), "EDF Statistics for goodness of fit and some comparisons", JASA, 69, 347

Quicker to write the code than search for a function. You only need to

  1. Calculate plotting positions for your sample size. $\frac{k}{n+1}$ for $k =1, \ldots, n$ is a common method—or pick from the dozens of methods in ppoints.

  2. Calculate the corresponding theoretical quantiles from your distribution, whatever it is (normal, Weibull, &c), & whether its parameters are pre-specified or estimated from the data.

  3. Plot the sorted sample data against the sorted theoretical quantiles

Here's some R code:

# make up some data
rnorm(40, mean=2, sd=2) -> x
length(x) -> n
# calculate plotting positions
plot.pos <- (1:n)/(n+1)
# calculate theoretical quantiles, say from N(2,3)
qnorm(plot.pos, mean=2, sd=3) -> theor.quantiles
# sort & plot
plot(sort(theor.quantiles), sort(x))
abline(a=0,b=1)

Quicker to write the code than search for a function. You only need to

  1. Calculate plotting positions for your sample size. $\frac{k}{n+1}$ for $k =1, \ldots, n$ is a common method—or pick from the dozens of methods in ppoints.

  2. Calculate the corresponding theoretical quantiles from your distribution, whatever it is (normal, Weibull, &c), & whether its parameters are pre-specified or estimated from the data.

  3. Plot the sorted sample data against the sorted theoretical quantiles

Here's some R code:

# make up some data
rnorm(40, mean=2, sd=2) -> x
length(x) -> n
# calculate plotting positions
plot.pos <- (1:n)/(n+1)
# calculate theoretical quantiles, say from N(2,3)
qnorm(plot.pos, mean=2, sd=3) -> theor.quantiles
# sort & plot
plot(sort(theor.quantiles), sort(x))
abline(a=0,b=1)

With regard to formal tests, Stephens (1974) says that for tests of normality based on the empirical distribution function you get higher power (against some alternatives he selects as being typically of interest) when estimating the mean & variance from the data than when using the known mean & variance (comparing the observed value of the test statistic with the appropriate null distribution for each case, of course). So, perhaps surprisingly, you might want to carry out a different test when you're only interested in departures from a hypothesized shape given an assumed location & scale from when you're interested in any kind of departure from a hypothesized, fully specified, distribution.

Stephens (1974), "EDF Statistics for goodness of fit and some comparisons", JASA, 69, 347

added 21 characters in body
Source Link
Scortchi
  • 31.6k
  • 9
  • 102
  • 281

Quicker to write the code than search for a function. You only need to

  1. Calculate plotting positions for your sample size. $\frac{k}{n+1}$ for $k =1, \ldots, n$ is a common method—or pick from the dozens of methods in ppoints.

  2. Calculate the corresponding theoretical quantiles from your distribution, whatever it is (normal, Weibull, &c), & whether its parameters are pre-specified or estimated from the data.

  3. Plot the sorted sample data against the sorted theoretical quantiles

Here's some R code:

# make up some data
rnorm(40, mean=2, sd=2) -> x
length(x) -> n
# calculate plotting positions
plot.pos <- (1:n)/(n+1)
# calculate theoretical quantiles, say from N(2,3)
qnorm(plot.pos, mean=2, sd=3) -> theor.quantiles
# sort & plot
plot(sort(theor.quantiles), sort(x))
abline(a=0,b=1)

Quicker to write the code than search for a function. You only need to

  1. Calculate plotting positions for your sample size. $\frac{k}{n+1}$ for $k =1, \ldots, n$ is a common method—or pick from the dozens of methods in ppoints.

  2. Calculate the corresponding theoretical quantiles from your distribution, whatever it is (normal, Weibull, &c), & whether its parameters are pre-specified or estimated from the data.

  3. Plot the sorted sample data against the sorted theoretical quantiles

Here's some R code:

# make up some data
rnorm(40, mean=2, sd=2) -> x
length(x) -> n
# calculate plotting positions
plot.pos <- (1:n)/(n+1)
# calculate theoretical quantiles, say from N(2,3)
qnorm(plot.pos, mean=2, sd=3) -> theor.quantiles
# sort & plot
plot(sort(theor.quantiles), sort(x))

Quicker to write the code than search for a function. You only need to

  1. Calculate plotting positions for your sample size. $\frac{k}{n+1}$ for $k =1, \ldots, n$ is a common method—or pick from the dozens of methods in ppoints.

  2. Calculate the corresponding theoretical quantiles from your distribution, whatever it is (normal, Weibull, &c), & whether its parameters are pre-specified or estimated from the data.

  3. Plot the sorted sample data against the sorted theoretical quantiles

Here's some R code:

# make up some data
rnorm(40, mean=2, sd=2) -> x
length(x) -> n
# calculate plotting positions
plot.pos <- (1:n)/(n+1)
# calculate theoretical quantiles, say from N(2,3)
qnorm(plot.pos, mean=2, sd=3) -> theor.quantiles
# sort & plot
plot(sort(theor.quantiles), sort(x))
abline(a=0,b=1)
added 20 characters in body
Source Link
Scortchi
  • 31.6k
  • 9
  • 102
  • 281
Loading
added 20 characters in body
Source Link
Scortchi
  • 31.6k
  • 9
  • 102
  • 281
Loading
added 1 character in body
Source Link
Scortchi
  • 31.6k
  • 9
  • 102
  • 281
Loading
Source Link
Scortchi
  • 31.6k
  • 9
  • 102
  • 281
Loading