Sun, John
2022-Sep-19 18:58 UTC
[R] How to find the variance-covariance matrix of a random-vector using R
Dear All, Reposting as plain text rather than html. I realized that R does not support finding the variance-covariance matrix of a random-vector. It must take two arguments. Numpy's cov doesn't give sensible results. I ask in a bigger context of finding the variance-covariance matrix of the vector of the dependent variables per subject which is the covariance form of the working-correlation matrix in GEE by Liang-Zeger (1986). Knowing it gives me better inference via efficiency improvement. I have not received a reply on these posts, so I ask. https://stats.stackexchange.com/questions/589022/how-to-find-covy-i-using-software-in-the-context-sum-i-1-mathrmk https://stackoverflow.com/questions/73755242/is-there-a-r-function-or-python-for-finding-the-covariance-matrix-of-a-random-ve Best regards, Kpjm
Bill Dunlap
2022-Sep-20 15:04 UTC
[R] How to find the variance-covariance matrix of a random-vector using R
?var E.g.,> x <- mvtnorm::rmvnorm(1e5, mean=101:105, sigma=matrix(1,5,5)+diag(11:15)) > dim(x)[1] 100000 5> var(x)[,1] [,2] [,3] [,4] [,5] [1,] 11.9666055 1.0603876 0.9627672 1.0371084 0.983217 [2,] 1.0603876 13.0774518 1.0228972 0.9261868 1.059799 [3,] 0.9627672 1.0228972 13.9296063 1.0444007 1.051089 [4,] 1.0371084 0.9261868 1.0444007 15.1556199 1.052573 [5,] 0.9832170 1.0597985 1.0510888 1.0525734 15.965351 -Bill On Tue, Sep 20, 2022 at 4:24 AM Sun, John <jsun20 at albany.edu> wrote:> Dear All, > Reposting as plain text rather than html. > > I realized that R does not support finding the variance-covariance matrix > of a random-vector. It must take two arguments. Numpy's cov doesn't give > sensible results. > I ask in a bigger context of finding the variance-covariance matrix of the > vector of the dependent variables per subject which is the covariance form > of the working-correlation matrix in GEE by Liang-Zeger (1986). Knowing it > gives me better inference via efficiency improvement. > > I have not received a reply on these posts, so I ask. > > https://stats.stackexchange.com/questions/589022/how-to-find-covy-i-using-software-in-the-context-sum-i-1-mathrmk > > https://stackoverflow.com/questions/73755242/is-there-a-r-function-or-python-for-finding-the-covariance-matrix-of-a-random-ve > > Best regards, > Kpjm > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. >[[alternative HTML version deleted]]