[R] Question about checkTmvArgs function in rtmvnorm (package tmvtnorm)
Dimitri Liakhovitski
dimitri.liakhovitski at gmail.com
Mon Feb 7 18:39:22 CET 2011
Hello!
I was wondering if it's possible to see the actual code of
checkTmvArgs function that is part of the code for rtmvnorm (which is
below - I just typed "rtmvnorm" on the prompt). I get an error:
Error in checkTmvArgs(mean, sigma, lower, upper) :
sigma must be a symmetric matrix
At the same time I am pretty sure that the matrix I am passing as
sigma is a var-covar matrix (however, it is NOT a correlation matrix).
Thanks a lot!
Dimitri
function (n, mean = rep(0, nrow(sigma)), sigma = diag(length(mean)),
lower = rep(-Inf, length = length(mean)), upper = rep(Inf,
length = length(mean)), algorithm = c("rejection", "gibbs",
"gibbsR"), ...)
{
algorithm <- match.arg(algorithm)
cargs <- checkTmvArgs(mean, sigma, lower, upper)
mean <- cargs$mean
sigma <- cargs$sigma
lower <- cargs$lower
upper <- cargs$upper
if (n < 1 || !is.numeric(n) || n != as.integer(n) || length(n) >
1) {
stop("n must be a integer scalar > 0")
}
if (algorithm == "rejection") {
retval <- rtmvnorm.rejection(n, mean, sigma, lower, upper,
...)
}
else if (algorithm == "gibbs") {
retval <- rtmvnorm.gibbs.Fortran(n, mean, sigma, lower,
upper, ...)
}
else if (algorithm == "gibbsR") {
retval <- rtmvnorm.gibbs(n, mean, sigma, lower, upper,
...)
}
return(retval)
}
--
Dimitri Liakhovitski
Ninah Consulting
www.ninah.com
More information about the R-help
mailing list