Description Usage Arguments Value Functions Examples
Create tables and plots for power and sample size calculations from a range of required parameters. All of the parameters accepts a range or sequence of numbers. Usable with pwr and stats::power.
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 | pwr_grid(
k = NULL,
n = NULL,
n1 = NULL,
n2 = NULL,
N = NULL,
h = NULL,
f = NULL,
f2 = NULL,
r = NULL,
w = NULL,
diff = NULL,
sigma = NULL,
d = NULL,
df = NULL,
u = NULL,
v = NULL,
sig.level = 0.05,
power = NULL,
type = NULL,
alternative = NULL
)
pwr_tidy(pwr_grid, test_function)
pwr_plot(pwr_tidy, x, y, group)
|
n |
Number of observations (per sample) |
diff |
Difference between the means |
sigma |
Standard deviation |
d |
Effect size (Cohen's d) |
sig.level |
Significance level (Type I error probability) |
power |
Power of test (1 minus Type II error probability) |
type |
Type of t test : one- two- or paired-samples |
alternative |
a character string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater" or "less" |
pwr_grid |
outcome of pwr_grid function |
test_function |
function to calculate power from pwr or stats package |
pwr_tidy |
outcome of pwr_tidy function |
x |
x axis |
y |
y axis |
group |
colour variable |
canal endemico, union y grafico
pwr_grid
:
pwr_tidy
: create table with parameters and calculations
pwr_plot
: create diagnostic plot
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 | library(tidyverse)
library(broom)
library(pwr)
library(powder)
# 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")
eg1 %>% pwr_tidy(test_function = pwr.t.test)
eg1 %>%
pwr_tidy(test_function = pwr.t.test) %>%
pwr_plot(x = diff,y = n,group = sigma)
# 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")
eg2 %>% pwr_tidy(test_function = pwr.t.test)
eg2 %>%
pwr_tidy(test_function = pwr.t.test) %>%
pwr_plot(x = n,y = power,group=diff)
# stata
# power onemean 100, n(10 20 30) power(0.8) sd(10 12.5 15)
eg3 <- pwr_grid(n=c(10,20,30),
#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")
eg3 %>% pwr_tidy(test_function = power.t.test)
eg3 %>%
pwr_tidy(test_function = power.t.test) %>%
pwr_plot(x = n,y = delta,group=sigma)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.