- 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)
+ if (!("corMartins" %in% class(object)))
+ stop("object is not of class \"corMartins\".")
+ if(!any(attr(object, "index")))
+ stop("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]]
+ matr