Description Usage Arguments Value Author(s) Examples
View source: R/miscellaneous.R
Compute the n models based on n sampling of data.
| 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
)
 | 
| 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. | 
A dataframe containing the summary of all models for all iterations.
| 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)
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.