Search in sources :

Example 11 with ParametricDistributionModel

use of dr.inference.distribution.ParametricDistributionModel in project beast-mcmc by beast-dev.

the class MixedDistributionLikelihoodParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    XMLObject cxo0 = xo.getChild(DISTRIBUTION0);
    ParametricDistributionModel model0 = (ParametricDistributionModel) cxo0.getChild(ParametricDistributionModel.class);
    XMLObject cxo1 = xo.getChild(DISTRIBUTION1);
    ParametricDistributionModel model1 = (ParametricDistributionModel) cxo1.getChild(ParametricDistributionModel.class);
    Statistic data = (Statistic) ((XMLObject) xo.getChild(DATA)).getChild(Statistic.class);
    Statistic indicators = (Statistic) ((XMLObject) xo.getChild(INDICATORS)).getChild(Statistic.class);
    ParametricDistributionModel[] models = { model0, model1 };
    try {
        return new MixedDistributionLikelihood(models, data, indicators);
    } catch (Exception e) {
        throw new XMLParseException(e.getMessage());
    }
}
Also used : Statistic(dr.inference.model.Statistic) ParametricDistributionModel(dr.inference.distribution.ParametricDistributionModel) MixedDistributionLikelihood(dr.inference.distribution.MixedDistributionLikelihood)

Example 12 with ParametricDistributionModel

use of dr.inference.distribution.ParametricDistributionModel in project beast-mcmc by beast-dev.

the class PartitionData method createClockRateModel.

public BranchRateModel createClockRateModel() {
    BranchRateModel branchRateModel = null;
    if (this.clockModelIndex == 0) {
        // Strict Clock
        Parameter rateParameter = new Parameter.Default(1, clockParameterValues[0]);
        branchRateModel = new StrictClockBranchRates(rateParameter);
    } else if (this.clockModelIndex == LRC_INDEX) {
        // Lognormal relaxed clock
        double numberOfBranches = 2 * (createTreeModel().getTaxonCount() - 1);
        Parameter rateCategoryParameter = new Parameter.Default(numberOfBranches);
        Parameter mean = new Parameter.Default(LogNormalDistributionModelParser.MEAN, 1, clockParameterValues[1]);
        Parameter stdev = new Parameter.Default(LogNormalDistributionModelParser.STDEV, 1, clockParameterValues[2]);
        //TODO: choose between log scale / real scale
        ParametricDistributionModel distributionModel = new LogNormalDistributionModel(mean, stdev, clockParameterValues[3], lrcParametersInRealSpace, lrcParametersInRealSpace);
        branchRateModel = new //
        DiscretizedBranchRates(//
        createTreeModel(), //
        rateCategoryParameter, //
        distributionModel, // 
        1, // 
        false, //
        Double.NaN, //randomizeRates
        true, // keepRates
        false, // cacheRates
        false);
    } else if (this.clockModelIndex == 2) {
        // Exponential relaxed clock
        double numberOfBranches = 2 * (createTreeModel().getTaxonCount() - 1);
        Parameter rateCategoryParameter = new Parameter.Default(numberOfBranches);
        Parameter mean = new Parameter.Default(DistributionModelParser.MEAN, 1, clockParameterValues[4]);
        ParametricDistributionModel distributionModel = new ExponentialDistributionModel(mean, clockParameterValues[5]);
        //	        branchRateModel = new DiscretizedBranchRates(createTreeModel(), rateCategoryParameter, 
        //	                distributionModel, 1, false, Double.NaN);
        branchRateModel = new //
        DiscretizedBranchRates(//
        createTreeModel(), //
        rateCategoryParameter, //
        distributionModel, // 
        1, // 
        false, //
        Double.NaN, //randomizeRates
        true, // keepRates
        false, // cacheRates
        false);
    } else if (this.clockModelIndex == 3) {
        // Inverse Gaussian
        double numberOfBranches = 2 * (createTreeModel().getTaxonCount() - 1);
        Parameter rateCategoryParameter = new Parameter.Default(numberOfBranches);
        Parameter mean = new Parameter.Default(InverseGaussianDistributionModelParser.MEAN, 1, clockParameterValues[6]);
        Parameter stdev = new Parameter.Default(InverseGaussianDistributionModelParser.STDEV, 1, clockParameterValues[7]);
        ParametricDistributionModel distributionModel = new InverseGaussianDistributionModel(mean, stdev, clockParameterValues[8], false);
        branchRateModel = new //
        DiscretizedBranchRates(//
        createTreeModel(), //
        rateCategoryParameter, //
        distributionModel, // 
        1, // 
        false, //
        Double.NaN, //randomizeRates
        true, // keepRates
        false, // cacheRates
        false);
    } else {
        System.out.println("Not yet implemented");
    }
    return branchRateModel;
}
Also used : DiscretizedBranchRates(dr.evomodel.branchratemodel.DiscretizedBranchRates) InverseGaussianDistributionModel(dr.inference.distribution.InverseGaussianDistributionModel) BranchRateModel(dr.evomodel.branchratemodel.BranchRateModel) LogNormalDistributionModel(dr.inference.distribution.LogNormalDistributionModel) ParametricDistributionModel(dr.inference.distribution.ParametricDistributionModel) ExponentialDistributionModel(dr.inference.distribution.ExponentialDistributionModel) Parameter(dr.inference.model.Parameter) StrictClockBranchRates(dr.evomodel.branchratemodel.StrictClockBranchRates)

Example 13 with ParametricDistributionModel

use of dr.inference.distribution.ParametricDistributionModel in project beast-mcmc by beast-dev.

the class AlloppNetworkPriorModelParser method parseXMLObject.

@Override
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    final Units.Type units = XMLUnits.Utils.getUnitsAttr(xo);
    final XMLObject erXo = xo.getChild(EVENTRATE);
    final Parameter eventrate = (Parameter) erXo.getChild(Parameter.class);
    final XMLObject psfXo = xo.getChild(POPULATION_SCALING_FACTOR);
    final Parameter popscalingfactor = (Parameter) psfXo.getChild(Parameter.class);
    final XMLObject tpdXo = xo.getChild(TIP_POPULATION_DISTRIBUTION);
    ParametricDistributionModel tippopmodel = (ParametricDistributionModel) tpdXo.getChild(ParametricDistributionModel.class);
    final XMLObject rpdXo = xo.getChild(ROOT_POPULATION_DISTRIBUTION);
    ParametricDistributionModel rootpopmodel = (ParametricDistributionModel) rpdXo.getChild(ParametricDistributionModel.class);
    final XMLObject hpdXo = xo.getChild(HYBRID_POPULATION_DISTRIBUTION);
    ParametricDistributionModel hybpopmodel = (ParametricDistributionModel) hpdXo.getChild(ParametricDistributionModel.class);
    return new AlloppNetworkPriorModel(eventrate, popscalingfactor, tippopmodel, rootpopmodel, hybpopmodel, units);
}
Also used : AlloppNetworkPriorModel(dr.evomodel.alloppnet.speciation.AlloppNetworkPriorModel) ParametricDistributionModel(dr.inference.distribution.ParametricDistributionModel) XMLObject(dr.xml.XMLObject) Parameter(dr.inference.model.Parameter) Units(dr.evolution.util.Units) XMLUnits(dr.evoxml.util.XMLUnits)

Example 14 with ParametricDistributionModel

use of dr.inference.distribution.ParametricDistributionModel in project beast-mcmc by beast-dev.

the class AlloppNetworkPrior method calculateLogLikelihood.

@Override
protected double calculateLogLikelihood() {
    double llhood = 0.0;
    //network topology and times prior
    llhood += loglikelihoodEvents();
    //System.out.print(llhood); System.out.print(" ");
    llhood += loglikeNumHybridizations();
    //System.out.print(llhood); System.out.print(" ");
    // population prior for tips
    Parameter tippvals = asnm.getTipPopValues();
    ParametricDistributionModel tipmodel = prior.getTipPopModel();
    for (int i = 0; i < tippvals.getDimension(); i++) {
        llhood += tipmodel.logPdf(tippvals.getParameterValue(i));
    }
    // population prior for root ends
    Parameter rootpvals = asnm.getRootPopValues();
    ParametricDistributionModel rootmodel = prior.getRootPopModel();
    for (int i = 0; i < rootpvals.getDimension(); i++) {
        llhood += rootmodel.logPdf(rootpvals.getParameterValue(i));
    }
    // population prior for new hybrids
    ParametricDistributionModel hybmodel = prior.getHybridPopModel();
    for (int i = 0; i < asnm.getNumberOfTetraTrees(); i++) {
        llhood += hybmodel.logPdf(asnm.getOneHybPopValue(i));
    }
    //System.out.println(llhood);
    return llhood;
}
Also used : ParametricDistributionModel(dr.inference.distribution.ParametricDistributionModel) Parameter(dr.inference.model.Parameter)

Example 15 with ParametricDistributionModel

use of dr.inference.distribution.ParametricDistributionModel in project beast-mcmc by beast-dev.

the class ContinuousBranchRatesParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    final boolean normalize = xo.getAttribute(NORMALIZE, false);
    final double normalizeBranchRateTo = xo.getAttribute(NORMALIZE_BRANCH_RATE_TO, Double.NaN);
    TreeModel tree = (TreeModel) xo.getChild(TreeModel.class);
    ParametricDistributionModel distributionModel = (ParametricDistributionModel) xo.getElementFirstChild(DISTRIBUTION);
    Parameter rateQuantilesParameter;
    if (xo.hasChildNamed(RATE_QUANTILES)) {
        rateQuantilesParameter = (Parameter) xo.getElementFirstChild(RATE_QUANTILES);
    } else {
        rateQuantilesParameter = (Parameter) xo.getElementFirstChild(RATE_CATEGORY_QUANTILES);
    }
    Logger.getLogger("dr.evomodel").info("Using continuous relaxed clock model.");
    Logger.getLogger("dr.evomodel").info("  parametric model = " + distributionModel.getModelName());
    Logger.getLogger("dr.evomodel").info("   rate categories = " + rateQuantilesParameter.getDimension());
    if (normalize) {
        Logger.getLogger("dr.evomodel").info("   mean rate is normalized to " + normalizeBranchRateTo);
    }
    if (xo.hasAttribute(SINGLE_ROOT_RATE)) {
        Logger.getLogger("dr.evomodel").warning("   WARNING: single root rate is not implemented!");
    }
    return new ContinuousBranchRates(tree, rateQuantilesParameter, distributionModel, normalize, normalizeBranchRateTo);
}
Also used : TreeModel(dr.evomodel.tree.TreeModel) ParametricDistributionModel(dr.inference.distribution.ParametricDistributionModel) Parameter(dr.inference.model.Parameter) ContinuousBranchRates(dr.evomodel.branchratemodel.ContinuousBranchRates)

Aggregations

ParametricDistributionModel (dr.inference.distribution.ParametricDistributionModel)21 Parameter (dr.inference.model.Parameter)16 ArrayList (java.util.ArrayList)4 TreeModel (dr.evomodel.tree.TreeModel)3 DistributionLikelihood (dr.inference.distribution.DistributionLikelihood)3 DiscretizedBranchRates (dr.evomodel.branchratemodel.DiscretizedBranchRates)2 VariableDemographicModel (dr.evomodel.coalescent.VariableDemographicModel)2 SpeciesTreeModel (dr.evomodel.speciation.SpeciesTreeModel)2 NormalDistributionModel (dr.inference.distribution.NormalDistributionModel)2 CompoundParameter (dr.inference.model.CompoundParameter)2 Statistic (dr.inference.model.Statistic)2 Attribute (dr.util.Attribute)2 SimpleTree (dr.evolution.tree.SimpleTree)1 Tree (dr.evolution.tree.Tree)1 Taxa (dr.evolution.util.Taxa)1 Taxon (dr.evolution.util.Taxon)1 TaxonList (dr.evolution.util.TaxonList)1 Units (dr.evolution.util.Units)1 AlloppNetworkPriorModel (dr.evomodel.alloppnet.speciation.AlloppNetworkPriorModel)1 BranchRateModel (dr.evomodel.branchratemodel.BranchRateModel)1