Density for Parameterized MVN Mixtures
dens.Rd
Computes densities of observations in parameterized MVN mixtures.
Arguments
- 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.
- modelName
A character string indicating the model. The help file for
mclustModelNames
describes the available models.- parameters
The parameters of the model:
pro
The vector of mixing proportions for the components of the mixture.
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.
- logarithm
A logical value indicating whether or not the logarithm of the component densities should be returned. The default is to return the component densities, obtained from the log component densities by exponentiation.
- warn
A logical value indicating whether or not a warning should be issued when computations fail. The default is
warn=FALSE
.- ...
Catches unused arguments in indirect or list calls via
do.call
.
Value
A numeric vector whose ith component is the density of the
ith observation in data
in the MVN mixture specified
by parameters
.
Examples
# \donttest{
faithfulModel <- Mclust(faithful)
Dens <- dens(modelName = faithfulModel$modelName, data = faithful,
parameters = faithfulModel$parameters)
Dens
#> [1] 0.0122707769 0.0250791544 0.0043706519 0.0138530357 0.0382956210
#> [6] 0.0002669332 0.0202191254 0.0040575505 0.0301848769 0.0325465898
#> [11] 0.0276869342 0.0127084049 0.0362272836 0.0126473322 0.0340433096
#> [16] 0.0275448001 0.0053347162 0.0232973040 0.0107378357 0.0408143520
#> [21] 0.0238107781 0.0126473322 0.0072401212 0.0004615756 0.0203636678
#> [26] 0.0066803862 0.0348709952 0.0258863865 0.0209955144 0.0477227189
#> [31] 0.0206531762 0.0391333267 0.0014780594 0.0257972930 0.0167084263
#> [36] 0.0332636318 0.0187479804 0.0175051886 0.0163036777 0.0109972466
#> [41] 0.0474204872 0.0227110075 0.0415680246 0.0137115191 0.0158266993
#> [46] 0.0012729444 0.0010299378 0.0336507731 0.0409197701 0.0251395735
#> [51] 0.0086303933 0.0127443256 0.0276869342 0.0175051886 0.0195757229
#> [56] 0.0158547822 0.0099200538 0.0015967934 0.0333010021 0.0448831115
#> [61] 0.0239559246 0.0428496246 0.0149845645 0.0234478154 0.0124655190
#> [66] 0.0057207553 0.0340808379 0.0254708050 0.0064351071 0.0084682320
#> [71] 0.0220153547 0.0332770111 0.0459430980 0.0104506735 0.0132065431
#> [76] 0.0014619324 0.0217586659 0.0378862342 0.0205889086 0.0066803862
#> [81] 0.0250386851 0.0438577789 0.0085574647 0.0017709761 0.0168201235
#> [86] 0.0088830496 0.0218162889 0.0476014546 0.0138720624 0.0099493552
#> [91] 0.0221772274 0.0094489614 0.0250152660 0.0146789904 0.0059518823
#> [96] 0.0162549604 0.0355225683 0.0172825304 0.0275228747 0.0139559513
#> [101] 0.0071018356 0.0183366060 0.0203532755 0.0463634341 0.0251129031
#> [106] 0.0154593959 0.0327309413 0.0238013515 0.0166081728 0.0125494369
#> [111] 0.0124071667 0.0205249659 0.0088890790 0.0477608953 0.0087337354
#> [116] 0.0404200470 0.0118739090 0.0365574562 0.0153237485 0.0254418777
#> [121] 0.0028285242 0.0062235544 0.0367698291 0.0332770111 0.0228631638
#> [126] 0.0152445746 0.0096078262 0.0485643201 0.0257527006 0.0138710618
#> [131] 0.0095366375 0.0275045523 0.0007572071 0.0128224853 0.0119541984
#> [136] 0.0467697878 0.0282281324 0.0109926682 0.0352702703 0.0171467325
#> [141] 0.0384053159 0.0211703981 0.0475772253 0.0122779718 0.0355556985
#> [146] 0.0244886753 0.0386518809 0.0228345796 0.0004696987 0.0254619048
#> [151] 0.0025750274 0.0244958403 0.0051819355 0.0434023375 0.0082005926
#> [156] 0.0080988362 0.0492461255 0.0011143717 0.0254619048 0.0037325233
#> [161] 0.0051808630 0.0155405861 0.0288468099 0.0205963766 0.0021521139
#> [166] 0.0271890898 0.0092240733 0.0060951894 0.0322175567 0.0054955650
#> [171] 0.0230753789 0.0332492684 0.0320539198 0.0021292353 0.0330200275
#> [176] 0.0459247107 0.0171264585 0.0068465199 0.0125125545 0.0226037644
#> [181] 0.0302872440 0.0320539198 0.0340958190 0.0112216922 0.0300605795
#> [186] 0.0444833129 0.0188389127 0.0119541984 0.0451826484 0.0318305057
#> [191] 0.0224060120 0.0222103090 0.0109726952 0.0197480537 0.0234588094
#> [196] 0.0384053159 0.0012583227 0.0405029646 0.0188536746 0.0287510417
#> [201] 0.0232604940 0.0449585388 0.0031753778 0.0302271931 0.0351137802
#> [206] 0.0110771907 0.0405130102 0.0110738013 0.0232544418 0.0463634341
#> [211] 0.0005925546 0.0315289486 0.0220102694 0.0184806555 0.0009023966
#> [216] 0.0325656419 0.0126143782 0.0032201571 0.0358732599 0.0288218671
#> [221] 0.0250152660 0.0388430888 0.0209701825 0.0278737826 0.0252166485
#> [226] 0.0313864902 0.0290215102 0.0403560942 0.0079947124 0.0430006133
#> [231] 0.0084615742 0.0127969899 0.0172641330 0.0179025070 0.0125562378
#> [236] 0.0312429480 0.0289616059 0.0382686642 0.0232927036 0.0079999951
#> [241] 0.0256640045 0.0046569310 0.0109926682 0.0002941915 0.0372016212
#> [246] 0.0151319087 0.0332492684 0.0459498689 0.0034327330 0.0255597331
#> [251] 0.0297690462 0.0461172111 0.0107096177 0.0171264585 0.0093189544
#> [256] 0.0183858540 0.0101940749 0.0461172111 0.0344591262 0.0429864494
#> [261] 0.0190147184 0.0425259106 0.0205065804 0.0340958190 0.0047576298
#> [266] 0.0205470761 0.0113825738 0.0292875446 0.0085827041 0.0117658465
#> [271] 0.0117107647 0.0232041075
## alternative call
do.call("dens", faithfulModel)# }
#> [1] 0.0122707769 0.0250791544 0.0043706519 0.0138530357 0.0382956210
#> [6] 0.0002669332 0.0202191254 0.0040575505 0.0301848769 0.0325465898
#> [11] 0.0276869342 0.0127084049 0.0362272836 0.0126473322 0.0340433096
#> [16] 0.0275448001 0.0053347162 0.0232973040 0.0107378357 0.0408143520
#> [21] 0.0238107781 0.0126473322 0.0072401212 0.0004615756 0.0203636678
#> [26] 0.0066803862 0.0348709952 0.0258863865 0.0209955144 0.0477227189
#> [31] 0.0206531762 0.0391333267 0.0014780594 0.0257972930 0.0167084263
#> [36] 0.0332636318 0.0187479804 0.0175051886 0.0163036777 0.0109972466
#> [41] 0.0474204872 0.0227110075 0.0415680246 0.0137115191 0.0158266993
#> [46] 0.0012729444 0.0010299378 0.0336507731 0.0409197701 0.0251395735
#> [51] 0.0086303933 0.0127443256 0.0276869342 0.0175051886 0.0195757229
#> [56] 0.0158547822 0.0099200538 0.0015967934 0.0333010021 0.0448831115
#> [61] 0.0239559246 0.0428496246 0.0149845645 0.0234478154 0.0124655190
#> [66] 0.0057207553 0.0340808379 0.0254708050 0.0064351071 0.0084682320
#> [71] 0.0220153547 0.0332770111 0.0459430980 0.0104506735 0.0132065431
#> [76] 0.0014619324 0.0217586659 0.0378862342 0.0205889086 0.0066803862
#> [81] 0.0250386851 0.0438577789 0.0085574647 0.0017709761 0.0168201235
#> [86] 0.0088830496 0.0218162889 0.0476014546 0.0138720624 0.0099493552
#> [91] 0.0221772274 0.0094489614 0.0250152660 0.0146789904 0.0059518823
#> [96] 0.0162549604 0.0355225683 0.0172825304 0.0275228747 0.0139559513
#> [101] 0.0071018356 0.0183366060 0.0203532755 0.0463634341 0.0251129031
#> [106] 0.0154593959 0.0327309413 0.0238013515 0.0166081728 0.0125494369
#> [111] 0.0124071667 0.0205249659 0.0088890790 0.0477608953 0.0087337354
#> [116] 0.0404200470 0.0118739090 0.0365574562 0.0153237485 0.0254418777
#> [121] 0.0028285242 0.0062235544 0.0367698291 0.0332770111 0.0228631638
#> [126] 0.0152445746 0.0096078262 0.0485643201 0.0257527006 0.0138710618
#> [131] 0.0095366375 0.0275045523 0.0007572071 0.0128224853 0.0119541984
#> [136] 0.0467697878 0.0282281324 0.0109926682 0.0352702703 0.0171467325
#> [141] 0.0384053159 0.0211703981 0.0475772253 0.0122779718 0.0355556985
#> [146] 0.0244886753 0.0386518809 0.0228345796 0.0004696987 0.0254619048
#> [151] 0.0025750274 0.0244958403 0.0051819355 0.0434023375 0.0082005926
#> [156] 0.0080988362 0.0492461255 0.0011143717 0.0254619048 0.0037325233
#> [161] 0.0051808630 0.0155405861 0.0288468099 0.0205963766 0.0021521139
#> [166] 0.0271890898 0.0092240733 0.0060951894 0.0322175567 0.0054955650
#> [171] 0.0230753789 0.0332492684 0.0320539198 0.0021292353 0.0330200275
#> [176] 0.0459247107 0.0171264585 0.0068465199 0.0125125545 0.0226037644
#> [181] 0.0302872440 0.0320539198 0.0340958190 0.0112216922 0.0300605795
#> [186] 0.0444833129 0.0188389127 0.0119541984 0.0451826484 0.0318305057
#> [191] 0.0224060120 0.0222103090 0.0109726952 0.0197480537 0.0234588094
#> [196] 0.0384053159 0.0012583227 0.0405029646 0.0188536746 0.0287510417
#> [201] 0.0232604940 0.0449585388 0.0031753778 0.0302271931 0.0351137802
#> [206] 0.0110771907 0.0405130102 0.0110738013 0.0232544418 0.0463634341
#> [211] 0.0005925546 0.0315289486 0.0220102694 0.0184806555 0.0009023966
#> [216] 0.0325656419 0.0126143782 0.0032201571 0.0358732599 0.0288218671
#> [221] 0.0250152660 0.0388430888 0.0209701825 0.0278737826 0.0252166485
#> [226] 0.0313864902 0.0290215102 0.0403560942 0.0079947124 0.0430006133
#> [231] 0.0084615742 0.0127969899 0.0172641330 0.0179025070 0.0125562378
#> [236] 0.0312429480 0.0289616059 0.0382686642 0.0232927036 0.0079999951
#> [241] 0.0256640045 0.0046569310 0.0109926682 0.0002941915 0.0372016212
#> [246] 0.0151319087 0.0332492684 0.0459498689 0.0034327330 0.0255597331
#> [251] 0.0297690462 0.0461172111 0.0107096177 0.0171264585 0.0093189544
#> [256] 0.0183858540 0.0101940749 0.0461172111 0.0344591262 0.0429864494
#> [261] 0.0190147184 0.0425259106 0.0205065804 0.0340958190 0.0047576298
#> [266] 0.0205470761 0.0113825738 0.0292875446 0.0085827041 0.0117658465
#> [271] 0.0117107647 0.0232041075