Hi, How to convert a var-covar matrix to correlation matrix. Thanks --------------------------------- [[alternate HTML version deleted]]
> Var <- array(c(4, 1, 1, 4), dim=c(2,2))> Sd <- sqrt(diag(Var)) > Var/outer(Sd, Sd) [,1] [,2] [1,] 1.00 0.25 [2,] 0.25 1.00 hope this helps. spencer graves Shutnik wrote:> Hi, How to convert a var-covar matrix to correlation matrix. Thanks > > > > --------------------------------- > > > [[alternate HTML version deleted]] > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help
If the variance matrix is large, then t(Var / Sd) / Sd is probably more efficient. Patrick Burns Burns Statistics patrick at burns-stat.com +44 (0) 208 525 0696 http://www.burns-stat.com/ (home of S Poetry and "A Guide for the Unwilling S User") Spencer Graves wrote:> > Var <- array(c(4, 1, 1, 4), dim=c(2,2)) > > Sd <- sqrt(diag(Var)) > > Var/outer(Sd, Sd) > [,1] [,2] > [1,] 1.00 0.25 > [2,] 0.25 1.00 > > hope this helps. spencer graves > > Shutnik wrote: > >> Hi, How to convert a var-covar matrix to correlation matrix. Thanks >> >> >> >> --------------------------------- >> >> >> [[alternate HTML version deleted]] >> >> ______________________________________________ >> R-help at stat.math.ethz.ch mailing list >> https://www.stat.math.ethz.ch/mailman/listinfo/r-help > > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > >
Hello, I have the normal random variables y(t)~N(mu, sigma.sq) and want to decompose them into n normal variables: y(t) = x(t,1) + … + x(t,n) x(t,i)~N(mu, sigma.sq/n) The problem is not as simple as can appear. All my experiments didn’t give me anything so far. Are there any tools to do this? Thanks --------------------------------- [[alternate HTML version deleted]]
No solution exists, because the mean of a sum of n random variables each with mean mu is n*mu, which is different from mu if n > 1. Beyond this, it is not clear to me what you want, but the following might help, if my understanding of your problem is close to correct: y <- rnorm(1) n <- 3 x <- rnorm(n)/sqrt(3) x <- y*x/sum(x) x; sum(x); y hth. spencer graves Shutnik wrote:> Hello, > I have the normal random variables y(t)~N(mu, sigma.sq) and want to decompose them into n normal variables: > > y(t) = x(t,1) + ? + x(t,n) > > x(t,i)~N(mu, sigma.sq/n) > > The problem is not as simple as can appear. All my experiments didn?t give me anything so far. Are there any tools to do this? > > > Thanks > > > > --------------------------------- > > > [[alternate HTML version deleted]] > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Peter Dalgaard writes:> Shutnik <shutnik_xx at yahoo.co.uk> writes: > > > Hello, > > I have the normal random variables y(t)~N(mu, sigma.sq) and want > > to decompose them into n normal variables: > > > > y(t) = x(t,1) ++ x(t,n) I presume this means y(t) = x(t,1) + ... + x(t,n) (R.T.)> > > > x(t,i)~N(mu, sigma.sq/n)I presume you want x(t,i)~N(mu/n, sigma.sq/n), elsewise the question doesn't make sense. I also presume you want the x(t,i) to be independent, elsewise the question is trivial. (R.T.)> > > > The problem is not as simple as can appear. All my experiments > > didnt give me anything so far. Are there any tools to do this? > > > > This should work, provided I understand the problem correctly: > > x <- rnorm(n,sd=sqrt(sigma.sq/n)) > x <- x - mean(x) + y/nI don't think it's that simple: By my calculations, Var(x_i) = 2*sigma.sq/n - sigma.sq/n^2, not sigma.sq/n. I think the problem is actually fairly subtle (although I may be overlooking something simple). Something like a Gramm-Schmidt approach should work, but I can't quite suss it out. cheers, Rolf Turner rolf at math.unb.ca