Dear all,

I made a simple test of the Cholesky decomposition in the package 'Matrix',
by considering 2 variables 100% correlated.
http://blogs.sas.com/content/iml/2012/02/08/use-the-cholesky-transformation-to-correlate-and-uncorrelate-variables/

The full code is below and can be simply copy&paste in the R prompt.

After uncorrelation I still have a correlation of +-100%...

###########################################
# 4 observations of 2 variables, 100% correlated
obs=matrix(nrow=2,ncol=4)
obs[1,]=seq(from=1, to=4, by=1)
obs[2,]=obs[1,]

# Plot
plot( obs[1,], obs[2,],pch=16)

# Correlation matrix
corr=matrix(nrow=2,ncol=2)
corr[1,2]=0.95
corr[2,1]=0.95
corr[1,1]=1
corr[2,2]=1

# Cholesky decomposition
choM=chol(corr)

# Decorrelated observation
decObs=matrix(nrow=2,ncol=4)
for( i in 1:4 ) decObs[,i]=choM%*%obs[,i]

# Other possibility
#decObs=solve(choM,obs)

# Plot
plot(decObs[1,], decObs[2,],pch=16)
###########################################

Does anyone have an idea?

Thanks,
regards,
Xavier



-- 
*---------------------------------------
Xavier Prudent
*
*
Computational biology and evolutionary genomics
*
*
*
*Guest scientist at the Max-Planck-Institut für Physik komplexer Systeme*
*(MPI-PKS)*
*Noethnitzer Str. 38*
*01187 Dresden
*
*
*
*Max Planck-Institute for Molecular Cell Biology and Genetics*
*
(MPI-CBG)
*
*
Pfotenhauerstraße 108
*
*
01307 Dresden
*
*

*
*
Phone: +49 351 210-2621
*
*Mail: prudent [ at ] mpi-cbg.de
**---------------------------------------*

        [[alternative HTML version deleted]]

______________________________________________
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.

Reply via email to