partial.cor              package:GeneTS              R Documentation

_P_a_r_t_i_a_l _C_o_r_r_e_l_a_t_i_o_n _f_r_o_m _C_o_r_r_e_l_a_t_i_o_n _M_a_t_r_i_x (_a_n_d _V_i_c_e _V_e_r_s_a)

_D_e_s_c_r_i_p_t_i_o_n:

     'cor2pcor' computes the pairwise  _partial_ correlation
     coefficients from either a correlation  or a covariance matrix.
     The partial correlations represent the direct interactions between
     two variables, with the indirect effects of all remaining
     variables removed.

     'pcor2cor' takes a partial correlation matrix and computes the
     corresponding correlation matrix.

     'partial.cor' computes a partial correlation matrix directly from
     the data ('partial.cor(x)' is the same as 'cor2pcor(cor(x))').

     The underlying algorithms are based on computing the inverse of
     the covariance or correlation matrix - see Whittaker (1990) for
     details. For stability reasons and to allow near-singular matrices
      the default matrix inversion is obtained via the function 
     'pseudoinverse'  rather than using 'solve'.

_U_s_a_g_e:

     cor2pcor(m, exact.inversion=FALSE, ...)
     pcor2cor(m, exact.inversion=FALSE, ...)
     partial.cor(x, use=c("all.obs", "complete.obs", "pairwise.complete.obs"),
        method=c("pearson", "kendall", "spearman"), exact.inversion=FALSE, ...)

_A_r_g_u_m_e_n_t_s:

       m: covariance matrix or (partial) correlation matrix

       x: data matrix or data frame

exact.inversion: determines whether the inverse is computed exactly
          (using 'solve') or via 'pseudoinverse'  

     use: an optional character string giving a method for computing
          covariances in the presence of missing values. This must be
          one of the strings "all.obs" (default), "complete.obs" or
          "pairwise.complete.obs".

  method: a character string indicating which correlation coefficient
          (or covariance) is to be computed. One of "pearson"
          (default), "kendall", or "spearman".

     ...: options passed to 'pseudoinverse'

_V_a_l_u_e:

     A matrix with the pairwise partial correlation coefficients
     ('cor2pcor' and 'pcor') or with pairwise correlations ('pcor2cor')

_A_u_t_h_o_r(_s):

     Juliane Schaefer (<URL:
     http://www.stat.uni-muenchen.de/~schaefer/>) and Korbinian
     Strimmer (<URL: http://www.stat.uni-muenchen.de/~strimmer/>).

_R_e_f_e_r_e_n_c_e_s:

     Whittaker J. (1990).  Graphical Models in Applied Multivariate
     Statistics. John Wiley, Chichester.

_S_e_e _A_l_s_o:

     'cor', 'pseudoinverse'.

_E_x_a_m_p_l_e_s:

     # load GeneTS library
     library(GeneTS)

     # 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 <- standardize.cov(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 )

