Hi,

among the many (5) methods that I found in the list to do partial
correlation in the following two that I had a look I am getting different
t-values. Does anyone have any clues on why is that? The source code is
below. Thanks.

pcor3 <- function (x, test = T, p = 0.05) {
  nvar <- ncol(x)
  ndata <- nrow(x)
  conc <- solve(cor(x))
  resid.sd <- 1/sqrt(diag(conc))
  pcc <- -sweep(sweep(conc, 1, resid.sd, "*"), 2, resid.sd, "*")
  #colnames(pcc) <- rownames(pcc) <- colnames(x)
  if (test) {
    t.df <- ndata - nvar
    t <- pcc/sqrt((1 - pcc^2)/t.df)
    print(t);
    pcc <- list(coefs = pcc, sig = t > qt(1 - (p/2), df = t.df))
  }
  return(pcc)
}


pcor4 <- function(x, y, z) {
  return(cor.test(lm(x~z)$resid,lm(y~z)$resid));
}

	[[alternative HTML version deleted]]

