Computes the informative sample size given an effect of interest and type I and II
error probabilities (alpha and beta) for Wald (W), likelihood ratio (LR),
Rao score (RS), and gradient (GR) test.
The routine supports two modes:
Either provide the return object of a previous call to invar_test()
or provide the effect size of interest along with the degrees of freedom.
opt_n(
invar_obj = NULL,
effect = NULL,
df = NULL,
alpha = 0.05,
beta = 0.05,
n_range = 10:10000
)A list of two elements:
The required sample sizes for the four tests.
The realized power, as the sample sizes are rounded to the next integer.
The matched call.
Return object of a previous call to invar_test(). Default is NULL.
If missing, values for effect and df need to be set manually.
Numeric value representing the effect size. A real number
between 0 and 1, interpreted as a proportion of pseudo-variance between persons with
different covariate values (but the same person parameter). Default is NULL.
Degrees of freedom of the test. Default is NULL.
Type I error probability. Default is 0.05.
Type II error probability. Default is 0.05.
A numeric vector specifying the sample sizes to be evaluated. Default is 10:10000).
The informative sample size is the number of observations realizing a score greater than zero and less than the maximum possible score, as these two values are not informative for the tests.
Providing the return object of a previous call to invar_test() allows
using the results of a pilot study to obtain an empirical estimate of
parameter differences between the groups.
The default search range of 10:10000 should suffice for most applications.
However, if the maximum is reached, a warning is given.
If effect and df are provided, the sample sizes of all four tests will be
equal due to their asymptotic equivalence. If an invar_obj is provided,
the sample sizes will usually differ slightly.
Note: The invar_test() function currently only supports a two-group split.
Draxler, C., & Kurz, A. (2025). Testing measurement invariance in a conditional likelihood framework by considering multiple covariates simultaneously. Behavior Research Methods, 57(1), 50.
invar_test, p_curve, p_ncurve