Load the galaxy dataset:

Define the logposterior as a function of G and y:
Calculating the MCMC output for 2 components:
##
## Attaching package: 'bayesmix'
## The following object is masked from 'package:Rfast':
##
## Sort
## Compiling model graph
## Declaring variables
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 82
## Unobserved stochastic nodes: 88
## Total graph size: 345
##
## Initializing model

Same for 3 components:
## Compiling model graph
## Declaring variables
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 82
## Unobserved stochastic nodes: 90
## Total graph size: 348
##
## Initializing model

Estimates of the logarithm of the marginal likelihood:
## G = 2 G = 3
## 1 -235.254 -226.6771
It is also possible to plot the overlap graphs and compute the criterion of overlap (co):

## G = 2 G = 3
## 1 2 3
This can also be done directly, without computing the THAMES:

## G = 2 G = 3
## 1 2 3