- }
- return(object)
-}
-
-corMatrix.corBrownian <- function(object, covariate = getCovariate(object), corr = TRUE, ...)
-{
- if (!("corBrownian" %in% class(object))) stop("ERROR!!! Object is not of class \"corBrownian\".")
- if(!any(attr(object, "index"))) stop("ERROR!!! object have not been initialized.")
- tree <- attr(object, "tree")
- mat <- vcv.phylo(tree, cor = corr)
- n <- dim(mat)[1]
- # reorder matrix:
- matr <- matrix(nrow=n, ncol=n)
- index <- attr(object, "index")
- for(i in 1:n)
- for(j in i:n)
- matr[i,j] <- matr[j,i] <- mat[index[i], index[j]]
- return(matr)
-}
-
-corMatrix.corMartins <- function(object, covariate = getCovariate(object), corr = TRUE, ...)
-{
- if (!("corMartins" %in% class(object))) stop("ERROR!!! Object is not of class \"corMartins\".")
- if(!any(attr(object, "index"))) stop("ERROR!!! object have not been initialized.")
- tree <- attr(object, "tree")
- dist <- cophenetic.phylo(tree)
- mat <- exp(-object[1] * dist)
- if(corr) mat <- cov2cor(mat)
- n <- dim(mat)[1]
- # reorder matrix:
- matr <- matrix(nrow=n, ncol=n)
- index <- attr(object, "index")
- for(i in 1:n)
- for(j in i:n)
- matr[i,j] <- matr[j,i] <- mat[index[i], index[j]]
- return(matr)
-}
-
-corMatrix.corGrafen <- function(object, covariate = getCovariate(object), corr = TRUE, ...)
-{
- if (!("corGrafen" %in% class(object))) stop("ERROR!!! Object is not of class \"corGrafen\".")
- if(!any(attr(object, "index"))) stop("ERROR!!! object have not been initialized.")
- tree <- compute.brlen(attr(object, "tree"), method = "Grafen", power = exp(object[1]))
- mat <- vcv.phylo(tree, cor = corr)
- n <- dim(mat)[1]
- # reorder matrix:
- matr <- matrix(nrow=n, ncol=n)
- index <- attr(object, "index")
- for(i in 1:n)
- for(j in i:n)
- matr[i,j] <- matr[j,i] <- mat[index[i], index[j]]
- return(matr)
+ object
+}
+
+corMatrix.corBrownian <-
+ function(object, covariate = getCovariate(object), corr = TRUE, ...)
+{
+ if (!("corBrownian" %in% class(object)))
+ stop('object is not of class "corBrownian"')
+ if (!any(attr(object, "index")))
+ stop("object has not been initialized.")
+ tree <- attr(object, "tree")
+ mat <- vcv.phylo(tree, corr = corr)
+ n <- dim(mat)[1]
+ ## reorder matrix:
+ index <- attr(object, "index")
+ mat[index, index]
+}
+
+corMatrix.corMartins <-
+ function(object, covariate = getCovariate(object), corr = TRUE, ...)
+{
+ if (!("corMartins" %in% class(object)))
+ stop('object is not of class "corMartins"')
+ if (!any(attr(object, "index")))
+ stop("object has not been initialized.")
+ tree <- attr(object, "tree")
+ dist <- cophenetic.phylo(tree)
+ mat <- exp(-object[1] * dist)
+ if (corr) mat <- cov2cor(mat)
+ n <- dim(mat)[1]
+ ## reorder matrix:
+ index <- attr(object, "index")
+ mat[index, index]
+}
+
+corMatrix.corGrafen <-
+ function(object, covariate = getCovariate(object), corr = TRUE, ...)
+{
+ if (!("corGrafen" %in% class(object)))
+ stop('object is not of class "corGrafen"')
+ if (!any(attr(object, "index")))
+ stop("object has not been initialized.")
+ tree <- compute.brlen(attr(object, "tree"),
+ method = "Grafen", power = exp(object[1]))
+ mat <- vcv.phylo(tree, corr = corr)
+ n <- dim(mat)[1]
+ ## reorder matrix:
+ index <- attr(object, "index")
+ mat[index, index]