Reputation: 188
It's possible to automatise this (using a loop, a function or something)? Currently I'm doing all the work "manually" (in other words, step by step), and it's very annoying for me. I use kstest().
Consider the null hypothesis H0 : X ∼ N(0, 1).
For different values of µ (for instance µ = 0, 0.25, 0.50, 0.75, 1,) and for different values of n (for instance n = 25, 50, 100), do the following steps:
Thank you so much.
Upvotes: 0
Views: 351
Reputation: 2455
I wrote a function to get the proportion of number for accepting null hypothesis, when you input the $\mu$, n and $\alpha$:
library(stats)
anxo <- function(mu, n, alpha){
prop <- 0
for (i in 1:n) {
x <- rnorm(1000, mu, 1)
if (ks.test(x, pnorm)$p.value > alpha) {
prop <- prop + 1
}
}
return(prop/n)
}
Upvotes: 1