| Title: | Sample Size Adequacy: Joint Power, Precision, Stability and Feasibility Planning |
|---|---|
| Description: | Implements the Sample Size Adequacy (SSA) framework, in which the minimum adequate sample size is the smallest N that jointly satisfies detectability (power), precision (confidence interval width, optionally with assurance; Kelley and Rausch (2006) <doi:10.1037/1082-989X.11.4.363>), stability (relative bias) and feasibility (rate of admissible solutions). Provides closed-form predictions of the binding criterion based on unit-information asymptotic theory, generalizing Goodman and Berlin (1994) <doi:10.7326/0003-4819-121-3-199408010-00008>, a calibrated weak-identification law for the admissibility of confirmatory factor analysis solutions, and Monte Carlo verification with root finding for confirmatory factor analysis (via 'lavaan'), multiple regression and one-way ANOVA. Non-normal data are generated with the method of Vale and Maurelli (1983) <doi:10.1007/BF02293687>. An interactive 'shiny' planner is included. |
| Authors: | Cansu Ergenç Özdaş [aut, cre] (ORCID: <https://orcid.org/0000-0002-4722-0911>) |
| Maintainer: | Cansu Ergenç Özdaş <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.1.0 |
| Built: | 2026-11-29 19:48:00 UTC |
| Source: | https://github.com/cran/ssadequacy |
Solves the Fleishman (1978) system for the coefficients of
that yield a standardized variable with the
requested skewness and excess kurtosis.
fleishman_coef(skew = 0, exkurt = 0)fleishman_coef(skew = 0, exkurt = 0)
skew |
Target skewness. |
exkurt |
Target excess kurtosis. |
Named numeric vector c(a, b, c, d).
Fleishman, A. I. (1978). A method for simulating non-normal distributions. Psychometrika, 43(4), 521–532. doi:10.1007/BF02293811
fleishman_coef(2, 7)fleishman_coef(2, 7)
Uses the Vale-Maurelli (1983) extension of the Fleishman method so that the
generated variables reproduce Sigma exactly in the population while
every margin has the requested skewness and excess kurtosis.
rmvnonnorm(n, Sigma, skew = 0, exkurt = 0)rmvnonnorm(n, Sigma, skew = 0, exkurt = 0)
n |
Number of observations. |
Sigma |
Population covariance matrix. |
skew, exkurt
|
Marginal skewness and excess kurtosis (common to all variables). |
An n x p matrix with column names taken from Sigma.
Vale, C. D., & Maurelli, V. A. (1983). Simulating multivariate nonnormal distributions. Psychometrika, 48(3), 465–471. doi:10.1007/BF02293687
S <- matrix(c(1, .5, .5, 1), 2) X <- rmvnonnorm(1000, S, skew = 2, exkurt = 7) cor(X)S <- matrix(c(1, .5, .5, 1), 2) X <- rmvnonnorm(1000, S, skew = 2, exkurt = 7) cor(X)
Launch the interactive SSA planner
run_ssa_app(...)run_ssa_app(...)
... |
Passed to |
Called for its side effect of launching the app; returns the value of shiny::runApp().
if (interactive()) run_ssa_app()if (interactive()) run_ssa_app()
Computes the sample size required by each SSA criterion from unit-information asymptotics and identifies the binding criterion.
ssa_analytic( design, delta, power = 0.8, alpha = 0.05, assurance = NULL, se_cv = 1/sqrt(2), tau = 0.05, bias_const = NULL, kappa = 0.95, v = NULL )ssa_analytic( design, delta, power = 0.8, alpha = 0.05, assurance = NULL, se_cv = 1/sqrt(2), tau = 0.05, bias_const = NULL, kappa = 0.95, v = NULL )
design |
An |
delta |
Target confidence interval width (same metric as the focal parameter). |
power |
Target power |
alpha |
Two-sided significance level. |
assurance |
Optional probability |
se_cv |
Unit coefficient of variation of the estimated standard error,
|
tau |
Maximum relative bias. |
bias_const |
Second-order bias constant |
kappa |
Target rate of admissible solutions (CFA designs; uses the calibrated law in |
v |
Optional unit variances (computed with |
An object of class ssa_analytic.
Goodman, S. N., & Berlin, J. A. (1994). The use of predicted confidence intervals when planning experiments and the misuse of power when interpreting results. Annals of Internal Medicine, 121(3), 200–206. doi:10.7326/0003-4819-121-3-199408010-00008
Kelley, K., & Rausch, J. R. (2006). Sample size planning for the standardized mean difference: Accuracy in parameter estimation via narrow confidence intervals. Psychological Methods, 11(4), 363–385. doi:10.1037/1082-989X.11.4.363
# Regression: power and precision for the standardized coefficients ssa_analytic(ssa_design_regression(k = 3, R2 = .10), delta = .25) # Two-group comparison, d = .50, with assurance for the interval width ssa_analytic(ssa_design_anova(k = 2, f = .25), delta = .50, assurance = .80) # Factor model with medium loadings ssa_analytic(ssa_design_cfa(3, 5, loadings = c(.55, .60)), delta = .20)# Regression: power and precision for the standardized coefficients ssa_analytic(ssa_design_regression(k = 3, R2 = .10), delta = .25) # Two-group comparison, d = .50, with assurance for the interval width ssa_analytic(ssa_design_anova(k = 2, f = .25), delta = .50, assurance = .80) # Factor model with medium loadings ssa_analytic(ssa_design_cfa(3, 5, loadings = c(.55, .60)), delta = .20)
Runs reps Monte Carlo replications of design at sample size
n and returns the raw per-replication quantities needed to evaluate
every SSA criterion for any choice of thresholds.
ssa_cell(design, n, reps = 500, alpha = 0.05, cores = 1)ssa_cell(design, n, reps = 500, alpha = 0.05, cores = 1)
design |
An |
n |
Sample size. |
reps |
Number of replications. |
alpha |
Two-sided significance level. |
cores |
Number of cores for |
An object of class ssa_cell.
cl <- ssa_cell(ssa_design_anova(k = 2, f = .25), n = 128, reps = 200) summary(cl, delta = .5)cl <- ssa_cell(ssa_design_anova(k = 2, f = .25), n = 128, reps = 200) summary(cl, delta = .5)
Under unit-information asymptotics the sample sizes required for a
Wald test with power and for an expected two-sided
confidence interval of width on the same
parameter satisfy
Precision is the binding criterion if and only if .
The ratio does not depend on the unit variance of the estimator, so method,
model size and distribution cannot change which of the two criteria binds.
ssa_crossover(alpha = 0.05, power = 0.8)ssa_crossover(alpha = 0.05, power = 0.8)
alpha |
Two-sided significance level. |
power |
Target power. |
The crossover ratio .
ssa_crossover() # 1.399 ssa_crossover(power = .90) # 1.209ssa_crossover() # 1.399 ssa_crossover(power = .90) # 1.209
A design bundles a population model, a data generator, an estimator and the focal parameters on which all four SSA criteria are evaluated (estimand coherence: power and precision always refer to the same parameters).
ssa_design_cfa( nfactors = 3, nind = 5, loadings = c(0.55, 0.6), phi = 0.3, skew = 0, exkurt = 0, estimator = NULL ) ssa_design_regression(k = 3, R2 = 0.1, rho = 0.3, skew = 0, exkurt = 0) ssa_design_anova(k = 2, f = 0.25, skew = 0, exkurt = 0) ssa_design_from_lavaan(fit, skew = 0, exkurt = 0, estimator = NULL)ssa_design_cfa( nfactors = 3, nind = 5, loadings = c(0.55, 0.6), phi = 0.3, skew = 0, exkurt = 0, estimator = NULL ) ssa_design_regression(k = 3, R2 = 0.1, rho = 0.3, skew = 0, exkurt = 0) ssa_design_anova(k = 2, f = 0.25, skew = 0, exkurt = 0) ssa_design_from_lavaan(fit, skew = 0, exkurt = 0, estimator = NULL)
nfactors |
Number of correlated factors. |
nind |
Number of indicators per factor. |
loadings |
Standardized loadings: either one value, a range |
phi |
Common inter-factor correlation, or a full factor correlation matrix. |
skew, exkurt
|
Marginal skewness and excess kurtosis of the indicators. |
estimator |
|
k |
Number of predictors (regression) or groups (ANOVA). |
R2 |
Population coefficient of determination. |
rho |
Common predictor intercorrelation. |
f |
Cohen's f (SD of group means over the within-group SD). |
fit |
A fitted |
An object of class ssa_design: a list holding the population model, the
focal parameter values (theta) and the data-generation settings.
ssa_design_cfa(): Confirmatory factor analysis with simple structure.
ssa_design_regression(): OLS multiple regression with equicorrelated predictors and equal standardized coefficients.
ssa_design_anova(): One-way between-subjects ANOVA with equally spaced means; the focal
parameter is the standardized difference between the two extreme groups.
ssa_design_from_lavaan(): Planning population taken from a fitted 'lavaan' CFA (e.g., a pilot or
published study): uses its standardized loadings and factor correlations. Requires
simple structure with the same number of indicators per factor.
ssa_design_cfa(nfactors = 3, nind = 5, loadings = c(.55, .60)) ssa_design_regression(k = 10, R2 = .25, skew = 2, exkurt = 7) ssa_design_anova(k = 3, f = .25) fit <- lavaan::cfa("visual =~ x1 + x2 + x3\n textual =~ x4 + x5 + x6\n speed =~ x7 + x8 + x9", data = lavaan::HolzingerSwineford1939, std.lv = TRUE) ssa_design_from_lavaan(fit)ssa_design_cfa(nfactors = 3, nind = 5, loadings = c(.55, .60)) ssa_design_regression(k = 10, R2 = .25, skew = 2, exkurt = 7) ssa_design_anova(k = 3, f = .25) fit <- lavaan::cfa("visual =~ x1 + x2 + x3\n textual =~ x4 + x5 + x6\n speed =~ x7 + x8 + x9", data = lavaan::HolzingerSwineford1939, std.lv = TRUE) ssa_design_from_lavaan(fit)
Implements the calibrated weak-identification scaling law for the rate of admissible (converged, Heywood-free) maximum likelihood solutions:
with the effective per-factor sum of squared standardized loadings (a power mean
over factors that is dominated by the weakest factor, because hazards add across factors) and
the number of factors. The law was calibrated on simple-structure models with
3 to 5 factors, 3 to 5 indicators per factor, loadings .35 to .60, normal data and
ML estimation; outside that range use ssa_simulate.
ssa_feasibility(design, N) ssa_n_kappa(design, kappa = 0.95) ssa_identification_strength(design, N)ssa_feasibility(design, N) ssa_n_kappa(design, kappa = 0.95) ssa_identification_strength(design, N)
design |
An |
N |
Sample size(s). |
kappa |
Target rate of admissible solutions (for |
ssa_feasibility: predicted admissibility rate at each N;
ssa_n_kappa: the smallest N with predicted rate kappa;
ssa_identification_strength: the index at each N.
d <- ssa_design_cfa(nfactors = 3, nind = 5, loadings = c(.35, .40)) ssa_feasibility(d, N = c(100, 150, 200)) ssa_n_kappa(d, kappa = .95) ssa_identification_strength(d, N = 150)d <- ssa_design_cfa(nfactors = 3, nind = 5, loadings = c(.35, .40)) ssa_feasibility(d, N = c(100, 150, 200)) ssa_n_kappa(d, kappa = .95) ssa_identification_strength(d, N = 150)
Produces a paragraph suitable for a preregistration or a Method section
from an ssa_analytic or ssa_sim result.
ssa_report(x, verbose = TRUE, ...)ssa_report(x, verbose = TRUE, ...)
x |
An |
verbose |
Logical; print the paragraph to the console (default) or only return it. |
... |
Unused. |
A character string (invisibly when verbose = TRUE).
ssa_report(ssa_analytic(ssa_design_anova(k = 2, f = .25), delta = .5)) txt <- ssa_report(ssa_analytic(ssa_design_anova(k = 2, f = .25), delta = .5), verbose = FALSE)ssa_report(ssa_analytic(ssa_design_anova(k = 2, f = .25), delta = .5)) txt <- ssa_report(ssa_analytic(ssa_design_anova(k = 2, f = .25), delta = .5), verbose = FALSE)
Simulates the design on a grid of sample sizes, smooths each criterion with
the functional form implied by asymptotic theory, solves for the sample size
at which each criterion is met, and reports and the binding
criterion.
ssa_simulate( design, delta, power = 0.8, alpha = 0.05, assurance = NULL, tau = 0.05, kappa = 0.95, n_grid = NULL, reps = 500, cores = 1, verify = TRUE )ssa_simulate( design, delta, power = 0.8, alpha = 0.05, assurance = NULL, tau = 0.05, kappa = 0.95, n_grid = NULL, reps = 500, cores = 1, verify = TRUE )
design |
An |
delta |
Target CI width. |
power, alpha
|
Power target and significance level. |
assurance |
Optional assurance probability for the width criterion. |
tau |
Maximum absolute relative bias. |
kappa |
Minimum rate of admissible solutions. |
n_grid |
Sample sizes to simulate; by default centred on the analytic |
reps |
Replications per grid point. |
cores |
Cores for |
verify |
Logical; re-simulate at the solved |
Smoothing models: power, ;
width, ; assurance and feasibility,
; relative bias, .
An object of class ssa_sim.
s <- ssa_simulate(ssa_design_regression(k = 3, R2 = .10), delta = .25, reps = 300) s ssa_report(s)s <- ssa_simulate(ssa_design_regression(k = 3, R2 = .10), delta = .25, reps = 300) s ssa_report(s)
Returns such that .
Closed forms are used for regression and ANOVA. For CFA the variance is taken
from a 'lavaan' fit to the population covariance matrix (normal data, ML) or,
for non-normal data, from a robust (MLR) fit to one very large generated sample.
ssa_unit_variance(design, M = 2e+05)ssa_unit_variance(design, M = 2e+05)
design |
An |
M |
Size of the population-scale sample used for non-normal CFA designs. |
Numeric vector of unit variances, one per focal parameter.
ssa_unit_variance(ssa_design_regression(k = 3, R2 = .10)) ssa_unit_variance(ssa_design_anova(k = 2, f = .25)) ssa_unit_variance(ssa_design_cfa(3, 5, loadings = c(.55, .60)))ssa_unit_variance(ssa_design_regression(k = 3, R2 = .10)) ssa_unit_variance(ssa_design_anova(k = 2, f = .25)) ssa_unit_variance(ssa_design_cfa(3, 5, loadings = c(.55, .60)))
Summarize a simulated cell
## S3 method for class 'ssa_cell' summary(object, delta = NA, ...)## S3 method for class 'ssa_cell' summary(object, delta = NA, ...)
object |
An |
delta |
Precision threshold (target CI width); used for the assurance probability. |
... |
Unused. |
Named vector: feasibility (rate of admissible solutions), power (focal, mean over focal parameters), omnibus power, mean CI width, assurance P(width <= delta), relative bias, coverage, and Monte Carlo SD-based width.
summary(ssa_cell(ssa_design_regression(3, .25), n = 150, reps = 100), delta = .3)summary(ssa_cell(ssa_design_regression(3, .25), n = 150, reps = 100), delta = .3)