Learn R Programming

psycho (version 0.4.91)

power_analysis: Power analysis for fitted models.

Description

Compute the n models based on n sampling of data.

Usage

power_analysis(fit, n_max, n_min = NULL, step = 1, n_batch = 1,
  groups = NULL, verbose = TRUE, CI = 90, effsize = FALSE,
  effsize_rules = "cohen1988", bayes_factor = FALSE, overlap = FALSE)

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

Argument for analyze.

effsize

Argument for analyze.

effsize_rules

Argument for analyze.

bayes_factor

Argument for analyze.

overlap

rgument for analyze.

Value

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

Examples

Run this code
# 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)
  )
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab