The R
package bmixture provides
statistical tools for Bayesian estimation for the mixture of
distributions. The package implemented the improvements in the Bayesian
literature, including Mohammadi
et al. (2013) and Mohammadi
and Salehi-Rad (2012). Besides, the package contains several
functions for simulation and visualization, as well as a real dataset
taken from the literature.
You can install the latest version from CRAN using:
install.packages( "bmixture" )
require( "bmixture" )
Here is a simple example to see the performance of the package for
the Finite mixture of Normal distributions for the galaxy
dataset:
data( galaxy )
# Runing bdmcmc algorithm for the galaxy dataset
= bmixnorm( data = galaxy )
mcmc_sample
summary( mcmc_sample )
plot( mcmc_sample )
print( mcmc_sample )
Here is a simple example to see the performance of the package for the Finite mixture of Normal distributions using simulation data. First, we simulate data from the mixture of Normal with 3 components as follow:
= 500
n = c( 0 , 10 , 3 )
mean = c( 1 , 1 , 1 )
sd = c( 0.3, 0.5, 0.2 )
weight
= rmixnorm( n = n, weight = weight, mean = mean, sd = sd )
data
# plot for simulation data
hist( data, prob = TRUE, nclass = 30, col = "gray" )
= seq( -20, 20, 0.05 )
x = dmixnorm( x, weight, mean, sd )
densmixnorm
lines( x, densmixnorm, lwd = 2 )
Now, we run the ‘bdmcmc’ algorithm for the above simulation data set
= bmixnorm( data, k = 3, iter = 1000 )
bmixnorm.obj
summary( bmixnorm.obj )