[R] My own correlation structure with nlme
Mohand
M-L.Feddag at warwick.ac.uk
Mon Nov 20 15:38:36 CET 2006
Dear all,
I am trying to define my own corStruct which is different from the
classical one available in nlme. The structure of this correlation is
given below.
I am wondering to know how to continue with this structure by using
specific functions (corMatrix, getCovariate, Initialize,...) in order to
get a structure like corAR1, corSymm which will be working for my data.
Thanks in advance.
Regards
M. Feddag
*Correlation structure _
_*
pairCorr <- function(A, B, lowerTriangle = TRUE){
n <- length(A)
m <- length(B)
if (n != m) stop("A and B must have same length")
result <- matrix(0, n, n)
same.A <- outer(A, A, "==")
same.B <- outer(B, B, "==")
A.matches.B <- outer(A, B, "==")
B.matches.A <- outer(B, A, "==")
result <- result + 0.5*same.A + 0.5*same.B -
0.5*A.matches.B - 0.5*B.matches.A
rownames(result) <- colnames(result) <- paste(A, B, sep = "")
if (lowerTriangle) result <- result[row(result) > col(result)]
result
}
More information about the R-help
mailing list