CTU-Bern / presize

Precision Based Sample Size Calculation
https://ctu-bern.github.io/presize/
GNU General Public License v3.0
15 stars 13 forks source link

Add paired t-test, add documentation, and add some unit tests #102

Closed qpmnguyen closed 1 year ago

qpmnguyen commented 1 year ago

Summary: This pull request is for simple support for paired t-tests in prec_meandiff. In this case, a paired t-test of difference-in-means would compute the confidence interval around the mean (paired) differences using the standard deviation of the (paired) differences. This value would be specified in sd1. As such, we do not use sd2 and expect n1 and n2 to be equal (r = 1). A source for the equation is here.

$$ \bar{d} = t{\alpha/2, n - 1} \cdot \frac{SD{\bar{d}}}{\sqrt{n}} $$

I attempted to affect the code base minimally by specifying this "paired" option as part of the variance argument. This is because there isn't really a paired t-test with unequal variances since the test is concerned with the variance of differences. As such, it makes sense for paired to be a separate option to equal and unequal.

Note: I did not update anything related to pkgdown.

A couple of reminders:

aghaynes commented 1 year ago

Thanks for the thoughtful PR.

For cases like this though, one would use prec_mean instead of prec_meandiff, which implements essentially exactly the formula you have implemented. We feel that modifying the documentation (and shiny app) to point the user to prec_mean in this case is probably sufficient.

qpmnguyen commented 1 year ago

Ah, that totally makes sense.

Thank you for adding documentation. I can close out this PR.

aghaynes commented 1 year ago

Thanks!