mModelList: Fitting Gaussian mixture model or collection of models

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/semiList.r

Description

These functions fit collection of models of one particular variant/class. Models to be fitted may differ in the requested number of Gaussian components or in the requested model structure.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
mModelList(X, knowns, B = NULL, P = NULL, class = NULL, kList = ncol(B), 
    init.params = NULL, stop.likelihood.change = 10^-5, stop.max.nsteps = 100, 
    trace = FALSE, mean = c("D", "E"), between = c("D", "E"), within = c("D", 
        "E"), cov = c("D", "0"), funct = belief, all.possible.permutations = FALSE, ...)
        
beliefList(..., funct=belief)

softList(..., funct=soft)

semisupervisedList(..., funct=semisupervised)

unsupervisedList(X, kList = 2, ...)

Arguments

X

a data.frame with the unlabeled observations. The rows correspond to the observations while the columns to variables/dimensions of the data.

knowns

a data.frame with the labeled observations. The rows correspond to the observations while the columns to variables/dimensions of the data.

B

a beliefs matrix which specifies the distribution of beliefs for the labeled observations. The number of rows in B should equal the number of rows in the data.frame knowns. It is assumed that both the observations in B and in knowns are given in the same order. Columns correspond to the model components. If matrix B is provided, the number of columns has to be less or equal k. Internally, the matrix B is completed to k columns.

P

a matrix of plausibilities, i.e., weights of the prior probabilities for the labeled observations. If matrix P is provided, the number of columns has to be less or equal k. The came conditions as for B apply.

class

a vector of classes/labels for the labeled observations. The number of its unique values has to be less or equal min(kList).

kList

a vector or a list with numbers of Gaussian components to fit. By default it is one number equal to the number of columns of B.

init.params

initial values for the estimates of the model parameters (means, variances and mixing proportions). The initial parameters are internally passed to the funct function.

stop.likelihood.change, stop.max.nsteps, trace

the parameters for the EM algorithm. Internally, these parameters are passed to the funct function.

mean, between, within, cov

four vectors which define the model structures for models to be fitted. For example, if mean="E", only models with constrained means are considered (means of Gaussian components are forced to be equal). On the other hand if mean=c("E", "D"), both models with constrained means and models without constraint on the means are fitted.

funct

a function which fits a variant of Gaussian mixture model, one of the: belief, soft, semisupervised or unsupervised functions.

...

arguments that are passed to function funct.

all.possible.permutations

If equal TRUE, all possible initial parameters' permutations of components are considered. Since there is kList! permutations, model fitting is repeated kList! times. As a result only the model with the highest likelihood is returned.

Details

Arguments kList, as well as mean, between, within, and cov define the list of models to be fitted. All combinations of specified model sizes and model structures are considered. List of fitted models is returned as a result.

The argument funct defines which variant of Gaussian mixture models should be used for model fitting. One can use the wrappers beliefList(), softList(), semisupervisedList(), unsupervisedList() which call the mModelList() function and have a prespecified argument funct.

Value

An object of the class mModelList, with the following slots:

models

a list of models, each of the class mModel

loglikelihoods

a vector with log likelihoods of the models from list models

names

a vector with names of the models from list models

params

a vector with the number of parameters of models from list models

kList

equals the input argument kList

Author(s)

Przemyslaw Biecek

References

Przemyslaw Biecek, Ewa Szczurek, Martin Vingron, Jerzy Tiuryn (2012), The R Package bgmm: Mixture Modeling with Uncertain Knowledge, Journal of Statistical Software.

See Also

mModel, getModelStructure

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
 simulated = simulateData(d=2, k=3, n=100, m=60, cov="0", within="E", n.labels=2)
 
 models1=mModelList(X=simulated$X, knowns=simulated$knowns, B=simulated$B, 
             kList=3:4, mean=c("D","E"), between="D", within="D", 
             cov="0", funct=belief)

 plot(models1)
 plotGIC(models1, penalty="BIC")

## Do not run
## It could take more than one minute
# simulated = simulateData(d=2, k=3, n=300, m=60, cov="0", within="E", n.labels=2)
# 
# models1=mModelList(X=simulated$X, knowns=simulated$knowns, B=simulated$B, 
#             kList=3, mean=c("D","E"), between=c("D","E"), within=c("D","E"), 
#             cov=c("D","0"), funct=belief)
# plot(models1)
# plotGIC(models1, penalty="BIC")
# 
# models2 = beliefList(X=simulated$X, knowns=simulated$knowns, B=simulated$B,
#                kList=2:7, mean="D", between="D", within="E", cov="0")
# plot(models2)
# plotGIC(models2, penalty="BIC")
# 
# models3 = beliefList(X=simulated$X, knowns=simulated$knowns, B=simulated$B,
#               kList=2:7, mean="D")
# plotGIC(models3, penalty="BIC")

Example output

Loading required package: mvtnorm
Loading required package: car
Loading required package: carData
Loading required package: lattice
Loading required package: combinat

Attaching package: 'combinat'

The following object is masked from 'package:utils':

    combn

                    k=3      k=4
structure=DDD0 103.5511 116.6256
structure=EDD0 553.2475 560.6257

bgmm documentation built on Oct. 10, 2021, 5:07 p.m.