I found a reason why I was getting the error that my var-covar matrix was not symmetric: because my column names and row names were different! Dimitri
On Mon, Feb 7, 2011 at 12:39 PM, Dimitri Liakhovitski <dimitri.liakhovit...@gmail.com> wrote: > 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 > -- Dimitri Liakhovitski Ninah Consulting www.ninah.com ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.