daijiang / phyr

Functions for phylogenetic analyses
https://daijiang.github.io/phyr/
GNU General Public License v3.0
30 stars 10 forks source link

Fixed issue that 4 element list and 1 element list approaches to spec… #59

Closed rdinnager closed 3 years ago

rdinnager commented 3 years ago

…ifying random effects did not produce same result for the INLA model. As a side-effect of the fix, phylogenetic random effects no longer have sum-to-zero constraint. On reflection, this constraint should not have been there, but shouldn't make too much difference in most cases.

I will continue using this branch to try and implement the speed up we discussed previously. In the mean time, I fixed the issue we were having before. It was caused by me specifying random effects to have a sum-to-zero constraint. I wrote that original code a long time ago, before I understood as much about the INLA models. Sum-to-zero normally doesn't hurt, but in this case led to a different model because of how the constraint was applied in INLA when it was doing the kronecker product internally. Sum-to-zero is only necessary for certain INLA models with singular precision matrices, in order to make the model identifiable. We shouldn't need it for phylogenetic models. Note this change could cause old results from phyr to be different from new results. But in most cases, they shouldn't be too different.