Confidence Intervals and Hypothesis Tests with a Consistent Layout

Computes confidence intervals and hypothesis tests for means and proportions. Every function prints its result in the same consistent three-section layout -- sample information, intermediary calculations, and the final answer -- so students always know where to look. Intended for classroom teaching, where each step of a calculation is shown, while every reported quantity is also returned in a standard R object for further use.


statelier

Confidence intervals and hypothesis tests in R, printed in a consistent layout organized for teaching.

Every result is laid out in the same three sections — sample information, intermediary calculations, and the final answer — so students always know where to look, whichever function produced it. The same functions also return every reported quantity in a standard R object for further use.

This package covers the elementary one- and two-sample procedures:

Function What it does
ci_mean() CI for a mean or a difference in means
ht_mean() t test for a mean or a difference in means
ci_prop() Wald CI for a proportion or a difference in proportions
ht_prop() z test for a proportion or a difference in proportions

The longer names ci_mean_stats(), ht_mean_stats(), ci_prop_stats() and ht_prop_stats() are kept as aliases, so existing code keeps working unchanged.

Installation

install.packages("statelier")

Example

library(statelier)

set.seed(1)
x <- rnorm(30, mean = 100, sd = 15)

ht_mean(x, null_value = 100, alpha = 0.05)
#> One-Sample Hypothesis Test for Population Mean
#> ==============================================
#>
#> Sample Information:
#> -------------------
#> Sample Mean:                  101.237
#> Sample Standard Deviation:     13.862
#> Sample Size (non-NA):              30
#> Missing Observations:               0
#>
#> Intermediary Calculations:
#> --------------------------
#> Standard Error:                 2.531
#> Degrees of Freedom:                29
#> T-Statistic:                    0.489
#>
#> Final Answer:
#> -------------
#> Null Hypothesis (mu):         100.000
#> Alternative Hypothesis: mu not equal to 100
#> P-Value:                        0.629
#> Significance Level:               5.0%
#> Conclusion: Fail to Reject Null Hypothesis
#> ==============================================

Omit alpha and the significance level and conclusion are left off, so students must compare the p-value to a significance level of their own choosing.

Assigning the result suppresses printing and keeps every number:

res <- ht_mean(x, null_value = 100)
res$p_value
#> [1] 0.629

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("statelier")

0.2.0 by Doru Cojoc, a day ago


Browse source code at https://github.com/cran/statelier


Authors: Doru Cojoc [aut, cre]


Documentation:   PDF Manual  


MIT + file LICENSE license


Suggests testthat


See at CRAN