Skip to content

Commit

Permalink
dmvnorm / dgmrf: mu must be a vector corresponding to Sigma / Q #24
Browse files Browse the repository at this point in the history
  • Loading branch information
kaskr committed Apr 17, 2024
1 parent e350bbb commit c1cea00
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions RTMB/R/mvgauss.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
##' @param scale Extra scale parameter - see section 'Scaling'.
##' @return Vector of densities.
dmvnorm <- function(x, mu=0, Sigma, log=FALSE, scale=1) {
if (!identical(mu, 0)) {
p <- length(mu)
if (!all(dim(Sigma) == c(p, p))) stop("incompatible arguments")
}
if (!unit(scale)) {
return (dscale("dmvnorm", x, mu, Sigma,
log=log, scale=scale, vectorize=TRUE))
Expand Down Expand Up @@ -43,6 +47,10 @@ dmvnorm <- function(x, mu=0, Sigma, log=FALSE, scale=1) {
##' @details The function `dgmrf()` is essentially identical to `dmvnorm()` with the only difference that `dgmrf()` is specified via the *precision* matrix (inverse covariance) assuming that this matrix is *sparse*.
##' @param Q Sparse precision matrix
dgmrf <- function(x, mu=0, Q, log=FALSE, scale=1) {
if (!identical(mu, 0)) {
p <- length(mu)
if (!all(dim(Sigma) == c(p, p))) stop("incompatible arguments")
}
if (!unit(scale)) {
return (dscale("dgmrf", x, mu, Q,
log=log, scale=scale, vectorize=TRUE))
Expand Down

0 comments on commit c1cea00

Please sign in to comment.