Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add values to diagonal to deal with non-positive definite phylogenies #9

Open
noamross opened this issue Jan 19, 2023 · 0 comments
Open

Comments

@noamross
Copy link
Contributor

When fitting a funky phylogeny, I got the following error:

pen <- MRFtools::mrf_penalty(tree)
>chol.default(vcv(object)) : 
> the leading minor of order 178 is not positive definite

This can be solved by modifying the variance-covariance matrix slightly, making https://github.com/eric-pedersen/MRFtools/blob/master/R/penalties.R#L222 into:

eps <- .Machine$double.eps
pen <- chol2inv(chol(vcv(object) + eps*diag(length(object$tip.label)))) 

The question is, should eps be default or an argument to mrf_penalty.phylo() and should be this implemented for other methods? Or is this too finicky, in which case maybe there should be a .matrix method that takes a covariance matrix so people can provide it themselves as needed?

Happy to PR if we agree on the best way to do this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant