| Type: | Package |
| Title: | Sample Size Adequacy: Joint Power, Precision, Stability and Feasibility Planning |
| Version: | 0.1.0 |
| 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. |
| License: | GPL (≥ 3) |
| URL: | https://github.com/cansuergenc/ssadequacy |
| BugReports: | https://github.com/cansuergenc/ssadequacy/issues |
| Encoding: | UTF-8 |
| Language: | en-US |
| Depends: | R (≥ 4.1) |
| Imports: | lavaan (≥ 0.6-12), stats, parallel |
| Suggests: | shiny, testthat (≥ 3.0.0), knitr, rmarkdown |
| VignetteBuilder: | knitr |
| Config/testthat/edition: | 3 |
| RoxygenNote: | 7.3.1 |
| NeedsCompilation: | no |
| Packaged: | 2026-11-08 12:23:30 UTC; root |
| Author: | Cansu Ergenç Özdaş
|
| Maintainer: | Cansu Ergenç Özdaş <cansuergenc7@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-11-29 11:10:08 UTC |
Fleishman power-method coefficients
Description
Solves the Fleishman (1978) system for the coefficients of
Y = a + bZ + cZ^2 + dZ^3 that yield a standardized variable with the
requested skewness and excess kurtosis.
Usage
fleishman_coef(skew = 0, exkurt = 0)
Arguments
skew |
Target skewness. |
exkurt |
Target excess kurtosis. |
Value
Named numeric vector c(a, b, c, d).
References
Fleishman, A. I. (1978). A method for simulating non-normal distributions. Psychometrika, 43(4), 521–532. doi:10.1007/BF02293811
Examples
fleishman_coef(2, 7)
Generate multivariate (non-)normal data with a given covariance matrix
Description
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.
Usage
rmvnonnorm(n, Sigma, skew = 0, exkurt = 0)
Arguments
n |
Number of observations. |
Sigma |
Population covariance matrix. |
skew, exkurt |
Marginal skewness and excess kurtosis (common to all variables). |
Value
An n x p matrix with column names taken from Sigma.
References
Vale, C. D., & Maurelli, V. A. (1983). Simulating multivariate nonnormal distributions. Psychometrika, 48(3), 465–471. doi:10.1007/BF02293687
Examples
S <- matrix(c(1, .5, .5, 1), 2)
X <- rmvnonnorm(1000, S, skew = 2, exkurt = 7)
cor(X)
Launch the interactive SSA planner
Description
Launch the interactive SSA planner
Usage
run_ssa_app(...)
Arguments
... |
Passed to |
Value
Called for its side effect of launching the app; returns the value of shiny::runApp().
Examples
if (interactive()) run_ssa_app()
Closed-form bottleneck analysis
Description
Computes the sample size required by each SSA criterion from unit-information asymptotics and identifies the binding criterion.
Usage
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
)
Arguments
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 |
Value
An object of class ssa_analytic.
References
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
Examples
# 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)
Simulate one design cell
Description
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.
Usage
ssa_cell(design, n, reps = 500, alpha = 0.05, cores = 1)
Arguments
design |
An |
n |
Sample size. |
reps |
Number of replications. |
alpha |
Two-sided significance level. |
cores |
Number of cores for |
Value
An object of class ssa_cell.
Examples
cl <- ssa_cell(ssa_design_anova(k = 2, f = .25), n = 128, reps = 200)
summary(cl, delta = .5)
Power-precision crossover ratio
Description
Under unit-information asymptotics the sample sizes required for a
Wald test with power \pi and for an expected two-sided
(1-\alpha) confidence interval of width \delta on the same
parameter \theta satisfy
N_\delta / N_\pi = [ r^* / r ]^2, \quad r = \delta/|\theta|,\quad
r^* = 2 z_{1-\alpha/2} / (z_{1-\alpha/2} + z_\pi).
Precision is the binding criterion if and only if r < r^*.
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.
Usage
ssa_crossover(alpha = 0.05, power = 0.8)
Arguments
alpha |
Two-sided significance level. |
power |
Target power. |
Value
The crossover ratio r^*.
Examples
ssa_crossover() # 1.399
ssa_crossover(power = .90) # 1.209
Design constructors
Description
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).
Usage
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)
Arguments
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 |
Value
An object of class ssa_design: a list holding the population model, the
focal parameter values (theta) and the data-generation settings.
Functions
-
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.
Examples
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)
Identification strength and predicted admissibility for CFA designs
Description
Implements the calibrated weak-identification scaling law for the rate of admissible (converged, Heywood-free) maximum likelihood solutions:
-\log P(\mathrm{admissible}) \approx A\, F^{c_3} (N S^{c_2/c_1})^{c_1},
with S 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 F
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.
Usage
ssa_feasibility(design, N)
ssa_n_kappa(design, kappa = 0.95)
ssa_identification_strength(design, N)
Arguments
design |
An |
N |
Sample size(s). |
kappa |
Target rate of admissible solutions (for |
Value
ssa_feasibility: predicted admissibility rate at each N;
ssa_n_kappa: the smallest N with predicted rate kappa;
ssa_identification_strength: the index N S^{c_2/c_1} at each N.
Examples
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)
Sample size justification text
Description
Produces a paragraph suitable for a preregistration or a Method section
from an ssa_analytic or ssa_sim result.
Usage
ssa_report(x, verbose = TRUE, ...)
Arguments
x |
An |
verbose |
Logical; print the paragraph to the console (default) or only return it. |
... |
Unused. |
Value
A character string (invisibly when verbose = TRUE).
Examples
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)
Monte Carlo SSA analysis with root finding
Description
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 N^* and the binding
criterion.
Usage
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
)
Arguments
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 |
Details
Smoothing models: power, \Phi^{-1}(\pi_N) = a + b\sqrt{N};
width, \log W_N = a + b \log N; assurance and feasibility,
\mathrm{logit}(p_N) = a + b \log N; relative bias, \mathrm{RelBias}_N = c/N.
Value
An object of class ssa_sim.
Examples
s <- ssa_simulate(ssa_design_regression(k = 3, R2 = .10), delta = .25, reps = 300)
s
ssa_report(s)
Unit (per-observation) asymptotic variance of the focal estimators
Description
Returns v_j such that \mathrm{Var}(\hat\theta_j) \approx v_j / N.
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.
Usage
ssa_unit_variance(design, M = 2e+05)
Arguments
design |
An |
M |
Size of the population-scale sample used for non-normal CFA designs. |
Value
Numeric vector of unit variances, one per focal parameter.
Examples
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
Description
Summarize a simulated cell
Usage
## S3 method for class 'ssa_cell'
summary(object, delta = NA, ...)
Arguments
object |
An |
delta |
Precision threshold (target CI width); used for the assurance probability. |
... |
Unused. |
Value
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.
Examples
summary(ssa_cell(ssa_design_regression(3, .25), n = 150, reps = 100), delta = .3)