Skip to content

package mvtnorm: sigma parameter in pmvnorm() (PR#2478)

1 message · Uwe Ligges

#
jerome@hivnet.ubc.ca wrote:
The bug is in checkmvArgs():

  if (!is.null(sigma)) {
          if (!is.matrix(sigma)) {
             if (length(sigma) == 1)
                 UNI <- TRUE
             if (length(sigma) != length(lower))
                stop("diag(sigma) and lower are of different length")
          } else {
+           if (length(diag(sigma)) != length(lower))
+              stop("diag(sigma) and lower are of different length")
             if (length(sigma) == 1) {
                 UNI <- TRUE
                 sigma <- sigma[1,1]
             }
-           if (length(diag(sigma)) != length(lower))
-              stop("diag(sigma) and lower are of different length")

          }
     }


The fix is to change the position of the validation, i.e. before the 
matrix is coerced to a vector of length 1.

Uwe Ligges