Last chance! 50% off unlimited learning
Sale ends in
Computes the log-likelihood (contributions) of multiple exact or interval-censored observations (or a mix thereof) from multivariate normal distributions and evaluates corresponding score functions.
lpmvnorm(lower, upper, mean = 0, center = NULL, chol, invchol, logLik = TRUE,
M = NULL, w = NULL, seed = NULL, tol = .Machine$double.eps, fast = FALSE)
slpmvnorm(lower, upper, mean = 0, center = NULL, chol, invchol, logLik = TRUE,
M = NULL, w = NULL, seed = NULL, tol = .Machine$double.eps, fast = FALSE)
ldmvnorm(obs, mean = 0, chol, invchol, logLik = TRUE)
sldmvnorm(obs, mean = 0, chol, invchol, logLik = TRUE)
ldpmvnorm(obs, lower, upper, mean = 0, chol, invchol, logLik = TRUE, ...)
sldpmvnorm(obs, lower, upper, mean = 0, chol, invchol, logLik = TRUE, ...)
The log-likelihood (logLik = TRUE
) or the individual contributions to the log-likelihood.
slpmvnorm
, sldmvnorm
, and sldpmvnorm
return the score
matrices and, optionally (logLik = TRUE
), the individual log-likelihood contributions
as well as scores for obs
, lower
, upper
, and
mean
.
matrix of lower limits (one column for each observation,
matrix of upper limits (one column for each observation,
matrix of exact observations (one column for each observation,
matrix of means (one column for each observation, length is
recycled to length of obs
, lower
and upper
).
matrix of negative rescaled means (one column for each observation, length is
recycled to length of lower
and upper
) as returned by
cond_mvnorm(..., center = TRUE)
.
Cholesky factors of covariance matrices as
ltMatrices
object, length is recylced to length of
obs
, lower
and upper
.
Cholesky factors of precision matrices as
ltMatrices
object, length is recylced to length of lower
and
upper
. Either chol
or invchol
must be given.
logical, if TRUE
, the log-likelihood is returned,
otherwise the individual contributions to the sum are returned.
number of iterations, early stopping based on estimated errors is NOT implemented.
an optional matrix of weights with ncol(w) == M
is specified. If ncol(w) == ncol(lower) * M
, each
likelihood contribution is evaluated on the corresponding sub-matrix.
If w
is NULL
, different uniform numbers are
drawn for each observation.
an object specifying if and how the random number generator
should be initialized, see simulate
. Only
applied when w
is NULL
.
tolerance limit, values smaller than tol
are interpreted
as zero.
logical, if TRUE
, a faster but less accurate version
of pnorm
is used internally.
additional arguments to lpmvnorm
.
Evaluates the multivariate normal log-likelihood defined by means
and
chol
over boxes defined by lower
and upper
or for
exact observations obs
.
Monte-Carlo (Genz, 1992, the default) and quasi-Monte-Carlo (Genz & Bretz, 2002)
integration is implemented, the latter with weights obtained, for example,
from packages qrng or randtoolbox. It is the responsibility of
the user to ensure a meaningful lattice is used. In case of doubt, use
plain Monte-Carlo (w = NULL
) or pmvnorm
.
slpmvnorm
computes both the individual log-likelihood contributions
and the corresponding score matrix (of dimension chol
contains diagonal elements. Otherwise, the dimension is sldmvnorm
and sldpmvnorm
,
respectively.
More details can be found in the lmvnorm_src
package vignette.
Genz, A. (1992). Numerical computation of multivariate normal probabilities. Journal of Computational and Graphical Statistics, 1, 141--150.
Genz, A. and Bretz, F. (2002), Methods for the computation of multivariate t-probabilities. Journal of Computational and Graphical Statistics, 11, 950--971.
dmvnorm
, vignette("lmvnorm_src", package = "mvtnorm")
### five observations
N <- 5L
### dimension
J <- 4L
### lower and upper bounds, ie interval-censoring
lwr <- matrix(-runif(N * J), nrow = J)
upr <- matrix(runif(N * J), nrow = J)
### Cholesky factor
(C <- ltMatrices(runif(J * (J + 1) / 2), diag = TRUE))
### corresponding covariance matrix
(S <- as.array(Tcrossprod(C))[,,1])
### plain Monte-Carlo (Genz, 1992)
w <- NULL
M <- 25000
### quasi-Monte-Carlo (Genz & Bretz, 2002, but with different weights)
if (require("qrng")) w <- t(ghalton(M * N, J - 1))
### log-likelihood
lpmvnorm(lower = lwr, upper = upr, chol = C, w = w, M = M)
### compare with pmvnorm
exp(lpmvnorm(lower = lwr, upper = upr, chol = C, logLik = FALSE, w = w, M = M))
sapply(1:N, function(i) pmvnorm(lower = lwr[,i], upper = upr[,i], sigma = S))
### log-lik contributions and score matrix
slpmvnorm(lower = lwr, upper = upr, chol = C, w = w, M = M, logLik = TRUE)
Run the code above in your browser using DataLab