Objects of class norMix
represent finite mixtures of
(univariate) normal (aka Gaussian) distributions. Methods for
construction, printing, plotting, and basic computations are provided.
1 2 3 4 5 6 7 8 9 10 11 12 
mu 
numeric vector of length K, say, specifying the means μ of the K normal components. 
sig2 
deprecated! numeric vector of length K,
specifying the variances σ^2 of the K normal
components. Do specify 
sigma 
numeric vector of length K, specifying the standard deviations σ of the K normal components. 
w 
numeric vector of length K, specifying the mixture proportions p[j] of the normal components, j = 1,…,K. Defaults to equal proportions 
name 
optional name tag of the result (used for printing). 
long.name 
logical indicating if the 
obj,x 
an object of class 
i,j,drop 
for indexing, see the generic 
... 
further arguments passed to methods. 
The (one dimensional) normal mixtures, R objects of class
"norMix"
, are constructed by norMix
and tested for by
is.norMix
. m.norMix()
returns the number of mixture
components; the mean()
method for class "norMix"
returns the (theoretical / true) mean E[X] and
var.norMix()
the true variance E[(X E[X])^2] where
X ~ <norm.mixt>.
The subsetting aka “extract” method (x[i,j]
; for generic
[
)—when called as x[i,]
—will typically return a
"norMix"
object unless matrix indexing selects only one row in
which case x[i, , drop=FALSE]
will return the normal mixture
(of one component only).
For further methods (density, random number generation, fitting, ...), see below.
norMix
returns objects of class "norMix"
which are
currently implemented as 3column matrix with column names mu
,
sigma
, and w
, and further attributes.
The user should rarely need to access the underlying structure
directly.
For estimation of the parameters of such a normal mixture,
we provide a smart parametrization and an efficient implementation of
the direct MLE or also the EM algorithm, see
norMixMLE()
which includes norMixEM()
.
Martin Maechler
dnorMix
for the density,
pnorMix
for the cumulative distribution
and the quantile function (qnorMix
), and
rnorMix
for random numbers and
plot.norMix
, the plot method.
MarronWand
has the MarronWand densities as normal mixtures.
norMixMLE()
and norMixEM()
provide fitting
of univariate normal mixtures to data.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22  ex < norMix(mu = c(1,2,5))# defaults: sigma = 1, equal proportions ('w')
ex
plot(ex, p.comp = TRUE)# looks like a mixture of only 2; 'p.comp' plots components
## The 2nd MarronWand example, see also ?MW.nm2
ex2 < norMix(name = "#2 Skewed",
mu = c(0, .5, 13/12),
sigma = c(1, 2/3, 5/9),
w = c(.2, .2, .6))
m.norMix (ex2)
mean (ex2)
var.norMix(ex2)
(e23 < ex2[2:3,]) # (with renormalized weights)
stopifnot(is.norMix(e23),
all.equal(var.norMix(ex2), 719/1080, tol=1e14),
all.equal(var.norMix(ex ), 35/9, tol=1e14),
all.equal(var.norMix(ex[2:3,]), 13/4, tol=1e14),
all.equal(var.norMix(e23), 53^2/(12^3*4),tol=1e14)
)
plot(ex2, log = "y")# maybe "revealing"

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.
Please suggest features or report bugs with the GitHub issue tracker.
All documentation is copyright its authors; we didn't write any of that.