Skip to contents

The numerical reliability of statistical software has been studied since benchmark data with certified results made it measurable (McCullough 1998; Filliben and Possolo 1999). Benchmark studies have since assessed and compared the accuracy of widely used packages on these reference problems (Keeling and Pavur 2007). Finite mixture models are among the hardest cases. Their likelihood is multimodal, their class labels are not identified, their estimates can lie on the boundary of the parameter space, and their standard errors and selection criteria depend on conventions that differ between programs (McLachlan and Peel 2000). When three established programs for latent class cluster analysis were applied to a single dataset, they returned three different solutions (Haughton, Legrand and Woolford 2009). A user of such software has, in general, no means of telling which answer is the correct one.

The science of computational modelling separates two questions about a program (Oberkampf and Roy 2010). Verification asks whether the program solves its equations correctly, that is, whether it computes the likelihood, the estimates, the standard errors and the derived statistics that its method defines. Validation asks whether the model, as computed, describes the system it is meant to describe. For statistical software the second question takes a specific form: whether estimates computed from data generated by a known process recover that process (Cook, Gelman and Rubin 2006). latents addresses both questions for every function it exports.

latents is developed within Dynalytics, a framework for the rigorous analysis of the dynamics of dynamical systems (Saqr, López-Pernas and Misiejuk 2026). Dynalytics is grounded in a scientific contract: every analytical claim must be matched by evidence appropriate to its structure, scope and complexity. Within Dynalytics, software is held to the same contract. Implementations are benchmarked against established references at tight numerical tolerances and tested on simulated data with known generating mechanisms. CarmNote, the framework’s portable, single-file analytical environment written in JavaScript (Saqr and López-Pernas 2026), follows the same discipline: its engines are verified against R, Python, SPSS, Mplus, NIST reference datasets and published results, and each comparison records the reference value, the computed value and its tolerance. This article states how the contract is met for latents 1.4.7 and what evidence supports it.

At this build, 40,098 current checks compare latents with 4 commercial programs, 18 R packages and 18 published analyses on 672 distinct datasets, and 0 disagree without a documented cause. Known parameters are recovered from 650 simulated datasets. All 10 function families meet the four required references defined below.

The standard of evidence

The standard adopted for latents is the strictest that the available references allow. It rests on six principles, each of which closes a way in which a verification record can overstate agreement.

The reference must be independent of the implementation. Agreement with code that shares the implementation’s assumptions, or its author, establishes little. latents is therefore compared with programs written by others: the R packages that implement the same models, and above all Mplus and Latent GOLD, the commercial programs in which latent class, profile and transition models are most often estimated and whose output defines practice in the applied literature. Each function must agree with an R package, with Mplus and with Latent GOLD. Published analyses and the output of Stata and SAS are further sources. A program counts once, however many of its outputs are used, and agreement on a model with a single class confirms only the arithmetic of a regression or a density, so it is reported without counting as a source.

The criterion must be fixed before the comparison. Every tolerance is set before the reference values are read, usually at half a unit of the last digit the reference prints, so that the outcome cannot be adjusted to the result. For simulation, the criteria for bias and interval coverage are fixed before the first replicate is drawn.

The comparison must be complete. latents is compared on every quantity a reference reports: the log likelihood, the parameter count, every estimate and standard error, the criteria, the posteriors and the classifications. Its arguments are varied over every option they accept. Its composite functions are checked at each step of their composition.

A disagreement must have a cause. A difference between latents and a reference is accepted only when it is explained by the documented behaviour of the reference: a local maximum, a stopping rule that halts before convergence, or a different definition of a statistic. The explanation is written in a register beside the comparison. It expires when the difference disappears, so that no excuse can outlive its reason, and a difference in the number of parameters is never excused, because it indicates a different model.

Evidence must be current. Every result is saved with checksums of the package source and of the result itself. A result counts only when both match the present source, so a change in the code withdraws the credit of every result obtained before it until the comparison is run again.

The evidence must be able to fail. Tests run on a machine separate from the one on which the code is written. A skipped or erroring test earns no credit. A failed replicate in a simulation is counted. Fits report non-convergence, boundary estimates and failed starts as classed warnings, and inference that the likelihood cannot support is refused.

Layers of evidence

The evidence is organised in layers. Each layer detects a class of error that the others cannot, and a function is considered verified when it passes all of them.

Layer 1. Equivalence with independent implementations

The first layer compares latents with other implementations of the same model on the same data. 18 R packages serve as references, among them poLCA, glca, multilevLCA, depmixS4, mclust, LMest, seqHMM, flexmix and lcmm. A harness of 24 suites runs latents and each package on shared datasets and compares every output column (10,837 current checks). Equivalence tests compare individual models in detail, one reference per test (14,709 checks). Before every comparison the fitted classes are matched to the reference’s classes by the permutation that minimises the distance between their parameters.

Layer 2. The commercial reference programs

The second layer compares latents with the programs whose output defines practice. Latent GOLD 6.1 is run on the data latents fits, and its listings are kept with their inputs and checksums. Mplus output comes from runs of the Mplus 9 demonstration version, from the output posted with the examples of the Mplus User’s Guide (Muthén and Muthén 1998–2017) and from the Mplus pages of the UCLA Statistical Methods and Data Analytics group. Stata output is that of the examples of its gsem manual, and SAS output that of PROC LCA, PROC FMM and PROC TRAJ as printed in their documentation and in tutorials. A program’s conventions are reproduced before its numbers are compared. Mplus computes robust standard errors without the small-sample factor of the sandwich estimator, PROC LCA reports its criteria on the deviance scale, and Latent GOLD normalises its entropy statistic by the entropy of the class sizes (Vermunt and Magidson 2016). This layer contributes 3,368 checks, and its 16 registers of explained differences hold 47 entries in all.

References against which latents is verified and validated.
Reference Kind Function families Current checks
Mplus commercial program 10 18,157
Latent GOLD commercial program 10 10,370
SAS commercial program 5 296
Stata commercial program 2 96
mclust R package 4 3,027
depmixS4 R package 5 2,448
poLCA R package 2 1,976
glca R package 3 611
multilevLCA R package 2 574
flexmix R package 2 532
LMest R package 1 395
mitools R package 1 166
MoEClust R package 2 80
Rmixmod R package 3 78
mixtools R package 3 74
mice R package 1 62
sandwich R package 1 56
BayesLCA R package 1 33
randomLCA R package 2 32
EMCluster R package 1 30
mitml R package 1 20
seqHMM R package 1 8
Published analyses published 7 178
simulab (known parameters) simulation recovery 11 543

Layer 3. Published analyses

Numbers printed in papers and books are reproduced from their data. These include Goodman’s latent class models and the worked examples published with poLCA, mclust, LMest and lcmm. A published analysis adds a source and anchors the comparison to a result that its authors have already defended.

Layer 4. Recovery of known parameters

The fourth layer validates the estimates. The simulab package draws data from latent class, latent profile, two-level, hidden Markov, regression mixture and growth mixture models with known parameters. Each design is replicated 10 to 100 times with fixed seeds, latents is fitted to every replicate, and the estimates are compared with the generating values. A parameter is recovered when the mean estimate lies within 3.5 Monte Carlo standard errors of its true value (Morris, White and Crowther 2019) and when the share of 95% confidence intervals containing it lies within the central 99.9% binomial range. Selection functions are judged by how often they choose the generating number of classes, and the bootstrap likelihood-ratio test by its rejection rates under two and three generating classes. At this build 278 recovery checks over 650 simulated datasets are current.

Recovery tests methods as well as code. The three-step estimator of covariate effects (r3step(), R3STEP in Mplus) produced intervals for the class intercepts that covered the true values in 84% and 88% of replicates. The estimator treats the classification of the first step as fixed, and its standard errors omit that step’s uncertainty (Bakk, Oberski and Vermunt 2014). The standard errors of latents equal those of Mplus to every printed digit, so the shortfall is a property of the method, and it is reported as one.

Layer 5. Invariance under transformation

Equivalence on a fixed dataset cannot detect an error that two programs share, or one that appears only in data neither program was shown. Metamorphic testing addresses both, by applying a transformation whose effect on every output is known in advance (Segura et al. 2016). latents is refitted after a permutation of rows, after groups, categories and indicators are renamed, after category order is reversed, after a change of units with scale factors from 10−510^{-5} to 10610^{6}, after every unit is duplicated and after groups of zero weight are added. Every output table of the refitted model must equal the original carried through the same transformation (875 checks).

Layer 6. Adversarial data and the search for the maximum

Well-behaved examples rarely expose a defect. Adversarial suites simulate the data on which mixture software fails: a category observed in three rows, classes that never use a category, a class of nine rows, weakly separated classes, near-singular covariances, indicators eleven orders of magnitude apart, more parameters than observations and likelihoods with many local maxima. Each case separates computation from search. Started at the reference’s solution, latents must remain at that mode; started from its own search, it must reach a maximum at least as high. Seed-stability suites refit models under six seeds and report the spread of the maximised log likelihood. The likelihood, its gradient and its information are rebuilt from the fitted tables by independent code and differentiated numerically (1,282 checks).

Layer 7. Refusal of invalid input

A wrong answer returned without warning is the most damaging failure of statistical software. latents defines 103 classes of condition, each documented with the input that raises it. Of the 1,542 assertions in its test suites that an input is refused, 1,340 require a specific class, so a refusal for the wrong reason fails. A refusal-parity suite passes each degenerate input through every function that accepts it and requires the same class from each (58 checks).

Layer 8. Coverage of every argument

The layers above test each function at a few settings. The argument sweep fits every function at each option of each argument, on several datasets, and checks every combination against a reference that does not use the likelihood code of latents: another package, the likelihood rebuilt from the result tables, or a closed form. It contains 12 modules and 8,312 current checks, and a check that cannot be attributed to a function and a reference stops it.

Layer 9. Composite functions

Class enumeration (enumerate_lca(), enumerate_lpa(), enumerate_classes(), compare_models()) and the pooling of multiply imputed analyses (pool_imputations()) estimate no model of their own. They fit core models and add a layer of computation. Each is verified at every step of its composition. An identity test requires every fit inside it to equal the direct fit of the core function exactly, so that the evidence for the core function applies. The added computation is compared with independent implementations: the information criteria and classification statistics with Latent GOLD, Mplus, mclust and poLCA, and Rubin’s rules with mice, mitools and mitml. The purpose of the function is validated by recovery.

Coverage by function

The table gives, for each function, the number of datasets on which each required reference agrees with latents, the number of independent sources and the current checks. Composite functions meet the R, Mplus and Latent GOLD requirements through their core functions.

Required references by function: datasets on which each agrees.
Function R Mplus Latent GOLD simulab recovery Sources Checks Failed
lpa() 81 212 213 100 9 15,797 0
multilpa() 3 56 85 40 5 8,020 0
lca() 75 77 71 100 10 6,779 0
multilca() 8 16 18 40 4 5,410 0
lta() 22 4 6 100 5 2,870 0
mixture_regression() 14 1 7 100 6 1,046 0
mixture_regression(random =) no 5 3 50 3 953 0
three_step() / r3step() 3 70 79 100 4 2,849 0
bootstrap_lrt() / VLMR 1 63 62 30 4 5,492 0
enumerate_*() / compare_models() 6 2 2 60 10 341 0
pool_imputations() 2 via core fits (56) via core fits (85) 30 3 766 0

Datasets are counted once per function. Across functions there are 672 distinct datasets and 650 simulated datasets from 12 simulation designs and seed sets. The 16,781 checks of independent code, invariance and refusal are reported separately and do not count as sources.

Scope

The verification covers every exported function that estimates a model or computes a statistic from one. Plots, printed summaries and argument handling are covered by the unit tests in tests/testthat/ (270 files), which check their structure and their refusals. The comparisons with Mplus, Latent GOLD, Stata and SAS run from listings kept in the source repository, outside the checks of the package on CRAN, so the package depends on none of these programs.

Documented divergences

A divergence between latents and a reference is reported with its cause and its treatment.

Reference Divergence Treatment
Mplus MLR standard errors omit the small-sample factor n/(n−1)n/(n-1) of the sandwich estimator latents’ robust errors are scaled by (n−1)/n\sqrt{(n-1)/n} before comparison
Mplus TECH11 builds its null model by deleting the first class and weights the statistic differently likelihood-ratio statistics are compared; p-values are not
Mplus, Stata local maxima at some numbers of classes registered with the higher maximum latents reaches
Latent GOLD Entropy R² is 1−EN/(nH)1 - EN/(n\,H), with HH the entropy of the class sizes; latents and Mplus report 1−EN/(nlog⁡K)1 - EN/(n \log K) the entropy ENEN is compared, and Latent GOLD’s statistic is rebuilt by its definition
SAS PROC LCA EM stops when no parameter changes by more than 10−610^{-6}, short of the maximum on flat likelihoods an EM with the same rule reproduces every printed estimate to its fourth decimal
SAS PROC LCA criteria are reported on the deviance scale reproduced from latents’ log likelihood
SAS PROC TRAJ printed standard errors carry an undocumented factor N/(N−q)\sqrt{N/(N-q)} measured to every printed digit and applied
SAS PROC FMM equal-variance grids stop at lower maxima registered with the higher maxima
flexmix the Gaussian M-step divides by nn minus the rank, so its fixed point is not the maximum likelihood estimate the step is replaced in the comparison
R3STEP, in latents and Mplus intervals for class intercepts treat the first step as fixed reported as a property of the method
lcmm 2.2.2 returns no subject-specific predictions comparisons use lcmm 2.2.1
latents parameter_inference(boundary = "fix") held nothing in transition fits, which were refused when a probability lay on its bound homogeneous transition fits now hold it; their conditional standard errors agree with a numerical Hessian of the likelihood over the free coordinates; general transition fits still refuse

References

Bakk, Z., Oberski, D. L., & Vermunt, J. K. (2014). Relating latent class assignments to external variables: Standard errors for correct inference. Political Analysis, 22(4), 520–540. https://doi.org/10.1093/pan/mpu003

Cook, S. R., Gelman, A., & Rubin, D. B. (2006). Validation of software for Bayesian models using posterior quantiles. Journal of Computational and Graphical Statistics, 15(3), 675–692. https://doi.org/10.1198/106186006X136976

Filliben, J., & Possolo, A. (1999). Statistical reference datasets (NIST Standard Reference Database 140). National Institute of Standards and Technology. https://doi.org/10.18434/T43G6C

Haughton, D., Legrand, P., & Woolford, S. (2009). Review of three latent class cluster analysis packages: Latent Gold, poLCA, and MCLUST. The American Statistician, 63(1), 81–91. https://doi.org/10.1198/tast.2009.0016

Keeling, K. B., & Pavur, R. J. (2007). A comparative study of the reliability of nine statistical software packages. Computational Statistics & Data Analysis, 51(8), 3811–3831. https://doi.org/10.1016/j.csda.2006.02.013

McCullough, B. D. (1998). Assessing the reliability of statistical software: Part I. The American Statistician, 52(4), 358–366. https://doi.org/10.1080/00031305.1998.10480597

McLachlan, G. J., & Peel, D. (2000). Finite mixture models. Wiley. https://doi.org/10.1002/0471721182

Morris, T. P., White, I. R., & Crowther, M. J. (2019). Using simulation studies to evaluate statistical methods. Statistics in Medicine, 38(11), 2074–2102. https://doi.org/10.1002/sim.8086

Muthén, L. K., & Muthén, B. O. (1998–2017). Mplus user’s guide (8th ed.). Los Angeles, CA: Muthén & Muthén.

Oberkampf, W. L., & Roy, C. J. (2010). Verification and validation in scientific computing. Cambridge University Press. https://doi.org/10.1017/CBO9780511760396

Saqr, M., & López-Pernas, S. (2026). CarmNote: A portable, reproducible, single-file computational software purely in JavaScript. In Proceedings of the 26th International Symposium on Computers in Education (SIIE 2026).

Saqr, M., López-Pernas, S., & Misiejuk, K. (2026). Dynalytics: The birth of a framework for rigorous analytics of dynamical systems. In M. Saqr, K. Misiejuk, & S. López-Pernas (Eds.), Innovations in analytics of learning dynamics (pp. 3–17). Communications in Computer and Information Science. Springer. https://doi.org/10.1007/978-3-032-34157-0_1

Segura, S., Fraser, G., Sánchez, A. B., & Ruiz-Cortés, A. (2016). A survey on metamorphic testing. IEEE Transactions on Software Engineering, 42(9), 805–824. https://doi.org/10.1109/TSE.2016.2532875

Vermunt, J. K., & Magidson, J. (2016). Technical guide for Latent GOLD 5.1: Basic, advanced, and syntax. Belmont, MA: Statistical Innovations Inc.