-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME.Rmd
More file actions
56 lines (41 loc) · 1.51 KB
/
README.Rmd
File metadata and controls
56 lines (41 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# ciwidth
<!-- badges: start -->
<!-- badges: end -->
With `ciwidth` you can determine the sample size needed for obtaining confidence intervals for means and mean differences which has a given width with a given probability.
## Installation
You can install the development version of ciwidth from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("snhansen/ciwidth")
```
## Example
Let us calculate the sample sizes needed to obtain a 95% confidence interval for a mean of width 5, 6, 7, 8 and 10 with a probability of either 80% or 90% and a standard deviation of 10 or 15:
```{r example}
library(ciwidth)
ci_width_mean(sigma = c(10, 15), width = 5:10, prob = c(0.80, 0.90))
```
With the `plot`-argument, you can create a `ggplot2` figure:
```{r example-figure}
ci_width_mean(sigma = c(10, 15), width = 5:10, prob = c(0.80, 0.90), plot = TRUE)
```
Since this is just a `ggplot2` figure, we can customize it afterwards:
```{r example-figure-2}
library(ggplot2)
fig <- ci_width_mean(sigma = c(10, 15), width = 5:10, prob = c(0.80, 0.90), plot = TRUE)
fig <- fig +
labs(x = "CI width", y = "Sample size", color = "Probability") +
facet_wrap(~ sigma, labeller = labeller(sigma = c("10" = "Sigma: 10", "15" = "Sigma: 15")))
fig
```