dmnorm | R Documentation |
Prediction of the probability density of multivariate observations. Function dmnorm
assumes a multivariate gaussian distribution for the reference (= training) observations. Function dkerngauss
returns a non parametric estimate using a (multiplicative) multivariate gaussian kernel estimator.
dmnorm(Xr = NULL, Xu, mu = NULL, sigma = NULL, diag = FALSE)
dkerngauss(Xr, Xu, H = NULL, hs = NULL, a = .5)
Xr |
A |
Xu |
A |
Specific arguments for dmnorm
:
mu |
A |
sigma |
The |
diag |
Logical indicating if the estimated covariance matrix is forced to be diagonal (default to |
Specific arguments for dkerngauss
:
H |
The |
hs |
A scalar representing a same bandwidth for all the |
a |
A scaling scalar used if |
A data.frame, see the examples.
data(iris)
Xr <- iris[, 1:4]
yr <- iris[, 5]
fm <- fda(Xr, yr)
Tr <- fm$Tr
m <- 50
x1 <- seq(min(Tr[, 1]), max(Tr[, 1]), length.out = m)
x2 <- seq(min(Tr[, 2]), max(Tr[, 2]), length.out = m)
Tu <- expand.grid(x1, x2)
headm(Tu)
## Parametric
z <- dmnorm(Tr[yr == "setosa", ], Tu)$fit$fit
mfit1 <- matrix(z, nrow = m)
z <- dmnorm(Tr[yr == "versicolor", ], Tu)$fit$fit
mfit2 <- matrix(z, nrow = m)
z <- dmnorm(Tr[yr == "virginica", ], Tu)$fit$fit
mfit3 <- matrix(z, nrow = m)
oldpar <- par(mfrow = c(1, 1))
par(mfrow = c(2, 2))
contour(x1, x2, mfit1)
abline(h = 0, v = 0, lty = 2)
contour(x1, x2, mfit2)
abline(h = 0, v = 0, lty = 2)
contour(x1, x2, mfit3)
abline(h = 0, v = 0, lty = 2)
par(oldpar)
## Non-parametric
hs <- .5
z <- dkerngauss(Tr[yr == "setosa", ], Tu, hs = hs)$fit$fit
mfit1 <- matrix(z, nrow = m)
z <- dkerngauss(Tr[yr == "versicolor", ], Tu, hs = hs)$fit$fit
mfit2 <- matrix(z, nrow = m)
z <- dkerngauss(Tr[yr == "virginica", ], Tu, hs = hs)$fit$fit
mfit3 <- matrix(z, nrow = m)
oldpar <- par(mfrow = c(1, 1))
par(mfrow = c(2, 2))
contour(x1, x2, mfit1)
abline(h = 0, v = 0, lty = 2)
contour(x1, x2, mfit2)
abline(h = 0, v = 0, lty = 2)
contour(x1, x2, mfit3)
abline(h = 0, v = 0, lty = 2)
par(oldpar)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.