Determine the necessary sample size for a structural equation model study
so that the confidence interval for every parameter of interest is
sufficiently narrow in the same study, or, given a sample size, return how
narrow the set of intervals can be expected to be. This is the accuracy in
parameter estimation (AIPE) counterpart of
ss_power_composite_sem: where that function plans for every
parameter to be statistically significant jointly, this one plans for
every parameter to be estimated with a confidence interval no wider than
desired, the goal when the research questions concern the magnitudes of
the effects rather than their existence. The parameters of interest are
any labeled parameters of a lavaan analysis model, structural paths,
loadings, covariances, or quantities defined with := such as an
indirect effect, and any subset of them can make up the set.
ss_aipe_composite_sem(
model,
Sigma = NULL,
pop_model = NULL,
mu = NULL,
parameters = NULL,
desired_width,
conf_level = 0.95,
assurance = NULL,
N = NULL,
G = 1000,
seed = NULL,
...
)A data.frame (a dmar_tbl) with term and
value columns: the necessary_N (or supplied
specified_N), the composite_assurance (the proportion of
replications in which every interval was simultaneously within its
desired width, reported under both criteria), then for each parameter
its mean_width_<label>, its marginal
width_within_desired_<label> proportion, its
desired_width_<label>, and its purported
population_<label> value under the analysis model, followed by
conf_level, the requested replications, the
converged_replications the summary is based on, and, when
supplied, the assurance.
A single character string giving the free analysis model in
lavaan model syntax (see model.syntax), the model
that would be fit to the data. Each parameter of interest must carry a
parameter label so it can be referred to by name, for example
"f2 ~ b*f1" labels the structural path b, and
"ab := a*b" defines an indirect effect from the labeled paths
a and b.
Population covariance matrix of the observed variables, with
row and column names matching the observed variables in model. It
is typically obtained from a fully fixed population model via
cov_sem. Supply exactly one of Sigma or
pop_model.
A single character string giving the population model in
lavaan model syntax with every parameter fixed to its population value,
from which cov_sem derives Sigma (and the
population means, when the model has a mean structure). The fixed
values are values the researcher posits (from theory, prior studies, or
pilot data), never sample estimates. Supply exactly one of Sigma
or pop_model.
Optional population means of the observed variables, used with
Sigma: a named numeric vector with one entry per observed
variable, or an unnamed vector in the row order of Sigma. The
default NULL is zero means. Means matter only when the analysis
model has a mean structure (an intercept term such as s ~ 1, as
in a latent growth curve model); when pop_model is supplied its
mean structure provides the means and mu must not also be given.
Character vector of the parameter labels that make up
the set. The default NULL uses every user-labeled parameter in
model, in order of appearance, so labeling exactly the parameters
of interest is the simplest way to state the set.
The desired full confidence interval width for each parameter of interest: a single value applied to every parameter, or a named numeric vector with one entry per parameter label. An unnamed vector of several widths is not accepted, so a width can never silently attach to the wrong parameter.
Confidence level of each interval (default 0.95).
The desired probability that a single study yields
confidence intervals no wider than desired for every parameter of
interest simultaneously (a value in [0.5, 1)), or NULL (the
default) to plan against the expected widths instead; see Details.
Sample size; if supplied, the realized interval widths at that N are summarized rather than a sample size planned.
Number of converged Monte Carlo replications per evaluated sample
size (default 1000). The simulation error of each estimated proportion
is about \(\sqrt{p(1 - p)/G}\); raise G for a sharper answer.
Optional integer seed for reproducibility. The default
NULL uses the current state of the random number generator; a
supplied seed is set internally and the prior state restored on exit.
Additional arguments passed to sem,
both when the population values are resolved and for every Monte Carlo
fit (for example std.lv = TRUE or missing = "listwise").
A robust estimator such as "MLM" cannot be used here: the same
arguments reach the setup fit, which is always from summary statistics,
and lavaan refuses a robust estimator there. The Monte Carlo data are
multivariate normal by construction, so a robust estimator would buy
nothing.
Ken Kelley [email protected]
AIPE planning for a single targeted SEM parameter is available in closed
form (Lai & Kelley, 2011; ss_aipe_sem_path), but most
studies estimate several effects and report all of them; a design is only
as informative as its widest interval of interest. This function plans for
the set by a priori Monte Carlo simulation (Muthén &
Muthén, 2002; Maxwell, Kelley, & Rausch, 2008): for a candidate
N, G data sets are drawn from the multivariate normal
population with covariance matrix Sigma, the analysis model is fit
to each, and each parameter's Wald confidence interval width, twice
\(z_{1 - \alpha/2}\) times its standard error, is recorded. Because the
estimates share one fitted model, the widths are dependent; the simulation
reflects that dependence exactly, at the stated N, with no
asymptotic shortcut.
Two planning criteria are available. With assurance = NULL the
necessary sample size is the smallest N at which the mean simulated
width of every parameter's interval is at or below its desired width, the
expected-width criterion of the AIPE framework applied to each member of
the set. Widths vary from sample to sample around their means, so each
interval separately lands at or below its desired width in roughly half
of the realizations. That is a statement about one interval at a time,
not about the set: the probability that every interval is narrow
enough at once falls well below one half as soon as more than one
parameter binds, and falls further the more parameters are targeted and
the more weakly their widths move together. Planning the whole set to a
stated probability is exactly what assurance is for. Supplying
assurance plans against the
joint event instead: the smallest N at which the proportion of
replications where every interval is simultaneously within its desired
width reaches the assurance. The joint event is contained in each marginal
event, so its probability is at most the smallest per-parameter
proportion, and the width_within_desired_<label> rows show which
parameter binds the design.
When N is NULL the search starts at the largest of the
per-parameter closed-form sample sizes (the no-assurance approximation
ss_aipe_sem_path uses, computed from the asymptotic
variances before any simulation), brackets the crossing geometrically, and
bisects to adjacent integers, each candidate evaluated with its own
G replications. A planning call therefore fits the analysis model
several thousand times at the default G, and even at the smallest
admissible G the search runs for several seconds, so the example
below evaluates a stated N, which is the cheap half of the method.
A planning call is the same call with N left out: supplying
assurance plans against the joint event, and leaving
assurance out as well plans against the expected widths; either way
the first row of the result is necessary_N rather than
specified_N. The vignette
vignette("composite_sem_planning", package = "DMAR") works through
both planning calls for a mediation model and a latent growth curve
model, with reference values computed at G = 10000.
Each reported proportion carries a simulation standard error of about
\(\sqrt{p(1 - p)/G}\), and the necessary sample size inherits that
uncertainty; raising G narrows it, and reporting the seed makes a
plan reproducible.
Lai, K., & Kelley, K. (2011). Accuracy in parameter estimation for targeted effects in structural equation modeling: Sample size planning for narrow confidence intervals. Psychological Methods, 16(2), 127--148. tools:::Rd_expr_doi("10.1037/a0021764")
Maxwell, S. E., Delaney, H. D., & Kelley, K. (2027). Designing experiments and analyzing data: A model comparison perspective (4th ed.). Routledge.
Maxwell, S. E., Kelley, K., & Rausch, J. R. (2008). Sample size planning for statistical power and accuracy in parameter estimation. Annual Review of Psychology, 59, 537--563. tools:::Rd_expr_doi("10.1146/annurev.psych.59.103006.093735")
Muthén, L. K., & Muthén, B. O. (2002). How to use a Monte Carlo study to decide on sample size and determine power. Structural Equation Modeling, 9(4), 599--620. tools:::Rd_expr_doi("10.1207/S15328007SEM0904_8")
Rosseel, Y. (2012). lavaan: An R package for structural equation modeling. Journal of Statistical Software, 48(2), 1--36. tools:::Rd_expr_doi("10.18637/jss.v048.i02")
ss_power_composite_sem for the same set of
parameters planned for joint statistical significance;
cov_sem for deriving Sigma from a fully fixed
population model; ss_aipe_sem_path and
ss_aipe_sem_path_sensitivity for a single targeted path.
Other AIPE sample size planning:
ss_aipe_c_sensitivity(),
ss_aipe_cliff_delta(),
ss_aipe_cliff_delta_sensitivity(),
ss_aipe_equivalence_r(),
ss_aipe_equivalence_r_sensitivity(),
ss_aipe_equivalence_smd(),
ss_aipe_equivalence_smd_sensitivity(),
ss_aipe_icc(),
ss_aipe_icc_sensitivity(),
ss_aipe_indirect_effect(),
ss_aipe_indirect_effect_sensitivity(),
ss_aipe_mixed_effects_sensitivity(),
ss_aipe_omega_squared(),
ss_aipe_omega_squared_sensitivity(),
ss_aipe_partial_r(),
ss_aipe_partial_r_sensitivity(),
ss_aipe_pcm_sensitivity(),
ss_aipe_r(),
ss_aipe_r_sensitivity(),
ss_aipe_reliability_sensitivity(),
ss_aipe_semipartial_r(),
ss_aipe_semipartial_r_sensitivity()
# A mediation model whose research questions concern the magnitudes of
# both individual paths and the indirect effect. The population model
# fixes every parameter to its purported population value.
pop_model <- "
f1 =~ 1*y1 + 0.8*y2 + 0.8*y3
f2 =~ 1*y4 + 0.8*y5 + 0.8*y6
f3 =~ 1*y7 + 0.8*y8 + 0.8*y9
f2 ~ 0.4*f1
f3 ~ 0.5*f2 + 0.2*f1
f1 ~~ 1*f1
f2 ~~ 0.84*f2
f3 ~~ 0.7*f3
y1 ~~ 0.5*y1; y2 ~~ 0.5*y2; y3 ~~ 0.5*y3
y4 ~~ 0.5*y4; y5 ~~ 0.5*y5; y6 ~~ 0.5*y6
y7 ~~ 0.5*y7; y8 ~~ 0.5*y8; y9 ~~ 0.5*y9
"
# The analysis model labels the two paths and defines the indirect
# effect; all three make up the set of interest.
analysis_model <- "
f1 =~ y1 + y2 + y3
f2 =~ y4 + y5 + y6
f3 =~ y7 + y8 + y9
f2 ~ a*f1
f3 ~ b*f2 + cp*f1
ab := a*b
"
# Realized interval widths at N = 200, with the indirect effect held to a
# narrower interval than the paths through a named vector of widths. Each
# interval lands within its desired width in most of the replications, yet
# all three do so together in far fewer of them: that joint proportion,
# reported as composite_assurance, is what a design of this kind has to be
# planned against. G = 20 keeps the example quick; a reported plan
# deserves the default G = 1000 or more.
ss_aipe_composite_sem(model = analysis_model, pop_model = pop_model,
parameters = c("a", "b", "ab"),
desired_width = c(a = 0.35, b = 0.40, ab = 0.25),
N = 200, G = 20, seed = 113)
Run the code above in your browser using DataLab