[R] Lilliefors Test
Martina Pavlicova
pavlicov at stat.ohio-state.edu
Mon Oct 20 17:51:44 CEST 2003
> Is it not true that the Shapiro Wilks test implemented in the package
> ctest requires the assumption that the population variance of the
> variable is known?
I am not sure about this one...
> Is it also not true that the Lilliefors is not a test of normality
> as such, but is rather a correction of the p-value for the
> Kolmogorov Smirnov test?
Yes, that is right. Here is the code:
null.hyp <- function(x) {
## one observation from the null distribution
mu <- mean(x)
sigma <- sd(x)
foo <- ks.test(x=x, y="pnorm", mean = mu, sd = sigma)
sim <- foo$statistic
sim
}
create.null <- function(n=n, rep=100000){
## creates a sample of length 'rep' from null distribution
null <- numeric(rep)
for(i in 1:rep){
null[i] <- null.hyp(rnorm(n))
}
null
}
Lilliefors.test <- function(sample=data, rep){
n <- length(sample)
null.dist <- create.null(n, rep)
res <- list()
res$statistic <- null.hyp(sample)
res$p.value <- sum(null.dist>res$statistic)/rep
res
}
Thanks,
Martina Pavlicova
--------------------------------------------------------------------------
Department of Statistics Office Phone: (614) 292-1567
1958 Neil Avenue, 304E Cockins Hall FAX: (614) 292-2096
The Ohio State University E-mail: pavlicov at stat.ohio-state.edu
Columbus, OH 43210-1247 www.stat.ohio-state.edu/~pavlicov
> | -----Original Message-----
> | From: kjetil at entelnet.bo [mailto:kjetil at entelnet.bo]
> | Sent: Friday, October 17, 2003 3:33 PM
> | To: R HELP; Martina Pavlicova
> | Subject: Re: [R] Lilliefors Test
> |
> |
> | On 17 Oct 2003 at 13:59, Martina Pavlicova wrote:
> |
> | There is shapiro.test in package ctest, which have much better power
> | properties than Lillefors test. So there is no need to have
> | Lilliefors test in R, except for archeological interest.
> |
> | Kjetil Halvorsen
> |
> | >
> | > Hello everybody,
> | >
> | > I would like to perform a test for normality (without specifying the
> | > mean a variance) on the sample data (80 observations). I found that
> | > Lilliefors test is appropriate. Does anybody have it
> | programmed already,
> | > or is there a function for this test in R?
> | >
> | > Thank you very much,
> | >
> | > Martina Pavlicova
> | >
More information about the R-help
mailing list