| dens {mclust} | R Documentation |
Computes densities of obseravations in parameterized MVN mixtures.
dens(modelName, data, mu, logarithm, ...)
modelName |
A character string indicating the model. Possible models: "E" for spherical, equal variance (one-dimensional) "V" for spherical, variable variance (one-dimensional) "EII": spherical, equal volume "VII": spherical, unequal volume "EEI": diagonal, equal volume, equal shape "VEI": diagonal, varying volume, equal shape "EVI": diagonal, equal volume, varying shape "VVI": diagonal, varying volume, varying shape "EEE": ellipsoidal, equal volume, shape, and orientation "EEV": ellipsoidal, equal volume and equal shape "VEV": ellipsoidal, equal shape "VVV": ellipsoidal, varying volume, shape, and orientation For fitting a single Gaussian, "X": one-dimensional "XII": spherical "XXI": diagonal "XXX": ellipsoidal |
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. |
mu |
The mean for each component. If there is more than one component,
mu is a matrix whose columns are the means of the components.
|
logarithm |
Return logarithm of the density, rather than the density itself. Default: FALSE |
... |
Other arguments, such as an argument describing the variance.
See cdens.
|
A numeric vector whose ith component is the density of observation
i in the MVN mixture specified by mu and
....
C. Fraley and A. E. Raftery (2002a). Model-based clustering, discriminant analysis, and density estimation. Journal of the American Statistical Association 97:611-631. See http://www.stat.washington.edu/mclust.
C. Fraley and A. E. Raftery (2002b). MCLUST:Software for model-based clustering, density estimation and discriminant analysis. Technical Report, Department of Statistics, University of Washington. See http://www.stat.washington.edu/mclust.
grid1,
cdens,
mclustOptions,
do.call
n <- 100 ## create artificial data
set.seed(0)
x <- rbind(matrix(rnorm(n*2), n, 2) %*% diag(c(1,9)),
matrix(rnorm(n*2), n, 2) %*% diag(c(1,9))[,2:1])
xclass <- c(rep(1,n),rep(2,n))
clPairs(x, cl = xclass, sym = c("1","2")) ## display the data
set.seed(0)
I <- sample(1:(2*n))
x <- x[I, ]
xclass <- xclass[I]
odd <- seq(1, 2*n, by = 2)
oddBic <- EMclust(x[odd, ])
oddSumry <- summary(oddBic, x[odd, ]) ## best parameter estimates
names(oddSumry)
oddDens <- dens(modelName = oddSumry$modelName, data = x,
mu = oddSumry$mu, decomp = oddSumry$decomp, pro = oddSumry$pro)
## Not run:
oddDens <- do.call("dens", c(list(data = x), oddSumry)) ## alternative call
## End(Not run)
even <- odd + 1
evenBic <- EMclust(x[even, ])
evenSumry <- summary(evenBic, x[even, ]) ## best parameter estimates
evenDens <- do.call( "dens", c(list(data = x), evenSumry))
cbind(class = xclass, odd = oddDens, even = evenDens)