I am trying to run a regression (using the gls function in nlme) in which I account for shared phylogenetic history, and my tree isn't ultrametric. I made the correlation matrix myself (because some of my data points are along the same branch of a tree, and it was just easier to do it myself). I keep getting the same error regarding the correlation matrix. My code:
s<-read.csv("vcv.csv", header=T)
cov_matrix<- as.matrix(apply(s[,-1],2,as.numeric))
row.names(cov_matrix) <- s[,1]
cormatrix<-cov2cor(cov_matrix) #the actual correlation matrix
dat<-read.csv("data.csv", header=T)
tip.heights <- diag(cov_matrix)
fit <- gls(y~x,
correlation=corSymm(cormatrix[lower.tri(cormatrix)]),
weights = varFixed(~tip.heights), #for non-ultrametric tree
data=dat)
And the error:
Error in Initialize.corSymm(X[[i]], ...) :
initial values for "corSymm" must be between -1 and 1
Thanks in advance for any help.