bmixfit: Fit a 'Bmix' mixture

View source: R/bmixfit.R

bmixfitR Documentation

Fit a Bmix mixture

Description

Fits a mixture of 'k' components, where each component can be either a Binomial or a Beta-Binomial random variable. This function take as input two paramters that determine the possible numer of compoennets, for both distributions, and creates all possible input combinations to fit the model.

The best mode is scored using the Integrated Classification Likelihood, an extension of the Bayesian Information Criterion. Through one parameters it is possible to switch to the Bayesian Information Criterion.

Multiple fits can be computed, and a parameter controls when the Expectation Maximization algorithm should stop.

Usage

bmixfit(
  data,
  K.Binomials = 1:2,
  K.BetaBinomials = 0,
  epsilon = 1e-08,
  samples = 2,
  score = "ICL",
  silent = FALSE,
  description = "My BMix model"
)

Arguments

data

A matrix or dataframe with two columns, the first one must represent the number of successes in the Binomial trials, the second the total number of trials.

K.Binomials

A vector of values that represents how many Binomial components should be fit to the data.By default this parameter is set to 'c(0:2)'.

K.BetaBinomials

A vector of values that represents how many Beta-Binomial components should be fit to the data. By default this parameter is set to '0'.

epsilon

The parameter that controls when the Expectation Maximization algorithm should stop. This is compared to the variation in the negative loglikelihood.

samples

Number of Expectation Maximization fits that should be computed per configuration of mixture.

score

The score for model selection, any of 'NLL', 'BIC' or 'ICL'.

silent

If 'FALSE', does not print outputs.

Value

An object of class bmix that represents a fit mixture of this package.

Examples

# The same dataset used in the package vignette
data = data.frame(successes = c(rbinom(30, 100, .4), rbinom(70, 100, .7)), trials = 100)

# BMix fit with default parameters
x = bmixfit(data)

print(x)

caravagn/BMix documentation built on May 10, 2022, 7:41 p.m.