I have variance-cov matrices made in stata, that i want to use in R in pmvtnorm, for example:
library(mvtnorm)
library(matrixcalc)
sigma = read.csv(file="c:/Users/../sigma1.csv", header=F, sep=",")
sigma <- as.matrix(sigma)
is.symmetric.matrix(sigma)
is.positive.definite(sigma)
m = nrow(sigma)
Fn = pmvnorm(lower=rep(-Inf, m), upper=rep(0, m), mean=rep(0, m), sigma=sigma)
When i run this sequence I get the error message:
Error in checkmvArgs(lower = lower, upper = upper, mean = mean, corr = corr, :
‘sigma’ is not a covariance matrix
Checking for positive definiteness and symmetry both show true, and most of the matrices i import to R i have already used in similar stata commands without a problem... Link for sigma1.csv:
sigmato your question, so we can see the matrix itself? - cgage1pmvnormto handle, or 2. Some sort of rounding issue is happening when the the values are being read intoFn. Sorry I couldn't help, hopefully someone that can comes across this! - cgage1rownames(sigma) <- colnames(sigma)- user20650pmvnormleads tomvtnorm:::checkmvArgs, and then toisTRUE(all.equal(sigma, t(sigma)))- user20650