I am trying to generate 1000 random samples and need to put if the p-value of the test for each sample is larger than alpha in reject_collect object and if the true mean of 10 is in the CI of each sample generated. My objects currently only have 1 value. Not sure how to fix it.
reject_collect <- NULL CI_include_collect <- NULL
for ( i in c(1:1000)) { random_vector_index <- rnorm( 50, mean = 10, sd = 2)
alpha <- 0.05 mean(random_vector_index) test_results_index <- t.test(random_vector_index, mu=10, alternative = "two.sided", conf.level = 0.95) test_results_index$p.value
reject_collect <- test_results_index$p.value < alpha
CI_include_collect <- between(10, test_results_index$conf.int[1], test_results_index$conf.int[2]) }
reject_collect <- NULL
CI_include_collect <- NULL
for ( i in c(1:1000)) {
random_vector_index <- rnorm( 50, mean = 10, sd = 2)
alpha <- 0.05
mean(random_vector_index)
test_results_index <- t.test(random_vector_index, mu=10, alternative = "two.sided", conf.level = 0.95)
test_results_index$p.value
reject_collect <- test_results_index$p.value < alpha
CI_include_collect <- between(10, test_results_index$conf.int[1], test_results_index$conf.int[2])
}
Aucun commentaire:
Enregistrer un commentaire