power_analysis: Power analysis for fitted models.

Description Usage Arguments Value Author(s) Examples

View source: R/miscellaneous.R

Description

Compute the n models based on n sampling of data.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
power_analysis(
  fit,
  n_max,
  n_min = NULL,
  step = 1,
  n_batch = 1,
  groups = NULL,
  verbose = TRUE,
  CI = 90
)

Arguments

fit

A lm or stanreg model.

n_max

Max sample size.

n_min

Min sample size. If null, take current nrow.

step

Increment of the sequence.

n_batch

Number of iterations at each sample size.

groups

Grouping variable name (string) to preserve proportions. Can be a list of strings.

verbose

Print progress.

CI

Confidence level.

Value

A dataframe containing the summary of all models for all iterations.

Author(s)

Dominique Makowski

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
## Not run: 
library(dplyr)
library(psycho)

fit <- lm(Sepal.Length ~ Sepal.Width, data = iris)

results <- power_analysis(fit, n_max = 300, n_min = 100, step = 5, n_batch = 20)

results %>%
  filter(Variable == "Sepal.Width") %>%
  select(n, p) %>%
  group_by(n) %>%
  summarise(
    p_median = median(p),
    p_mad = mad(p)
  )

## End(Not run)

neuropsychology/psycho.R documentation built on Jan. 25, 2021, 7:59 a.m.