me.weighted: EM algorithm with weights starting with M-step for...

Description Usage Arguments Value Author(s) See Also Examples

View source: R/weights.R

Description

Implements the EM algorithm for fitting MVN mixture models parameterized by eigenvalue decomposition, when observations have weights, starting with the maximization step.

Usage

1
2
me.weighted(modelName, data, z, weights = NULL, prior = NULL, 
            control = emControl(), Vinv = NULL, warn = NULL, ...)

Arguments

modelName

A character string indicating the model. The help file for mclustModelNames describes the available models.

data

A numeric vector, matrix, or data frame of observations. Categorical variables are not allowed. If a matrix or data frame, rows correspond to observations and columns correspond to variables.

z

A matrix whose [i,k]th entry is an initial estimate of the conditional probability of the ith observation belonging to the kth component of the mixture.

weights

A vector of positive weights, where the [i]th entry is the weight for the ith observation. If any of the weights are greater than one, then they are scaled so that the maximum weight is one.

prior

Specification of a conjugate prior on the means and variances. See the help file for priorControl for further information. The default assumes no prior.

control

A list of control parameters for EM. The defaults are set by the call emControl.

Vinv

If the model is to include a noise term, Vinv is an estimate of the reciprocal hypervolume of the data region. If set to a negative value or 0, the model will include a noise term with the reciprocal hypervolume estimated by the function hypvol. The default is not to assume a noise term in the model through the setting Vinv=NULL.

warn

A logical value indicating whether or not certain warnings (usually related to singularity) should be issued when the estimation fails. The default is set by warn using mclust.options.

...

Catches unused arguments in indirect or list calls via do.call.

Value

A list including the following components:

modelName

A character string identifying the model (same as the input argument).

z

A matrix whose [i,k]th entry is the conditional probability of the ith observation belonging to the kth component of the mixture.

parameters
pro

A vector whose kth component is the mixing proportion for the kth component of the mixture model. If the model includes a Poisson term for noise, there should be one more mixing proportion than the number of Gaussian components.

mean

The mean for each component. If there is more than one component, this is a matrix whose kth column is the mean of the kth component of the mixture model.

variance

A list of variance parameters for the model. The components of this list depend on the model specification. See the help file for mclustVariance for details.

Vinv

The estimate of the reciprocal hypervolume of the data region used in the computation when the input indicates the addition of a noise component to the model.

loglik

The log likelihood for the data in the mixture model.

Attributes:

"info" Information on the iteration.
"WARNING" An appropriate warning if problems are encountered in the computations.

Author(s)

Thomas Brendan Murphy

See Also

me, meE, ..., meVVV, em, mstep, estep, priorControl, mclustModelNames, mclustVariance, mclust.options

Examples

1
2
3
4
5
## Not run: 
w <- rep(1,150)
w[1] <- 0
me.weighted(modelName = "VVV", data = iris[,-5], z = unmap(iris[,5]),weights=w)
## End(Not run)

Example output

Package 'mclust' version 5.3
Type 'citation("mclust")' for citing this R package in publications.
$modelName
[1] "VVV"

$prior
NULL

$n
[1] 150

$d
[1] 4

$G
[1] 3

$z
                [,1]         [,2]         [,3]
  [1,]  1.000000e+00 9.846065e-45 2.544850e-34
  [2,]  1.000000e+00 1.760534e-31 8.650336e-28
  [3,]  1.000000e+00 1.455710e-36 1.445200e-29
  [4,]  1.000000e+00 2.725576e-32 8.105404e-26
  [5,]  1.000000e+00 3.126131e-47 1.050590e-34
  [6,]  1.000000e+00 8.934098e-46 1.166960e-34
  [7,]  1.000000e+00 1.278176e-36 1.909943e-28
  [8,]  1.000000e+00 7.600707e-41 2.251406e-31
  [9,]  1.000000e+00 4.881904e-28 7.662684e-24
 [10,]  1.000000e+00 2.979708e-36 3.240221e-28
 [11,]  1.000000e+00 3.110363e-50 2.658118e-37
 [12,]  1.000000e+00 2.417770e-39 9.693722e-29
 [13,]  1.000000e+00 1.979402e-34 7.103427e-28
 [14,]  1.000000e+00 6.606281e-35 2.374567e-27
 [15,]  1.000000e+00 1.919027e-63 2.255458e-47
 [16,]  1.000000e+00 1.121164e-64 6.373667e-46
 [17,]  1.000000e+00 3.786529e-50 1.334022e-39
 [18,]  1.000000e+00 4.755202e-41 2.867640e-33
 [19,]  1.000000e+00 1.631373e-47 1.734456e-36
 [20,]  1.000000e+00 2.823149e-48 2.509488e-35
 [21,]  1.000000e+00 2.742233e-39 1.049880e-30
 [22,]  1.000000e+00 1.648069e-41 7.940390e-33
 [23,]  1.000000e+00 4.034286e-48 8.727128e-35
 [24,]  1.000000e+00 5.248287e-26 1.697183e-24
 [25,]  1.000000e+00 4.921500e-36 3.279710e-24
 [26,]  1.000000e+00 9.694272e-30 8.393259e-26
 [27,]  1.000000e+00 1.297849e-32 8.497812e-28
 [28,]  1.000000e+00 5.051316e-44 1.019182e-33
 [29,]  1.000000e+00 3.382338e-42 8.251526e-34
 [30,]  1.000000e+00 4.924024e-34 3.741455e-26
 [31,]  1.000000e+00 7.441383e-32 8.304069e-26
 [32,]  1.000000e+00 1.040903e-34 1.738174e-31
 [33,]  1.000000e+00 1.023099e-66 2.559950e-41
 [34,]  1.000000e+00 1.567619e-67 1.510520e-45
 [35,]  1.000000e+00 5.429497e-33 1.202816e-27
 [36,]  1.000000e+00 4.037361e-38 1.754271e-32
 [37,]  1.000000e+00 2.197258e-46 7.936115e-38
 [38,]  1.000000e+00 7.401142e-51 1.045757e-34
 [39,]  1.000000e+00 6.836554e-31 1.280966e-25
 [40,]  1.000000e+00 4.564313e-41 5.424814e-32
 [41,]  1.000000e+00 1.393323e-41 1.374434e-33
 [42,]  1.000000e+00 3.197920e-15 2.741550e-19
 [43,]  1.000000e+00 2.085259e-35 2.949242e-27
 [44,]  1.000000e+00 1.199818e-27 5.669457e-25
 [45,]  1.000000e+00 2.117483e-39 3.012633e-28
 [46,]  1.000000e+00 3.266071e-28 3.117067e-26
 [47,]  1.000000e+00 1.992247e-51 4.697058e-35
 [48,]  1.000000e+00 1.793161e-35 7.817668e-28
 [49,]  1.000000e+00 5.037349e-50 1.125089e-36
 [50,]  1.000000e+00 4.078910e-39 1.653954e-31
 [51,]  1.164884e-90 9.997143e-01 2.857276e-04
 [52,]  2.481538e-82 9.985970e-01 1.402991e-03
 [53,] 1.012440e-102 9.943715e-01 5.628535e-03
 [54,]  1.117797e-62 9.303525e-01 6.964753e-02
 [55,]  1.581392e-90 9.697291e-01 3.027092e-02
 [56,]  5.187304e-78 9.680556e-01 3.194442e-02
 [57,]  2.490896e-92 9.863352e-01 1.366482e-02
 [58,]  1.227621e-33 9.998379e-01 1.620515e-04
 [59,]  3.889539e-85 9.985798e-01 1.420159e-03
 [60,]  1.321284e-59 9.663375e-01 3.366251e-02
 [61,]  1.419717e-41 9.981567e-01 1.843270e-03
 [62,]  2.088065e-71 9.926379e-01 7.362149e-03
 [63,]  4.817384e-60 9.991051e-01 8.948776e-04
 [64,]  2.836558e-89 9.665315e-01 3.346849e-02
 [65,]  3.942433e-46 9.997916e-01 2.084309e-04
 [66,]  6.493530e-78 9.998727e-01 1.273451e-04
 [67,]  2.660304e-82 9.236195e-01 7.638051e-02
 [68,]  8.621985e-57 9.964523e-01 3.547746e-03
 [69,]  1.307816e-90 2.764715e-03 9.972353e-01
 [70,]  5.454312e-54 9.994870e-01 5.130321e-04
 [71,] 2.847533e-104 5.281011e-02 9.471899e-01
 [72,]  3.863196e-61 9.998390e-01 1.610173e-04
 [73,] 2.615613e-105 4.172675e-02 9.582732e-01
 [74,]  9.540519e-85 9.120010e-01 8.799898e-02
 [75,]  2.989928e-72 9.997754e-01 2.245945e-04
 [76,]  1.403347e-78 9.997160e-01 2.840016e-04
 [77,]  1.920627e-98 9.876050e-01 1.239495e-02
 [78,] 8.960396e-113 3.293562e-01 6.706438e-01
 [79,]  1.010045e-83 9.639717e-01 3.602826e-02
 [80,]  1.144874e-38 9.999856e-01 1.444975e-05
 [81,]  2.602174e-51 9.994951e-01 5.049170e-04
 [82,]  5.156523e-46 9.998127e-01 1.873370e-04
 [83,]  3.187348e-55 9.998224e-01 1.776351e-04
 [84,] 1.152438e-114 6.739998e-03 9.932600e-01
 [85,]  3.228601e-82 8.476516e-01 1.523484e-01
 [86,]  8.235296e-83 9.871216e-01 1.287837e-02
 [87,]  6.542055e-93 9.974957e-01 2.504255e-03
 [88,]  5.572590e-81 9.177850e-01 8.221500e-02
 [89,]  1.592153e-61 9.985048e-01 1.495202e-03
 [90,]  1.117110e-61 9.896974e-01 1.030256e-02
 [91,]  1.562757e-72 9.402664e-01 5.973361e-02
 [92,]  2.550881e-84 9.908480e-01 9.152043e-03
 [93,]  1.760024e-59 9.994966e-01 5.034197e-04
 [94,]  1.988369e-34 9.998787e-01 1.212881e-04
 [95,]  1.625838e-67 9.936310e-01 6.368965e-03
 [96,]  4.100658e-62 9.972439e-01 2.756069e-03
 [97,]  4.120973e-66 9.979144e-01 2.085588e-03
 [98,]  2.478512e-71 9.994828e-01 5.172018e-04
 [99,]  9.132959e-28 9.999387e-01 6.126038e-05
[100,]  1.845675e-63 9.985709e-01 1.429099e-03
[101,] 2.636994e-200 4.671822e-17 1.000000e+00
[102,] 1.366897e-126 9.988926e-08 9.999999e-01
[103,] 2.374538e-178 2.393012e-09 1.000000e+00
[104,] 2.772626e-146 4.089605e-05 9.999591e-01
[105,] 4.325891e-175 6.917434e-12 1.000000e+00
[106,] 7.874429e-225 2.404432e-11 1.000000e+00
[107,]  7.120581e-94 1.114289e-05 9.999889e-01
[108,] 2.867466e-193 1.864413e-07 9.999998e-01
[109,] 5.499254e-164 5.084313e-09 1.000000e+00
[110,] 2.666041e-204 4.563949e-13 1.000000e+00
[111,] 1.316114e-127 5.733677e-05 9.999427e-01
[112,] 1.147045e-137 1.520506e-07 9.999998e-01
[113,] 2.532947e-155 5.429643e-09 1.000000e+00
[114,] 1.543582e-128 1.987568e-12 1.000000e+00
[115,] 3.245175e-154 2.838436e-22 1.000000e+00
[116,] 1.812104e-153 9.242162e-13 1.000000e+00
[117,] 1.156166e-140 7.473635e-04 9.992526e-01
[118,] 1.412384e-224 5.136647e-06 9.999949e-01
[119,] 1.670310e-260 2.488404e-22 1.000000e+00
[120,] 9.295377e-112 4.986516e-05 9.999501e-01
[121,] 2.180489e-174 4.074227e-12 1.000000e+00
[122,] 6.103943e-122 3.032268e-09 1.000000e+00
[123,] 1.052763e-231 1.648594e-12 1.000000e+00
[124,] 3.878750e-114 4.918961e-05 9.999508e-01
[125,] 6.233149e-162 1.876281e-06 9.999981e-01
[126,] 9.336133e-170 7.154978e-04 9.992845e-01
[127,] 2.229514e-108 3.358526e-04 9.996641e-01
[128,] 1.382192e-110 5.744022e-03 9.942560e-01
[129,] 3.828033e-161 1.704508e-11 1.000000e+00
[130,] 1.433095e-154 4.598587e-03 9.954014e-01
[131,] 9.411020e-187 2.933983e-08 1.000000e+00
[132,] 1.142420e-197 5.877930e-03 9.941221e-01
[133,] 2.344141e-166 2.998819e-14 1.000000e+00
[134,] 1.865025e-111 2.160253e-01 7.839747e-01
[135,] 7.070001e-136 2.990509e-05 9.999701e-01
[136,] 6.081013e-204 1.685783e-14 1.000000e+00
[137,] 2.574303e-172 3.253642e-13 1.000000e+00
[138,] 3.408721e-139 2.372952e-03 9.976270e-01
[139,] 4.150624e-106 5.570411e-03 9.944296e-01
[140,] 1.951551e-149 7.260122e-08 9.999999e-01
[141,] 1.123368e-175 1.016098e-16 1.000000e+00
[142,] 4.079971e-146 3.290379e-14 1.000000e+00
[143,] 1.366897e-126 9.988926e-08 9.999999e-01
[144,] 8.912039e-185 3.717934e-12 1.000000e+00
[145,] 5.453573e-185 1.985072e-17 1.000000e+00
[146,] 2.396471e-151 2.791429e-15 1.000000e+00
[147,] 3.135797e-125 2.094314e-09 1.000000e+00
[148,] 1.582201e-134 1.114907e-06 9.999989e-01
[149,] 2.237243e-156 1.263753e-10 1.000000e+00
[150,] 1.611193e-119 1.660929e-03 9.983391e-01

$parameters
$parameters$pro
[1] 0.3288591 0.3012419 0.3698990

$parameters$mean
                  [,1]     [,2]     [,3]
Sepal.Length 5.0040816 5.915002 6.544592
Sepal.Width  3.4265306 2.777847 2.948678
Petal.Length 1.4632653 4.201621 5.479639
Petal.Width  0.2469388 1.296993 1.984659

$parameters$variance
$parameters$variance$modelName
[1] "VVV"

$parameters$variance$d
[1] 4

$parameters$variance$G
[1] 3

$parameters$variance$sigma
, , 1

             Sepal.Length Sepal.Width Petal.Length Petal.Width
Sepal.Length   0.12406497  0.09907539  0.016476468 0.010420658
Sepal.Width    0.09907539  0.14358184  0.011790920 0.009366930
Petal.Length   0.01647647  0.01179092  0.030079134 0.006009996
Petal.Width    0.01042066  0.00936693  0.006009996 0.011062057

, , 2

             Sepal.Length Sepal.Width Petal.Length Petal.Width
Sepal.Length   0.27531971  0.09693387   0.18467205  0.05439581
Sepal.Width    0.09693387  0.09264414   0.09114016  0.04299699
Petal.Length   0.18467205  0.09114016   0.20065618  0.06098954
Petal.Width    0.05439581  0.04299699   0.06098954  0.03200230

, , 3

             Sepal.Length Sepal.Width Petal.Length Petal.Width
Sepal.Length   0.38704532  0.09220768   0.30279656  0.06163158
Sepal.Width    0.09220768  0.11033880   0.08427772  0.05600560
Petal.Length   0.30279656  0.08427772   0.32775124  0.07449089
Petal.Width    0.06163158  0.05600560   0.07449089  0.08577660


$parameters$variance$cholsigma
, , 1

             Sepal.Length Sepal.Width Petal.Length  Petal.Width
Sepal.Length   -0.3522286  -0.2812815 -0.046777772 -0.029584930
Sepal.Width     0.0000000   0.2538948 -0.005383339  0.004116811
Petal.Length    0.0000000   0.0000000 -0.166919122 -0.027847264
Petal.Width     0.0000000   0.0000000  0.000000000  0.096924564

, , 2

             Sepal.Length Sepal.Width Petal.Length Petal.Width
Sepal.Length    0.5247092   0.1847383    0.3519513  0.10366849
Sepal.Width     0.0000000  -0.2419006   -0.1079835 -0.09857539
Petal.Length    0.0000000   0.0000000    0.2551981  0.05430592
Petal.Width     0.0000000   0.0000000    0.0000000 -0.09267633

, , 3

             Sepal.Length Sepal.Width Petal.Length Petal.Width
Sepal.Length   -0.6221297  -0.1482130  -0.48670972 -0.09906550
Sepal.Width     0.0000000  -0.2972738  -0.04084124 -0.13900587
Petal.Length    0.0000000   0.0000000  -0.29865845 -0.06896701
Petal.Width     0.0000000   0.0000000   0.00000000 -0.22777960




$weights
  [1] 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
 [38] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
 [75] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
[112] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
[149] 1 1

$loglik
[1] -181.7281

attr(,"returnCode")
[1] 0

mclust documentation built on Nov. 20, 2020, 5:09 p.m.