Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# number of subjects in each condition
n <- 10000
# number of replications of the study in order to check the Type I error rate
nsamp <- 10000
ps <- replicate(nsamp, {
#population mean = 0, sd = 1 for both samples, therefore, no real effect
y1 <- rnorm(n, 0, 1)
y2 <- rnorm(n, 0, 1)
tt <- ks.test(y1, y2)
tt$p.value
})
sum(ps < .05) / nsamp
# that gave me the expected 0.0466 and 0.0491 on rerun
# number of subjects in each condition
n <- 10000
# number of replications of the study in order to check the Type I error rate
nsamp <- 10000
ps <- replicate(nsamp, {
#population mean = 0, sd = 1 for both samples, therefore, no real effect
y1 <- rnorm(n, 0, 1)
tt <- ks.test(y1, 'pnorm')
tt$p.value
})
sum(ps < .05) / nsamp
# that gave me 0.0484, 0.0504 and 0.0484
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment