Can someone please help me fill in the following function in R:
#data is a single vector of decimal values
normally.distributed <- function(data) {
if(dat
The Anderson-Darling test is also be useful.
library(nortest)
ad.test(data)
when you perform a test, you ever have the probabilty to reject the null hypothesis when it is true.
See the nextt R code:
p=function(n){
x=rnorm(n,0,1)
s=shapiro.test(x)
s$p.value
}
rep1=replicate(1000,p(5))
rep2=replicate(1000,p(100))
plot(density(rep1))
lines(density(rep2),col="blue")
abline(v=0.05,lty=3)
The graph shows that whether you have a sample size small or big a 5% of the times you have a chance to reject the null hypothesis when it s true (a Type-I error)