BetaMixture-class | R Documentation |
Model data on the interval [0,1] as a mixture of an arbitrary number of beta distributions.
BetaMixture(datavec, K = 2, forever = 100, epsilon = 0.001,
relative = 0.001, debug = FALSE)
## S4 method for signature 'BetaMixture'
summary(object, ...)
## S4 method for signature 'BetaMixture'
hist(x, mixcols = 1:7, ...)
datavec |
The observed vector of data points (between 0 and 1). |
K |
The number of mixture components to fit. |
forever |
The maximum number of iterations of the algorithm. |
epsilon |
The minimum change of parameters that must be observed in order to continue iterating. |
relative |
The minimum relative change of parameters that must be observed in order to continue iterating. |
debug |
A local valuecontrolling whethe to print out intermediate steps. |
x |
In the |
mixcols |
A vector of colors used to show differnt components. Recycled as necessary. |
object |
Object of class |
... |
Extra arguments for generic routines. |
Given a data set consisting of values in the interval [0,1], we want to
model it as a mixture of K
beta distributions:
f(x) = \sum_{i=1}^K \phi_i B(\nu_i, \omega_i)
f(X) = sum phi[u] B(nu[i], omega[i])
where the non-negative frequencies or weights of the components sum to
1 (that is, \sum_{i=1}^K \phi_i = 1
).
We fit such a model using en Expectation-Maximation (EM) algorithm.
To accomplish this goal, we must introduce a matrix 431Z
of
latent assignments of each of the $N$ observation to the $K$
components. In the current implementation, we intialize teh
assignments by dividing the range of the observed data into $K$
subintervals of equal width, and assign the elemnts in the Kth
subinterval to component $K$. (Warning: This may change in later
versions.) We then alternate between the M-step (finding a maximum
likelihood estimate of the parameters of the beta distributions given
Z), and the E-step (estimating the weights \phi
by
averaging the columns of Z). Iterations continue up to the number
specified by forever
times, or until the log likelihood changes
by less than the amount specified by epsilon
.
The BetaMixture
constructor returns an object of the indicated
class.
The graphical method hist
and the summary
method
invisibly return the object on which it was invoked.
Although objects can be created directly using new
, the most
common usage will be to pass a vector of unit interval values to the
BetaMixture
function.
datavec
:input data vector of values between 0 and 1.
phi
:vector of non-negative component frequencies; will sum to 1.
mle
:2\times K
matrix of parameters of the $K$ beta
mixture components.
Z
:N\times K
matrix of the probability for each of
the $N$ observations to arise from beta mixture component $K$. Each
row will sum to 1.
loglike
:The log likelihood of the fitted model.
converged
:A logical value indicating where the EM algorithm converged.
Prints a summary of the BetaMixture
object. This includes (1) the frequency/weight of each component, (2)
the parameters of each beta distribution, (3) an indicator of
convergence, and (4) the log-likelihood of the fimal model.
Kevin R. Coombes krc@silicovore.com
showClass("BetaMixture")
set.seed(73892)
datavec <- c(rbeta(130, 1, 4),
rbeta(170, 7, 4))
model <- BetaMixture(datavec)
summary(model)
hist(model, breaks=35)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.