Performing a relative rate test¶
Section author: Gavin Huttley
From cogent3
import all the components we need
Get your alignment and tree.
Create a HKY85 model.
Make the controller object and limit the display precision (to decrease the chance that small differences in estimates cause tests of the documentation to fail).
Set the local clock for humans & Howler Monkey. This method is just a special interface to the more general set_param_rules()
method.
Get the likelihood function object this object performs the actual likelihood calculation.
Optimise the function capturing the return optimised lnL, and parameter value vector.
View the resulting maximum-likelihood parameter values.
We extract the log-likelihood and number of free parameters for later use.
Clear the local clock constraint, freeing up the branch lengths.
Run the optimiser capturing the return optimised lnL, and parameter value vector.
View the resulting maximum-likelihood parameter values.
These two lnL’s are now used to calculate the likelihood ratio statistic it’s degrees-of-freedom and the probability of observing the LR.
Print this and look up a \(\chi^2\) with number of edges - 1 degrees of freedom.