Main functions
Package interpretCI have three main functions
1. meanCI(), propCI()
The main function is meanCI() and propCI(). The meanCI() function estimate confidence interval of a mean or mean difference. The propCI() function estimate confidence interval of a proportion or difference in proportion. Both functions can take raw data or summary statistics.
# With raw data
meanCI(mtcars,mpg)
call: meanCI.data.frame(x = mtcars, mpg)
method: One sample t-test
alternative hypothesis:
true mean is not equal to 0
Results
# A tibble: 1 × 7
m se DF lower upper t p
<chr> <chr> <chr> <chr> <chr> <chr> <chr>
1 20.09062 1.0654 31 17.91768 22.26357 18.857 < 2.2e-16
# With raw data, Perform one-sample t-test
meanCI(mtcars,mpg,mu=23)
call: meanCI.data.frame(x = mtcars, mpg, mu = 23)
method: One sample t-test
alternative hypothesis:
true mean is not equal to 23
Results
# A tibble: 1 × 7
m se DF lower upper t p
<chr> <chr> <chr> <chr> <chr> <chr> <chr>
1 20.09062 1.0654 31 17.91768 22.26357 -2.7307 0.01033
The meanCI function estimate confidence interval of mean without raw data. For example, you can answer the following question.
meanCI(n=150,m=115,s=10,alpha=0.01)
call: meanCI.default(n = 150, m = 115, s = 10, alpha = 0.01)
method: One sample t-test
alternative hypothesis:
true mean is not equal to 0
Results
# A tibble: 1 × 7
m se DF lower upper t p
<chr> <chr> <chr> <chr> <chr> <chr> <chr>
1 115 0.8165 149 112.8696 117.1304 140.85 < 2.2e-16
You can specify confidence interval with alpha argument and suggested true mean with mu argument and select alternative hypothesis with alternative argument. You can see the full story in the vignette named “Confidence interval for a mean”.
You can estimate mean difference with or without raw data.
meanCI(iris,Petal.Width,Petal.Length)
call: meanCI.data.frame(x = iris, Petal.Width, Petal.Length)
method: Welch Two Sample t-test
alternative hypothesis:
true unpaired differences in means is not equal to 0
Results
# A tibble: 1 × 6
control test DF CI t p
<chr> <chr> <chr> <chr> <chr> <chr>
1 Petal.Width Petal.Length 202.69 -2.56 [95CI -2.87; -2.25] -16.297 < 2.2e-16
You can answer the following question about difference of means.
=meanCI(n1=100,n2=100,m1=200,s1=40,m2=190,s2=20,mu=7,alpha=0.05,alternative="greater")
x x
call: meanCI.default(n1 = 100, n2 = 100, m1 = 200, s1 = 40, m2 = 190, s2 = 20, mu = 7, alpha = 0.05, alternative = "greater")
method: Welch Two Sample t-test
alternative hypothesis:
true unpaired differences in means is greater than 7
Results
# A tibble: 1 × 6
control test DF CI t p
<chr> <chr> <chr> <chr> <chr> <chr>
1 x y 145.59 10.00 [95CI 2.60; Inf] 0.67082 0.2517
You can see the full story in the vignette named “Hypothesis test for a difference between means”.
Similarly, propCI() function can estimate confidence interval of proportion or difference in two proportions.
propCI(n=100,p=0.73,P=0.8,alpha=0.01)
$data
# A tibble: 1 × 1
value
<lgl>
1 NA
$result
alpha n df p P se critical ME lower upper
1 0.01 100 99 0.73 0.8 0.04 2.575829 0.1030332 0.6269668 0.8330332
CI z pvalue alternative
1 0.73 [99CI 0.63; 0.83] -1.75 0.08011831 two.sided
$call
propCI(n = 100, p = 0.73, P = 0.8, alpha = 0.01)
attr(,"measure")
[1] "prop"
2. plot()
The plot() function draw a estimation plot with the result of meanCI() function. You can see many examples on the following sections.
3.interpret()
You can generate documents explaining the statistical result step by step. You can see several vignettes in this package and they are made by interpret() function. For example, you can answer the following question.
=propCI(n1=150,n2=100,p1=0.71,p2=0.63,P=0,alternative="greater")
x x
$data
# A tibble: 1 × 2
x y
<lgl> <lgl>
1 NA NA
$result
alpha p1 p2 n1 n2 DF pd se critical ME lower
1 0.05 0.71 0.63 150 100 248 0.08 0.06085776 1.644854 0.1001021 -0.0201021
upper CI ppooled sepooled z pvalue
1 0.1801021 0.08 [95CI -0.02; 0.18] 0.678 0.06032081 1.326242 0.09237975
alternative
1 greater
$call
propCI(n1 = 150, n2 = 100, p1 = 0.71, p2 = 0.63, P = 0, alternative = "greater")
attr(,"measure")
[1] "propdiff"
The interpret() function generate the document explaining statistical result step-by-step automatically and show this on RStudio viewer or default browser. It is the same document as the vignette named “Hypothesis test for a proportion”.
interpret(x)