dmnorm {rchemo}R Documentation

Multivariate normal probability density

Description

Prediction of the normal probability density of multivariate observations.

Usage


dmnorm(X = NULL, mu = NULL, sigma = NULL)

## S3 method for class 'Dmnorm'
predict(object, X, ...)
  

Arguments

X

For the main function: Training data (n, p) used for estimating the mean and the covariance matrix population (if mu or/and sigma are not provided). — For the auxiliary functions: New data (m, p) for which the density has to be predicted.

mu

The mean (p, 1) of the normal distribution. If NULL (default), mu is estimated by the column-wise mean of the training data.

sigma

The covariance matrix (p x p) of the normal distribution. If NULL (default), sigma is estimated by the empirical covariance matrix (denominator n - 1) of the training data.

object

For the auxiliary functions: A result of a call to dmnorm.

...

For the auxiliary functions: Optional arguments.

Value

For dmnorm:

mu

means of the X variables

Uinv

inverse of the Cholesky decomposition of the covariance matrix

det

squared determinant of the Cholesky decomposition of the covariance matrix

For predict:

pred

Prediction of the normal probability density of new multivariate observations

Examples


data(iris)

X <- iris[, 1:2]

Xtrain <- X[1:40, ]
Xtest <- X[40:50, ]

fm <- dmnorm(Xtrain)
fm

k <- 50
x1 <- seq(min(Xtrain[, 1]), max(Xtrain[, 1]), length.out = k)
x2 <- seq(min(Xtrain[, 2]), max(Xtrain[, 2]), length.out = k)
zX <- expand.grid(x1, x2)
pred <- predict(fm, zX)$pred
contour(x1, x2, matrix(pred, nrow = 50))

points(Xtest, col = "red", pch = 16)


[Package rchemo version 0.1-1 Index]