Wednesday, October 12, 2011

Tests of agreement with normality, comparing distributions

Kolmogorov-Smirnov test (KS test) for normality, "Do x and y come from the same distribution?"

( see ks.test() in R )

x <- rnorm(50)
y <- runif(30)
ks.test(x, y)

you get a small-pvalue so reject the hypothesis that the distributions are the same, therefore two distributions are different.

small p-value = different

or

Shapiro-Wilk normality test

( see shapiro.test() in R )

or

visually using QQ plot (Q-Q plot, see qqnorm() and qqplot() )  x: empirical data, y: theoretical data, ideally, data should lie close to the diagonal

cran.r-project.org/doc/contrib/Ricci-distributions-en.pdf

No comments: