https://github.com/avallecam/powder
A Tidy Extension for Power Analysis
Science Score: 23.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
✓Academic publication links
Links to: zenodo.org -
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (15.5%) to scientific vocabulary
Keywords
power-analysis
pwr-package
rstats
sample-size
tidyverse
Last synced: 5 months ago
·
JSON representation
Repository
A Tidy Extension for Power Analysis
Basic Info
- Host: GitHub
- Owner: avallecam
- License: other
- Language: R
- Default Branch: master
- Homepage: https://avallecam.github.io/powder/
- Size: 450 KB
Statistics
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 3
- Releases: 2
Topics
power-analysis
pwr-package
rstats
sample-size
tidyverse
Created about 6 years ago
· Last pushed almost 5 years ago
Metadata Files
Readme
Contributing
License
Code of conduct
Support
README.Rmd
---
output:
github_document:
#df_print: kable
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
warning = FALSE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# powder
**Author:** [Andree Valle Campos](https://twitter.com/avallecam)
**License:** [MIT](https://opensource.org/licenses/MIT)
[](https://www.tidyverse.org/lifecycle/#experimental)
[](https://cran.r-project.org/package=powder)
[](https://zenodo.org/badge/latestdoi/240771164)
## Overview
The goal of `powder` is to extend __power__ and __sample size__ calculations:
- for _more than one set_ of parameters, and
- create tidy output _tables_ and _plots_ from them.
## Installation
You can install the developing version of `powder` using:
```r
if(!require("devtools")) install.packages("devtools")
devtools::install_github("avallecam/powder")
```
## Quick example
This is a basic example which shows you how to solve a common problem:
```{r example,eval=TRUE,message=FALSE}
library(tidyverse)
library(broom)
library(pwr)
library(powder)
```
```{r}
#example("pwr.2p.test")
pwr.2p.test(h=0.3,n=80,sig.level=0.05,alternative="greater")
pwr_grid(h=0.3,n=seq(80,90,5),sig.level=0.05,alternative="greater") %>%
pwr_tidy(test_function = pwr.2p.test)
pwr_grid(h=seq(0.3,0.5,0.1),n=seq(80,90,5),sig.level=0.05,alternative="greater") %>%
pwr_tidy(test_function = pwr.2p.test)
```
## Core structure
`powder` consist of three main functions:
- `pwr_grid`: creates a tibble from all combination of input parameters using `tidyr::expand_grid`.
- `pwr_tidy`: creates a `broom::tidy()` output from the calculations of all input parameters using `purrr::pmap`.
- `pwr_plot`: create a `ggplot` with input parameters and calculated value (sample size, power or effect size)
## More examples
### One set of parameters
```{r}
diff <- 10
sigma <- 10
delta <- diff/sigma
pwr.t.test(d = delta, power = 0.8, type = "one.sample")
# sample - power plot
#pwr.t.test(d = delta, power = 0.8, type = "one.sample") %>% plot()
```
### More than one set of parameters
#### sample size
```{r}
# stata
# power onemean 20, diff(10 20 30) sd(10 12.5 15)
eg1 <- pwr_grid(n = NULL,
diff = c(10,20,30),
sigma = c(10,12.5,15),
d = NULL,
sig.level = 0.05,
power = 0.8,
type = "one.sample",
alternative = "two.sided")
#create tidytable
eg1 %>% pwr_tidy(test_function = pwr.t.test)
#create ggplot
eg1 %>%
pwr_tidy(test_function = pwr.t.test) %>%
pwr_plot(x = diff,y = n,group = sigma)
```
#### power
```{r}
# stata
# power onemean 20, diff(5 (5) 15) sd(10) n(10 (2) 20)
eg2 <- pwr_grid(n = seq(from = 10,to = 20,by = 2),
diff = seq(from = 5,to = 15,by = 5),
sigma = 10,
d = NULL,
sig.level = 0.05,
#power = 0.8,
type = "one.sample",
alternative = "two.sided")
#create tidytable
eg2 %>% pwr_tidy(test_function = pwr.t.test)
#create ggplot
eg2 %>%
pwr_tidy(test_function = pwr.t.test) %>%
pwr_plot(x = n,y = power,group=diff)
```
## References
Stephane Champely (2018). pwr: Basic Functions for Power
Analysis. R package version 1.2-2.
https://CRAN.R-project.org/package=pwr
## Citation
```{r}
citation("powder")
```
Owner
- Name: Andree Valle Campos
- Login: avallecam
- Kind: user
- Location: Lima, Perú
- Website: https://avallecam.github.io/
- Twitter: avallecam
- Repositories: 3
- Profile: https://github.com/avallecam
pron: él/he/his, peruano, tusán.
GitHub Events
Total
Last Year
Issues and Pull Requests
Last synced: 12 months ago
All Time
- Total issues: 3
- Total pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Total issue authors: 1
- Total pull request authors: 0
- Average comments per issue: 0.33
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- avallecam (3)