Search in sources :

Example 36 with StrictClockBranchRates

use of dr.evomodel.branchratemodel.StrictClockBranchRates in project beast-mcmc by beast-dev.

the class ContinuousDataLikelihoodDelegateTest method testLikelihoodDriftRelaxedFactor.

public void testLikelihoodDriftRelaxedFactor() {
    System.out.println("\nTest Likelihood using drifted Relaxed BM and factor:");
    // Diffusion
    List<BranchRateModel> driftModels = new ArrayList<BranchRateModel>();
    ArbitraryBranchRates.BranchRateTransform transform = make(false, false, false);
    driftModels.add(new ArbitraryBranchRates(treeModel, new Parameter.Default("rate.1", new double[] { 0, 10, 20, 30, 40, 40, 30, 20, 10, 0 }), transform, false));
    driftModels.add(new StrictClockBranchRates(new Parameter.Default("rate.2", new double[] { 0.0 })));
    DiffusionProcessDelegate diffusionProcessDelegate = new DriftDiffusionModelDelegate(treeModel, diffusionModelFactor, driftModels);
    // CDL
    ContinuousDataLikelihoodDelegate likelihoodDelegateFactors = new ContinuousDataLikelihoodDelegate(treeModel, diffusionProcessDelegate, dataModelFactor, rootPriorFactor, rateTransformation, rateModel, false);
    dataModelFactor.setLikelihoodDelegate(likelihoodDelegateFactors);
    // Likelihood Computation
    TreeDataLikelihood dataLikelihoodFactors = new TreeDataLikelihood(likelihoodDelegateFactors, treeModel, rateModel);
    testLikelihood("likelihoodDriftRelaxedFactor", dataModelFactor, dataLikelihoodFactors);
    // Conditional simulations
    MathUtils.setSeed(17890826);
    double[] expectedTraits = new double[] { 0.21992781609528125, 1.271388273711557, 0.40761548539751596, 1.3682648770877144, 0.6599021787120436, 1.2830636141108613, 1.1488658943588324, 1.472103688153391, 0.8971632986744889, 1.20748933414854, 1.603739823726808, 1.4761482401796842 };
    testConditionalSimulations(dataLikelihoodFactors, likelihoodDelegateFactors, diffusionModelFactor, dataModelFactor, rootPriorFactor, expectedTraits);
}
Also used : ArbitraryBranchRates(dr.evomodel.branchratemodel.ArbitraryBranchRates) TreeDataLikelihood(dr.evomodel.treedatalikelihood.TreeDataLikelihood) BranchRateModel(dr.evomodel.branchratemodel.BranchRateModel) DefaultBranchRateModel(dr.evomodel.branchratemodel.DefaultBranchRateModel) ArrayList(java.util.ArrayList) StrictClockBranchRates(dr.evomodel.branchratemodel.StrictClockBranchRates)

Example 37 with StrictClockBranchRates

use of dr.evomodel.branchratemodel.StrictClockBranchRates in project beast-mcmc by beast-dev.

the class ContinuousDataLikelihoodDelegateTest method testLikelihoodDrift.

public void testLikelihoodDrift() {
    System.out.println("\nTest Likelihood using Drifted BM:");
    // Diffusion
    List<BranchRateModel> driftModels = new ArrayList<BranchRateModel>();
    driftModels.add(new StrictClockBranchRates(new Parameter.Default("rate.1", new double[] { 100.0 })));
    driftModels.add(new StrictClockBranchRates(new Parameter.Default("rate.2", new double[] { 200.0 })));
    driftModels.add(new StrictClockBranchRates(new Parameter.Default("rate.3", new double[] { -200.0 })));
    DiffusionProcessDelegate diffusionProcessDelegate = new DriftDiffusionModelDelegate(treeModel, diffusionModel, driftModels);
    // CDL
    ContinuousDataLikelihoodDelegate likelihoodDelegate = new ContinuousDataLikelihoodDelegate(treeModel, diffusionProcessDelegate, dataModel, rootPrior, rateTransformation, rateModel, false);
    // Likelihood Computation
    TreeDataLikelihood dataLikelihood = new TreeDataLikelihood(likelihoodDelegate, treeModel, rateModel);
    testLikelihood("likelihoodDrift", dataLikelihood);
    // Conditional moments (preorder)
    testConditionalMoments(dataLikelihood, likelihoodDelegate);
    // Conditional simulations
    MathUtils.setSeed(17890826);
    double[] expectedTraits = new double[] { -1.0, 2.0, 0.0, 0.5457621072639138, 3.28662834718796, 3.2939596558001845, 0.5, 1.0742799493604265, 5.5, 2.0, 5.0, -8.0, 11.0, 1.0, -1.5, 1.0, 2.5, 4.0 };
    testConditionalSimulations(dataLikelihood, likelihoodDelegate, diffusionModel, dataModel, rootPrior, expectedTraits);
    // Fixed Root
    ContinuousDataLikelihoodDelegate likelihoodDelegateInf = new ContinuousDataLikelihoodDelegate(treeModel, diffusionProcessDelegate, dataModel, rootPriorInf, rateTransformation, rateModel, true);
    TreeDataLikelihood dataLikelihoodInf = new TreeDataLikelihood(likelihoodDelegateInf, treeModel, rateModel);
    testLikelihood("likelihoodDriftInf", dataLikelihoodInf);
    testConditionalMoments(dataLikelihoodInf, likelihoodDelegateInf);
}
Also used : TreeDataLikelihood(dr.evomodel.treedatalikelihood.TreeDataLikelihood) BranchRateModel(dr.evomodel.branchratemodel.BranchRateModel) DefaultBranchRateModel(dr.evomodel.branchratemodel.DefaultBranchRateModel) ArrayList(java.util.ArrayList) StrictClockBranchRates(dr.evomodel.branchratemodel.StrictClockBranchRates)

Example 38 with StrictClockBranchRates

use of dr.evomodel.branchratemodel.StrictClockBranchRates in project beast-mcmc by beast-dev.

the class ContinuousDataLikelihoodDelegateTest method testLikelihoodDriftFactor.

public void testLikelihoodDriftFactor() {
    System.out.println("\nTest Likelihood using drifted BM and factor:");
    // Diffusion
    List<BranchRateModel> driftModels = new ArrayList<BranchRateModel>();
    driftModels.add(new StrictClockBranchRates(new Parameter.Default("rate.1", new double[] { 0.0 })));
    driftModels.add(new StrictClockBranchRates(new Parameter.Default("rate.2", new double[] { -40.0 })));
    DiffusionProcessDelegate diffusionProcessDelegate = new DriftDiffusionModelDelegate(treeModel, diffusionModelFactor, driftModels);
    // CDL
    ContinuousDataLikelihoodDelegate likelihoodDelegateFactors = new ContinuousDataLikelihoodDelegate(treeModel, diffusionProcessDelegate, dataModelFactor, rootPriorFactor, rateTransformation, rateModel, false);
    dataModelFactor.setLikelihoodDelegate(likelihoodDelegateFactors);
    // Likelihood Computation
    TreeDataLikelihood dataLikelihoodFactors = new TreeDataLikelihood(likelihoodDelegateFactors, treeModel, rateModel);
    testLikelihood("likelihoodDriftFactor", dataModelFactor, dataLikelihoodFactors);
    // Conditional simulations
    MathUtils.setSeed(17890826);
    double[] expectedTraits = new double[] { 1.5058510863259034, -2.344107747791032, 1.415239714927795, -2.225937980916329, 1.5639840062954773, -2.3082612693286513, 1.9875205911751028, -2.1049011248405525, 1.3355460225282372, -2.2848471441564056, 1.742347318026791, -1.940903337116235 };
    testConditionalSimulations(dataLikelihoodFactors, likelihoodDelegateFactors, diffusionModelFactor, dataModelFactor, rootPriorFactor, expectedTraits);
}
Also used : TreeDataLikelihood(dr.evomodel.treedatalikelihood.TreeDataLikelihood) BranchRateModel(dr.evomodel.branchratemodel.BranchRateModel) DefaultBranchRateModel(dr.evomodel.branchratemodel.DefaultBranchRateModel) ArrayList(java.util.ArrayList) StrictClockBranchRates(dr.evomodel.branchratemodel.StrictClockBranchRates)

Example 39 with StrictClockBranchRates

use of dr.evomodel.branchratemodel.StrictClockBranchRates in project beast-mcmc by beast-dev.

the class ContinuousDataLikelihoodDelegateTest method testLikelihoodFullOU.

public void testLikelihoodFullOU() {
    System.out.println("\nTest Likelihood using Full OU:");
    // Diffusion
    List<BranchRateModel> optimalTraitsModels = new ArrayList<BranchRateModel>();
    optimalTraitsModels.add(new StrictClockBranchRates(new Parameter.Default("rate.1", new double[] { 1.0 })));
    optimalTraitsModels.add(new StrictClockBranchRates(new Parameter.Default("rate.2", new double[] { 2.0 })));
    optimalTraitsModels.add(new StrictClockBranchRates(new Parameter.Default("rate.3", new double[] { -2.0 })));
    Parameter[] strengthOfSelectionParameters = new Parameter[3];
    strengthOfSelectionParameters[0] = new Parameter.Default(new double[] { 0.5, 0.2, 0.0 });
    strengthOfSelectionParameters[1] = new Parameter.Default(new double[] { 0.2, 100.0, 0.1 });
    strengthOfSelectionParameters[2] = new Parameter.Default(new double[] { 0.0, 0.1, 50.5 });
    MatrixParameter strengthOfSelectionMatrixParam = new MatrixParameter("strengthOfSelectionMatrix", strengthOfSelectionParameters);
    DiffusionProcessDelegate diffusionProcessDelegate = new OUDiffusionModelDelegate(treeModel, diffusionModel, optimalTraitsModels, new MultivariateElasticModel(strengthOfSelectionMatrixParam));
    // CDL
    ContinuousDataLikelihoodDelegate likelihoodDelegate = new ContinuousDataLikelihoodDelegate(treeModel, diffusionProcessDelegate, dataModel, rootPrior, rateTransformation, rateModel, false);
    // Likelihood Computation
    TreeDataLikelihood dataLikelihood = new TreeDataLikelihood(likelihoodDelegate, treeModel, rateModel);
    testLikelihood("likelihoodFullOU", dataLikelihood);
    // Conditional moments (preorder)
    testConditionalMoments(dataLikelihood, likelihoodDelegate);
    // Conditional simulations
    MathUtils.setSeed(17890826);
    double[] expectedTraits = new double[] { -1.0, 2.0, 0.0, 1.0427958776637916, 2.060317467842193, 0.5916377446549433, 0.5, 2.07249828895442, 5.5, 2.0, 5.0, -8.0, 11.0, 1.0, -1.5, 1.0, 2.5, 4.0 };
    testConditionalSimulations(dataLikelihood, likelihoodDelegate, diffusionModel, dataModel, rootPrior, expectedTraits);
    // Fixed Root
    ContinuousDataLikelihoodDelegate likelihoodDelegateInf = new ContinuousDataLikelihoodDelegate(treeModel, diffusionProcessDelegate, dataModel, rootPriorInf, rateTransformation, rateModel, true);
    TreeDataLikelihood dataLikelihoodInf = new TreeDataLikelihood(likelihoodDelegateInf, treeModel, rateModel);
    testLikelihood("likelihoodFullOUInf", dataLikelihoodInf);
    testConditionalMoments(dataLikelihoodInf, likelihoodDelegateInf);
}
Also used : MatrixParameter(dr.inference.model.MatrixParameter) ArrayList(java.util.ArrayList) MultivariateElasticModel(dr.evomodel.continuous.MultivariateElasticModel) StrictClockBranchRates(dr.evomodel.branchratemodel.StrictClockBranchRates) TreeDataLikelihood(dr.evomodel.treedatalikelihood.TreeDataLikelihood) BranchRateModel(dr.evomodel.branchratemodel.BranchRateModel) DefaultBranchRateModel(dr.evomodel.branchratemodel.DefaultBranchRateModel) MatrixParameter(dr.inference.model.MatrixParameter) Parameter(dr.inference.model.Parameter)

Example 40 with StrictClockBranchRates

use of dr.evomodel.branchratemodel.StrictClockBranchRates in project beast-mcmc by beast-dev.

the class ContinuousDataLikelihoodDelegateTest method testLikelihoodFullOURelaxedFactor.

public void testLikelihoodFullOURelaxedFactor() {
    System.out.println("\nTest Likelihood using full Relaxed OU and factor:");
    // Diffusion
    List<BranchRateModel> optimalTraitsModels = new ArrayList<BranchRateModel>();
    ArbitraryBranchRates.BranchRateTransform transform = make(false, false, false);
    optimalTraitsModels.add(new ArbitraryBranchRates(treeModel, new Parameter.Default("rate.1", new double[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }), transform, false));
    optimalTraitsModels.add(new StrictClockBranchRates(new Parameter.Default("rate.2", new double[] { 1.5 })));
    Parameter[] strengthOfSelectionParameters = new Parameter[2];
    strengthOfSelectionParameters[0] = new Parameter.Default(new double[] { 0.5, 0.15 });
    strengthOfSelectionParameters[1] = new Parameter.Default(new double[] { 0.15, 25.5 });
    MatrixParameter strengthOfSelectionMatrixParam = new MatrixParameter("strengthOfSelectionMatrix", strengthOfSelectionParameters);
    DiffusionProcessDelegate diffusionProcessDelegate = new OUDiffusionModelDelegate(treeModel, diffusionModelFactor, optimalTraitsModels, new MultivariateElasticModel(strengthOfSelectionMatrixParam));
    // CDL
    ContinuousDataLikelihoodDelegate likelihoodDelegateFactors = new ContinuousDataLikelihoodDelegate(treeModel, diffusionProcessDelegate, dataModelFactor, rootPriorFactor, rateTransformation, rateModel, false);
    dataModelFactor.setLikelihoodDelegate(likelihoodDelegateFactors);
    // Likelihood Computation
    TreeDataLikelihood dataLikelihoodFactors = new TreeDataLikelihood(likelihoodDelegateFactors, treeModel, rateModel);
    testLikelihood("likelihoodFullRelaxedOUFactor", dataModelFactor, dataLikelihoodFactors);
    // Conditional simulations
    MathUtils.setSeed(17890826);
    double[] expectedTraits = new double[] { 0.6074917696668031, 1.4240248941610945, 0.5818653246406664, 1.545237778993696, 0.7248840308905077, 1.4623057820376757, 1.0961030597302799, 1.603694717986661, 0.44280937767720896, 1.5374906898020686, 0.920698984735896, 1.6011019734876784 };
    testConditionalSimulations(dataLikelihoodFactors, likelihoodDelegateFactors, diffusionModelFactor, dataModelFactor, rootPriorFactor, expectedTraits);
}
Also used : MatrixParameter(dr.inference.model.MatrixParameter) ArrayList(java.util.ArrayList) MultivariateElasticModel(dr.evomodel.continuous.MultivariateElasticModel) StrictClockBranchRates(dr.evomodel.branchratemodel.StrictClockBranchRates) ArbitraryBranchRates(dr.evomodel.branchratemodel.ArbitraryBranchRates) TreeDataLikelihood(dr.evomodel.treedatalikelihood.TreeDataLikelihood) BranchRateModel(dr.evomodel.branchratemodel.BranchRateModel) DefaultBranchRateModel(dr.evomodel.branchratemodel.DefaultBranchRateModel) MatrixParameter(dr.inference.model.MatrixParameter) Parameter(dr.inference.model.Parameter)

Aggregations

StrictClockBranchRates (dr.evomodel.branchratemodel.StrictClockBranchRates)41 BranchRateModel (dr.evomodel.branchratemodel.BranchRateModel)32 ArrayList (java.util.ArrayList)29 DefaultBranchRateModel (dr.evomodel.branchratemodel.DefaultBranchRateModel)26 Parameter (dr.inference.model.Parameter)26 TreeDataLikelihood (dr.evomodel.treedatalikelihood.TreeDataLikelihood)21 MultivariateElasticModel (dr.evomodel.continuous.MultivariateElasticModel)18 MatrixParameter (dr.inference.model.MatrixParameter)15 ArbitraryBranchRates (dr.evomodel.branchratemodel.ArbitraryBranchRates)10 NewickImporter (dr.evolution.io.NewickImporter)8 DiagonalMatrix (dr.inference.model.DiagonalMatrix)7 CladeNodeModel (dr.evomodel.bigfasttree.constrainedtree.CladeNodeModel)5 ConstrainedTreeBranchLengthProvider (dr.evomodel.bigfasttree.constrainedtree.ConstrainedTreeBranchLengthProvider)5 NodeRef (dr.evolution.tree.NodeRef)4 DefaultTreeModel (dr.evomodel.tree.DefaultTreeModel)4 TreeModel (dr.evomodel.tree.TreeModel)4 Tree (dr.evolution.tree.Tree)3 Taxon (dr.evolution.util.Taxon)3 CladeRef (dr.evomodel.bigfasttree.constrainedtree.CladeRef)3 GammaSiteRateModel (dr.evomodel.siteratemodel.GammaSiteRateModel)3