similar to: Compute a correlation matrix from an existing covariance matrix

Displaying 20 results from an estimated 20000 matches similar to: "Compute a correlation matrix from an existing covariance matrix"

2005 Oct 06
3
Singular matrix
Dear All, I have written the following programs to find a non-singular (10*10) covariance matrix. Here is the program: nitems <- 10 x <- array(rnorm(5*nitems,3,3), c(5,nitems)) sigma <- t(x)%*%x inverse <- try(solve(sigma), TRUE) while(inherits(inverse, "try-error")) { x <- array(rnorm(5*nitems,3,3), c(5,nitems)) sigma <- t(x)%*%x inverse <-
2008 May 19
2
Converting variance covariance matrix to correlation matrix
Suppose I have a Variance-covariance matrix A. Is there any fast way to calculate correlation matrix from 'A' and vice-versa without emplying any 'for' loop? [[alternative HTML version deleted]]
2008 Jun 26
2
constructing arbitrary (positive definite) covariance matrix
Dear list, I am trying to use the 'mvrnorm' function from the MASS package for simulating multivariate Gaussian data with given covariance matrix. The diagonal elements of my covariance matrix should be the same, i.e., all variables have the same marginal variance. Also all correlations between all pair of variables should be identical, but could be any value in [-1,1]. The problem I am
2011 Jun 02
4
generating random covariance matrices (with a uniform distribution of correlations)
List members, Via searches I've seen similar discussion of this topic but have not seen resolution of the particular issue I am experiencing. If my search on this topic failed, I apologize for the redundancy. I am attempting to generate random covariance matrices but would like the corresponding correlations to be uniformly distributed between -1 and 1. The approach I have been using is:
2004 Jun 25
2
Simulating from a Multivariate Normal Distribution Using a Correlation Matrix
Hello, I would like to simulate randomly from a multivariate normal distribution using a correlation matrix, rho. I do not have sigma. I have searched the help archive and the R documentation as well as doing a standard google search. What I have seen is that one can either use rmvnorm in the package: mvtnorm or mvrnorm in the package: MASS. I believe I read somewhere that the latter was
2004 Jun 07
2
MCLUST Covariance Parameterization.
Hello all (especially MCLUS users). I'm trying to make use of the MCLUST package by C. Fraley and A. Raftery. My problem is trying to figure out how the (model) identifier (e.g, EII, VII, VVI, etc.) relates to the covariance matrix. The parameterization of the covariance matrix makes use of the method of decomposition in Banfield and Rraftery (1993) and Fraley and Raftery (2002) where
2012 Oct 13
1
hep on arithmetic covariance conversion to log-covariance
Dear All,   is there a function in R that would help me convert a covariance matrix built based on arithmetic returns to a covariance matrix from log-returns?   As an example of the means and covariance from arithmetic:   mu <-c(0.094,0.006,1.337,1.046,0.263) sigma
2007 May 11
1
Create an AR(1) covariance matrix
Hi All. I need to create a first-order autoregressive covariance matrix (AR(1)) for a longitudinal mixed-model simulation. I can do this using nested "for" loops but I'm trying to improve my R coding proficiency and am curious how it might be done in a more elegant manner. To be clear, if there are 5 time points then the AR(1) matrix is 5x5 where the diagonal is a constant
2005 Jun 28
1
How to extract the within group correlation structure matrix in "lme"
Dear R users, I fitted a repeated measure model without random effects by using lme. I will use the estimates from that model as an initial estimates to do multiple imputation for missing values of the response variable in the model. I am trying to extract the within group correlation matrix or covariance matrix. here is my code: f = lme(y ~x0+x1+trt+tim+x1:tim +tim:trt,random=~-1|subj,
2018 Apr 12
3
Bivariate Normal Distribution Plots
R-Help I am attempting to create a series of bivariate normal distributions. So using the mvtnorm library I have created the following code ... # Standard deviations and correlation sig_x <- 1 sig_y <- 1 rho_xy <- 0.0 # Covariance between X and Y sig_xy <- rho_xy * sig_x *sig_y # Covariance matrix Sigma_xy <- matrix(c(sig_x ^ 2, sig_xy, sig_xy, sig_y ^ 2), nrow = 2, ncol = 2)
2011 May 05
1
matrix not positive definite (while it should be)
I do have some trouble with matrices. I want to build up a covariance matrix with a hierarchical structure). For instance, in dimension n=10, I have two subgroups (called REGION). NR=2; n=10 CORRELATION=matrix(c(0.4,-0.25, -0.25,0.3),NR,NR) REGION=sample(1:NR,size=n,replace=TRUE) R1=REGION%*%t(rep(1,n)) R2=rep(1,n)%*%t(REGION) SIGMA=matrix(NA,n,n) for(i in 1:NR){ for(j in
2007 Aug 15
3
Covariance of data with missing values.
I have a data matrix X (n x k, say) each row of which constitutes an observation of a k-dimensional random variable which I am willing, if not happy, to assume to be Gaussian, with mean ``mu'' and covariance matrix ``Sigma''. Distinct rows of X may be assumed to correspond to independent realizations of this random variable. Most rows of X (all but 240 out of 6000+ rows)
2007 Jul 24
1
function optimization: reducing the computing time
Dear useRs, I have written a function that implements a Bayesian method to compare a patient's score on two tasks with that of a small control group, as described in Crawford, J. and Garthwaite, P. (2007). Comparison of a single case to a control or normative sample in neuropsychology: Development of a bayesian approach. Cognitive Neuropsychology, 24(4):343?372. The function (see
2006 Jun 19
2
Nested variance-covariance matrix in Multilevel model
Dear R community, I have trouble implementing a nested variance-covariance matrix in the lme function. The model has two fixed effects called End and logpgc, the response variable is the logarithm to base 2 of Intensity ( log2(Intensity) ) and the random effects are called Probe and ProbeNo. The model has the following nesting structure: A Pixel is nested within the ProbeNo,the ProbeNo is
2005 Sep 08
5
data manipulation
Dear All, I would be grateful if you can help me. My problem is the following: I have a data set like: ID time X1 X2 1 1 x111 x211 1 2 x112 x212 2 1 x121 x221 2 2 x122 x222 2 3 x123 x223 where X1 and X2 are 2 covariates and "time" is the time of observation and ID indicates the
2012 Aug 11
3
Problem when creating matrix of values based on covariance matrix
Hi, I want to simulate a data set with similar covariance structure as my observed data, and have calculated a covariance matrix (dimensions 8368*8368). So far I've tried two approaches to simulating data: rmvnorm from the mvtnorm package, and by using the Cholesky decomposition (http://www.cerebralmastication.com/2010/09/cholesk-post-on-correlated-random-normal-generation/). The problem is
2013 Sep 18
2
cov2cor exp
Ok, Thanks foe the answer, Ken: *1L, 2L etc are integers. (That is, identical to as.integer(1) , as.integer(2) etc) Using integers (instead of "numeric" type) is more efficient as here they're used as indexes and would be converted to integer anyway. Compare > is(1) ... and > is(1L) 1L:p is the sequence 1, 2, 3, ..., p (just like 1:p) Just for curiosity, what is
2007 Jul 30
3
Constructing correlation matrices
Greetings, I have a seemingly simple task which I have not been able to solve today and I checked all of the help archives on this and have been unable to find anything useful. I want to construct a symmetric matrix of arbtriray size w/o using loops. The following I thought would do it: p <- 6 Rmat <- diag(p) dat.cor <- rnorm(p*(p-1)/2) Rmat[outer(1:p, 1:p, "<")] <-
2009 Jun 03
1
Function in R for computing correlation matrix and covariance matrix
Hi, At present, i have two distinct and real values for the coefficient, which is  required in AR(2) model. Based on my revision, for distinct and real values of the coefficients in AR(2) model, the correlation structure separated by lag h can be computed by p(h) = a*z1^(-h) + b*z2^(h), where p(h) is the autocorrelation separated by lag h, a and b can be determined by initial values, z1 and z2
2010 Aug 24
3
generate random numbers from a multivariate distribution with specified correlation matrix
Hi all, rmvnorm()can be used to generate the random numbers from a multivariate normal distribution with specified means and covariance matrix, but i want to specify the correlation matrix instead of covariance matrix for the multivariate normal distribution. Does anybody know how to generate the random numbers from a multivariate normal distribution with specified correlation matrix? What about