zzz-mvnorm | R Documentation |
Alternative density, distribution function, and random generation for the multivariate Normal distribution.
The multivariate distribution functions to compute densities
dmvnorm
, probabilities pmvnorm
, and to generate
random numbers rmvnorm
are available from the contributed
R package mvtnorm
.
The function qmvnorm
computes the equicoordinate quantile
function of the multivariate normal distribution for arbitrary
correlation matrices based on inversion of pmvnorm
.
dmvnorm(x, mean, sigma, <<...>>
pmvnorm(<<...>>)
qmvnorm(p, <<...>>)
rmvnorm(n, mean, sigma, <<...>>
NOTE: The function are not builtin in the package fMultivar
.
Fur details we refer to the help page of mvnorm
.
Friedrich Leisch and Fabian Scheipl.
## Not run:
## Load Libray:
require(mvtnorm)
## dmvnorm -
# Multivariate Normal Density Function:
mean <- c(1, 1)
sigma <- matrix(c(1, 0.5, 0.5, 1), ncol=2)
dmvnorm(x = c(0, 0),mean, sigma)
## dmvnorm -
# Across a Grid:
x <- seq(-4, 4, length=90)
X <- grid2d(x)
X <- cbind(X$x, X$y)
# Write Density Function:
dmvnorm. <- function(X, mean, sigma)
matrix(apply(X, 1, dmvnorm, mean=mean, sigma=sigma), ncol=sqrt(dim(X)[1]))
z <- dmvnorm.(X, mean, sigma)
contour(list(x = x, y = x, z = z))
## qmvnorm -
# Equicoordinate Quantile Function:
qmvnorm(p = 0.95, sigma = diag(2), tail = "both")
## rmvnorm -
# Random Numbers:
sigma <- matrix(c(4, 2, 2, 3), ncol=2)
x <- rmvnorm(n = 500, mean = c(1, 2), sigma = sigma)
colMeans(x)
var(x)
# Next Generation:
x <- rmvnorm(n = 500, mean = c(1, 2), sigma = sigma, method = "chol")
colMeans(x)
var(x)
plot(x, cex=0.5, pch=19, col="steelblue")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.