Context
I am confused by the following post where the accepted answer states that :
You can't really even compare the two since the Kolmogorov-Smirnov is for a completely specified distribution (so if you're testing normality, you must specify the mean and variance; they can't be estimated from the data*), while the Shapiro-Wilk is for normality, with unspecified mean and variance.
- you also can't standardize by using estimated parameters and test for standard normal; that's actually the same thing.
Question
Imagine that I have a random sample of measurements X which I standardise using its sample mean and variance. May I use the Kolmogorov Smirnov test as a GOF test to assess normality of this random sample ?
$$ H_0 : X_{scaled} \sim N(0,1) $$
Illustration
To illustrate my question here is a code snippet in R :
# We wish to do a Goodness of Fit test that X is a random sample from a Normal Distribution N(mu,sigma^2)
X <- c(10.212, 10.103, 10.242, 10.106, 10.102, 10.095, 10.042, 10.093, 10.302, 10.111)
sample.mean <- mean(X)
sample.variance <- var(X)
# Or that standardized X (scaled.X) is a random sample from a standard normal distribution N(0,1)
scaled.X <- (X-sample.mean)/(sqrt(sample.variance))
# Kolmogorov-Smirnov Test H0 : X ~ N(0,1)
ks.test(scaled.X,alternative="two.sided",y = "pnorm")
# Do not reject the null.
# Shapiro Test
shapiro.test(scaled.X)
# Do reject the null.
Note that the KS test and the Shapiro-Wilk test gives contradictory results, hinting towards the Shapiro Wilk test being more powerful in this specific case. This is however not my main question although any comments on this is gladly welcomed.
The specific area of interest of this question is if using the KS test on a standardized random sample (with sample statistics) a sound way to evaluate the normality assumption.