Learn R Programming

bmixture

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.

Installation

You can install the latest version from CRAN using:

install.packages( "bmixture" )
require( "bmixture" )

Example 1: Finite mixture of Normal distributions using real world data

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      
mcmc_sample = bmixnorm( data = galaxy )

summary( mcmc_sample ) 
plot( mcmc_sample )
print( mcmc_sample )

Example 2: Finite mixture of Normal distributions using simulatoin data

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:

n      = 500
mean   = c( 0  , 10 , 3   )
sd     = c( 1  , 1  , 1   )
weight = c( 0.3, 0.5, 0.2 )
    
data = rmixnorm( n = n, weight = weight, mean = mean, sd = sd )
   
# plot for simulation data      
hist( data, prob = TRUE, nclass = 30, col = "gray" )
    
x           = seq( -20, 20, 0.05 )
densmixnorm = dmixnorm( x, weight, mean, sd )
      
lines( x, densmixnorm, lwd = 2 )  

Now, we run the 'bdmcmc' algorithm for the above simulation data set

bmixnorm.obj = bmixnorm( data, k = 3, iter = 1000 )
    
summary( bmixnorm.obj ) 

Copy Link

Version

Install

install.packages('bmixture')

Monthly Downloads

280

Version

1.7

License

GPL (>= 2)

Maintainer

Abdolreza Mohammadi

Last Published

May 11th, 2021

Functions in bmixture (1.7)

summary.bmixgamma

Summary function for S3 class "bmixgamma"
summary.bmixnorm

Summary function for S3 class "bmixnorm"
bmixt

Sampling algorithm for mixture of t-distributions
plot.bmixgamma

Plot function for S3 class "bmixgamma"
mixt

Mixture of t-distribution
plot.bmixnorm

Plot function for S3 class "bmixnorm"
plot.bmixt

Plot function for S3 class "bmixt"
print.bmixt

Print function for S3 class "bmixt"
bmixture-internal

Internal bmixture functions and datasets
summary.bmixt

Summary function for S3 class "bmixt"
rdirichlet

Random generation for the Dirichlet distribution
print.bmixnorm

Print function for S3 class "bmixnorm"
print.bmixgamma

Print function for S3 class "bmixgamma"
mixgamma

Mixture of Gamma distribution
mixnorm

Mixture of Normal distribution
bmixgamma

Sampling algorithm for mixture of gamma distributions
galaxy

Galaxy data
bmixture-package

Bayesian Estimation for Finite Mixture of Distributions
bmixnorm

Sampling algorithm for mixture of Normal distributions