I need to fit a multivaraite normal distribution to each specie in the Iris dataset in R. I saw the mvtnorm
package might be useful; however, i want to use the maximum likelihood estimation and not sure how to do so in R. Any ideas?
It seems you are looking for a mixture discriminant analysis (since class labels are known). In this case, you can use the MclustDA
from the mclust
package.
model= MclustDA(data = iris[,1:4], class = iris$Species)
summary(model)
However, if you are looking to cluster the data using by fitting multivariate Gaussian mixtures then you can use the Mclust
function.
fit = Mclust(data = iris[,1:4], G=3)
table(fit$classification, iris$Species)
# setosa versicolor virginica
# 1 50 0 0
# 2 0 45 0
# 3 0 5 50