From ceccc9ab9482db1c251768357c91e95bb7b7f487 Mon Sep 17 00:00:00 2001 From: davharris Date: Fri, 15 May 2015 19:43:42 -0700 Subject: [PATCH] Is this way of explaining prop.test clearer? --- inst/themes/default/prop.test.Rmd | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/inst/themes/default/prop.test.Rmd b/inst/themes/default/prop.test.Rmd index 6ec65fd..45dece4 100644 --- a/inst/themes/default/prop.test.Rmd +++ b/inst/themes/default/prop.test.Rmd @@ -86,15 +86,15 @@ stmt3 <- paste0( "The observed difference in proportions is ", - x$estimate[2] - x$estimate[1], + signif(x$estimate[2] - x$estimate[1], 3), ". The observed proportion for the first group is ", - x$estimate[1], + signif(x$estimate[1], 3), " (", prettyNum(x1, big.mark=","), " events out of a total sample size of ", prettyNum(n1, big.mark=","), "). For the second group, the observed proportion is ", - x$estimate[2], + signif(x$estimate[2], 3), " (", prettyNum(x2, big.mark=","), ", out of a total sample size of ", @@ -125,8 +125,8 @@ stmt4 <- } ``` -`r stmt1`. Using a significance level of `r 1 - attr(x$conf.int, "conf")`, we `r if (x$p.value < 1 - attr(x$conf.int, "conf")) "reject" else "do not reject"` the null hypothesis, and `r stmt2`. `r stmt3`. +`r stmt1`. Using a significance level of `r 1 - signif(attr(x$conf.int, "conf"), 3)`, we `r if (x$p.value < 1 - signif(attr(x$conf.int, "conf"), 3)) "reject" else "do not reject"` the null hypothesis, and `r stmt2`. `r stmt3`. -The confidence interval for the true `r if (onesamp) "population proportion" else "difference in population proportions"` is (`r tidyx$conf.low`, `r tidyx$conf.high`). This interval will contain the true `r if(onesamp) "population proportion" else "difference in population proportions"` 95 times out of 100. +The confidence interval for the true `r if (onesamp) "population proportion" else "difference in population proportions"` is (`r signif(tidyx$conf.low, 3)`, `r signif(tidyx$conf.high, 3)`). Intervals generated with this procedure will contain the true `r if(onesamp) "population proportion" else "difference in population proportions"` `r round(attr(x$conf.int, "conf.level") * 100)` times out of 100. -The p-value for this test is `r x$p.value`. This, formally, is defined as the probability -- if the null hypothesis is true -- of observing a `r if (onesamp) "sample proportion" else "difference in sample proportions"` that is as or more extreme than the `r if (onesamp) "sample proportion" else "difference in sample proportions"` from this data set. In this case, this is the probability -- if the true `r if (onesamp) paste0("population proportion is ", x$null.value) else "population proportions are equal"` -- of observing a `r if (onesamp) "sample proportion" else "difference in sample proportions"` that is greater than `r stmt4`. +The p-value for this test is `r x$p.value`. In other words: if the true `r if (onesamp) "sample proportion" else "difference in sample proportions"` were exactly `r ifelse(is.null(x$null.value), 0, x$null.value)`, and we collected 100 replicate data sets, we would find a discrepancy this large (or larger) in about `r round(x$p.value * 100)` of these 100 cases.