Reproducibility of BIC results in latent class analysis via mclust package in R

214 Views Asked by At

I am conducting a latent class analysis in R using the mclust package. I supplied codes for BIC to select the best fitting model or optimal number of classes, but noticed that the solution is not reproducible since it gives inconsistent output any time I rerun the same codes. For instance as shown below, I initially run the code and it yields a VVV model with 7 classes as the best fitting model. Other candidate best fitting models include VVV,6 and EVE, 8 (shown below):

enter image description here

I tried running the same code again and it suggests different best fitting models, i.e. EVE,9, EVE,8 and EVI,9 as reported below

enter image description here

My question is about how to resolve this problem to allow for reproducibility of results. I greatly appreciate any help on this.

1

There are 1 best solutions below

0
On

Are you setting your seed prior to running your code during testing? If not, use:

set.seed(42) # or whatever number you want...

this should allow you to get reproducible results.