use of dr.evomodel.treedatalikelihood.TreeDataLikelihood in project beast-mcmc by beast-dev.
the class ContinuousDataLikelihoodDelegateTest method testLikelihoodFullOUNonSymmetricRelaxed.
public void testLikelihoodFullOUNonSymmetricRelaxed() {
System.out.println("\nTest Likelihood using Full Non symmetric OU Relaxed:");
// 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 ArbitraryBranchRates(treeModel, new Parameter.Default("rate.2", new double[] { 0, -1, 2, -3, 4, -5, 6, -7, 8, -9 }), transform, false));
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.0, 0.0 });
strengthOfSelectionParameters[1] = new Parameter.Default(new double[] { 0.2, 100.0, 0.1 });
strengthOfSelectionParameters[2] = new Parameter.Default(new double[] { 10.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("likelihoodFullNonSymmetricOURelaxed", dataLikelihood);
// Conditional moments (preorder)
testConditionalMoments(dataLikelihood, likelihoodDelegate);
// Fixed Root
ContinuousDataLikelihoodDelegate likelihoodDelegateInf = new ContinuousDataLikelihoodDelegate(treeModel, diffusionProcessDelegate, dataModel, rootPriorInf, rateTransformation, rateModel, true);
TreeDataLikelihood dataLikelihoodInf = new TreeDataLikelihood(likelihoodDelegateInf, treeModel, rateModel);
testLikelihood("likelihoodFullNonSymmetricOURelaxedInf", dataLikelihoodInf);
testConditionalMoments(dataLikelihoodInf, likelihoodDelegateInf);
}
use of dr.evomodel.treedatalikelihood.TreeDataLikelihood in project beast-mcmc by beast-dev.
the class ContinuousDataLikelihoodDelegateTest method testLikelihoodBM.
public void testLikelihoodBM() {
System.out.println("\nTest Likelihood using vanilla BM:");
// Diffusion
DiffusionProcessDelegate diffusionProcessDelegate = new HomogeneousDiffusionModelDelegate(treeModel, diffusionModel);
// CDL
ContinuousDataLikelihoodDelegate likelihoodDelegate = new ContinuousDataLikelihoodDelegate(treeModel, diffusionProcessDelegate, dataModel, rootPrior, rateTransformation, rateModel, true);
// Likelihood Computation
TreeDataLikelihood dataLikelihood = new TreeDataLikelihood(likelihoodDelegate, treeModel, rateModel);
testLikelihood("likelihoodBM", dataLikelihood);
// Conditional moments (preorder)
testConditionalMoments(dataLikelihood, likelihoodDelegate);
// Conditional simulations
MathUtils.setSeed(17890826);
double[] expectedTraits = new double[] { -1.0, 2.0, 0.0, 0.45807521679597646, 2.6505355982097605, 3.4693334367360538, 0.5, 2.64206285585883, 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("likelihoodBMInf", dataLikelihoodInf);
testConditionalMoments(dataLikelihoodInf, likelihoodDelegateInf);
}
use of dr.evomodel.treedatalikelihood.TreeDataLikelihood in project beast-mcmc by beast-dev.
the class ContinuousDataLikelihoodDelegateTest method testLikelihoodDiagonalOU.
public void testLikelihoodDiagonalOU() {
System.out.println("\nTest Likelihood using Diagonal 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 })));
DiagonalMatrix strengthOfSelectionMatrixParam = new DiagonalMatrix(new Parameter.Default(new double[] { 0.1, 100.0, 50.0 }));
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("likelihoodDiagonalOU", dataLikelihood);
// Conditional moments (preorder)
testConditionalMoments(dataLikelihood, likelihoodDelegate);
// Conditional simulations
MathUtils.setSeed(17890826);
double[] expectedTraits = new double[] { -1.0, 2.0, 0.0, 1.0369622398437415, 2.065450266793184, 0.6174755164694558, 0.5, 2.0829935706195615, 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("likelihoodDiagonalOUInf", dataLikelihoodInf);
testConditionalMoments(dataLikelihoodInf, likelihoodDelegateInf);
}
use of dr.evomodel.treedatalikelihood.TreeDataLikelihood in project beast-mcmc by beast-dev.
the class ContinuousDataLikelihoodDelegateTest method testLikelihoodDiagonalOUFactor.
public void testLikelihoodDiagonalOUFactor() {
System.out.println("\nTest Likelihood using diagonal OU and factor:");
// 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[] { -1.5 })));
DiagonalMatrix strengthOfSelectionMatrixParam = new DiagonalMatrix(new Parameter.Default(new double[] { 0.5, 50.0 }));
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("likelihoodDiagonalOUFactor", dataModelFactor, dataLikelihoodFactors);
// Conditional simulations
MathUtils.setSeed(17890826);
double[] expectedTraits = new double[] { 1.3270345780274333, -1.5589839744569975, 1.241407854756886, -1.4525648723106128, 1.388017192005544, -1.533399261149814, 1.8040948421311085, -1.4189758121385794, 1.1408165195832969, -1.4607180451268982, 1.6048925583434688, -1.4333922414628846 };
testConditionalSimulations(dataLikelihoodFactors, likelihoodDelegateFactors, diffusionModelFactor, dataModelFactor, rootPriorFactor, expectedTraits);
}
use of dr.evomodel.treedatalikelihood.TreeDataLikelihood in project beast-mcmc by beast-dev.
the class ContinuousDataLikelihoodDelegateTest method testLikelihoodFullOURelaxed.
public void testLikelihoodFullOURelaxed() {
System.out.println("\nTest Likelihood using Full OU Relaxed:");
// 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 ArbitraryBranchRates(treeModel, new Parameter.Default("rate.2", new double[] { 0, -1, 2, -3, 4, -5, 6, -7, 8, -9 }), transform, false));
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, 10.5, 0.1 });
strengthOfSelectionParameters[2] = new Parameter.Default(new double[] { 0.0, 0.1, 100.0 });
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("likelihoodFullOURelaxed", dataLikelihood);
// Conditional moments (preorder)
testConditionalMoments(dataLikelihood, likelihoodDelegate);
// Conditional simulations
MathUtils.setSeed(17890826);
double[] expectedTraits = new double[] { -1.0, 2.0, 0.0, 1.6349449153945943, 2.8676718538313635, -1.0653412418514505, 0.5, 3.3661883786009166, 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("likelihoodFullOURelaxedInf", dataLikelihoodInf);
testConditionalMoments(dataLikelihoodInf, likelihoodDelegateInf);
}
Aggregations