# NOT RUN {
# load corpcor library
library("corpcor")
# covariance matrix
m.cov = rbind(
c(3,1,1,0),
c(1,3,0,1),
c(1,0,2,0),
c(0,1,0,2)
)
m.cov
# corresponding correlation matrix
m.cor.1 = cov2cor(m.cov)
m.cor.1
# compute partial correlations (from covariance matrix)
m.pcor.1 = cor2pcor(m.cov)
m.pcor.1
# compute partial correlations (from correlation matrix)
m.pcor.2 = cor2pcor(m.cor.1)
m.pcor.2
zapsmall( m.pcor.1 ) == zapsmall( m.pcor.2 )
# backtransformation
m.cor.2 = pcor2cor(m.pcor.1)
m.cor.2
zapsmall( m.cor.1 ) == zapsmall( m.cor.2 )
# }
Run the code above in your browser using DataLab