sample.prop.CI <- function(x, n) { ## Purpose: Calculate sample proportion and its confidence interval based on the Score Test ## Arguments: ## x: a count in the numerator ## n: total count in the denominator ## Return: print sample proportion and its confidence interval ## Author: Feiming Chen ## ________________________________________________ r <- prop.test(x, n, correct = FALSE) paste0(round(r$estimate, 2), " (", paste0(round(r$conf.int, 2), collapse = ","), ")") } if (F) { # Unit Test set.seed(1) sample.prop.CI(10, 100) # "0.1 (0.06,0.17)" }
Tuesday, April 6, 2021
Calculate sample proportion and its confidence interval based on the Score Test
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment