[R] partial correlation significance

From: <gatemaze_at_gmail.com>
Date: Fri, 18 May 2007 20:09:13 +0100


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]]



R-help_at_stat.math.ethz.ch 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. Received on Fri 18 May 2007 - 19:23:00 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 18 May 2007 - 20:33:14 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.