| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
package test.dr.evomodel.speciation; |
| 27 |
|
| 28 |
import dr.evolution.io.NewickImporter; |
| 29 |
import dr.evolution.tree.FlexibleTree; |
| 30 |
import dr.evolution.tree.Tree; |
| 31 |
import dr.evolution.util.Units; |
| 32 |
import dr.evomodel.speciation.BirthDeathGernhard08Model; |
| 33 |
import dr.evomodel.speciation.SpeciationLikelihood; |
| 34 |
import dr.evomodel.speciation.SpeciationModel; |
| 35 |
import dr.evomodelxml.tree.TreeModelParser; |
| 36 |
import dr.inference.model.Likelihood; |
| 37 |
import dr.inference.model.Parameter; |
| 38 |
import junit.framework.Test; |
| 39 |
import junit.framework.TestCase; |
| 40 |
import junit.framework.TestSuite; |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
public class YuleLikelihoodTest extends TestCase { |
| 50 |
|
| 51 |
static final String TL = "TL"; |
| 52 |
static final String TREE_HEIGHT = TreeModelParser.ROOT_HEIGHT; |
| 53 |
|
| 54 |
private FlexibleTree tree; |
| 55 |
|
| 56 |
public YuleLikelihoodTest(String name) { |
| 57 |
super(name); |
| 58 |
} |
| 59 |
|
| 60 |
public void setUp() throws Exception { |
| 61 |
super.setUp(); |
| 62 |
|
| 63 |
NewickImporter importer = new NewickImporter("((1:1.0,2:1.0):1.0,(3:1.0,4:1.0):1.0);"); |
| 64 |
tree = (FlexibleTree) importer.importTree(null); |
| 65 |
} |
| 66 |
|
| 67 |
public void testYuleLikelihood() { |
| 68 |
|
| 69 |
yuleLikelihoodTester(tree, 1.0, -2.8219461696520542); |
| 70 |
|
| 71 |
} |
| 72 |
|
| 73 |
private void yuleLikelihoodTester(Tree tree, double birthRate, double logL) { |
| 74 |
|
| 75 |
Parameter b = new Parameter.Default("b", birthRate, 0.0, Double.MAX_VALUE); |
| 76 |
Parameter d = new Parameter.Default("d", 0.0, 0.0, Double.MAX_VALUE); |
| 77 |
|
| 78 |
SpeciationModel speciationModel = new BirthDeathGernhard08Model(b, d, null, BirthDeathGernhard08Model.TreeType.TIMESONLY, |
| 79 |
Units.Type.YEARS); |
| 80 |
Likelihood likelihood = new SpeciationLikelihood(tree, speciationModel, "yule.like"); |
| 81 |
|
| 82 |
assertEquals(likelihood.getLogLikelihood(), logL); |
| 83 |
|
| 84 |
} |
| 85 |
|
| 86 |
public static Test suite() { |
| 87 |
return new TestSuite(YuleLikelihoodTest.class); |
| 88 |
} |
| 89 |
} |