Search in sources :

Example 1 with AutoCorrelatedBranchRatesDistribution

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

the class BayesianBridgeShrinkageOperatorParser method parseAutoCorrelatedRates.

private BayesianBridgeStatisticsProvider parseAutoCorrelatedRates(XMLObject xo) throws XMLParseException {
    final AutoCorrelatedBranchRatesDistribution rates = (AutoCorrelatedBranchRatesDistribution) xo.getChild(AutoCorrelatedBranchRatesDistribution.class);
    if (!(rates.getPrior() instanceof BayesianBridgeDistributionModel)) {
        throw new XMLParseException("Gibbs sampler only implemented for a Bayesian Bridge prior");
    }
    final BayesianBridgeDistributionModel prior = (BayesianBridgeDistributionModel) rates.getPrior();
    return new BayesianBridgeStatisticsProvider() {

        @Override
        public double getCoefficient(int i) {
            return rates.getIncrement(i);
        }

        @Override
        public Parameter getGlobalScale() {
            return prior.getGlobalScale();
        }

        @Override
        public Parameter getLocalScale() {
            return prior.getLocalScale();
        }

        @Override
        public Parameter getExponent() {
            return prior.getExponent();
        }

        @Override
        public int getDimension() {
            return rates.getDimension();
        }
    };
}
Also used : BayesianBridgeStatisticsProvider(dr.inference.distribution.shrinkage.BayesianBridgeStatisticsProvider) AutoCorrelatedBranchRatesDistribution(dr.evomodel.branchratemodel.AutoCorrelatedBranchRatesDistribution) BayesianBridgeDistributionModel(dr.inference.distribution.shrinkage.BayesianBridgeDistributionModel)

Example 2 with AutoCorrelatedBranchRatesDistribution

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

the class AutoCorrelatedBranchRatesDistributionParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    ArbitraryBranchRates branchRates = (ArbitraryBranchRates) xo.getChild(ArbitraryBranchRates.class);
    ParametricMultivariateDistributionModel distribution = (ParametricMultivariateDistributionModel) xo.getChild(ParametricMultivariateDistributionModel.class);
    AutoCorrelatedBranchRatesDistribution.BranchVarianceScaling scaling = parseScaling(xo);
    boolean log = xo.getAttribute(LOG, false);
    return new AutoCorrelatedBranchRatesDistribution(xo.getId(), branchRates, distribution, scaling, log);
}
Also used : ArbitraryBranchRates(dr.evomodel.branchratemodel.ArbitraryBranchRates) AutoCorrelatedBranchRatesDistribution(dr.evomodel.branchratemodel.AutoCorrelatedBranchRatesDistribution) ParametricMultivariateDistributionModel(dr.inference.distribution.ParametricMultivariateDistributionModel)

Example 3 with AutoCorrelatedBranchRatesDistribution

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

the class AutoCorrelatedRatesBayesianBridgeParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    AutoCorrelatedBranchRatesDistribution ratesDistribution = (AutoCorrelatedBranchRatesDistribution) xo.getChild(AutoCorrelatedBranchRatesDistribution.class);
    XMLObject globalXo = xo.getChild(GLOBAL_SCALE);
    Parameter globalScale = (Parameter) globalXo.getChild(Parameter.class);
    Parameter localScale = null;
    if (xo.hasChildNamed(LOCAL_SCALE)) {
        XMLObject localXo = xo.getChild(LOCAL_SCALE);
        localScale = (Parameter) localXo.getChild(Parameter.class);
        if (localScale.getDimension() != ratesDistribution.getDimension()) {
            throw new XMLParseException("Local scale dimension (" + localScale.getDimension() + ") != rates dimension (" + ratesDistribution.getDimension() + ")");
        }
    }
    XMLObject exponentXo = xo.getChild(EXPONENT);
    Parameter exponent = (Parameter) exponentXo.getChild(Parameter.class);
    Parameter slabWidth = ParameterParser.getOptionalParameter(xo, SLAB_WIDTH);
    BayesianBridgeDistributionModel distributionModel = (localScale != null) ? new JointBayesianBridgeDistributionModel(globalScale, localScale, exponent, slabWidth, 1) : new MarginalBayesianBridgeDistributionModel(globalScale, exponent, 1);
    return new AutoCorrelatedRatesWithBayesianBridge(ratesDistribution, distributionModel);
}
Also used : AutoCorrelatedBranchRatesDistribution(dr.evomodel.branchratemodel.AutoCorrelatedBranchRatesDistribution) Parameter(dr.inference.model.Parameter) MatrixParameter(dr.inference.model.MatrixParameter) AutoCorrelatedRatesWithBayesianBridge(dr.evomodel.branchratemodel.shrinkage.AutoCorrelatedRatesWithBayesianBridge)

Aggregations

AutoCorrelatedBranchRatesDistribution (dr.evomodel.branchratemodel.AutoCorrelatedBranchRatesDistribution)3 ArbitraryBranchRates (dr.evomodel.branchratemodel.ArbitraryBranchRates)1 AutoCorrelatedRatesWithBayesianBridge (dr.evomodel.branchratemodel.shrinkage.AutoCorrelatedRatesWithBayesianBridge)1 ParametricMultivariateDistributionModel (dr.inference.distribution.ParametricMultivariateDistributionModel)1 BayesianBridgeDistributionModel (dr.inference.distribution.shrinkage.BayesianBridgeDistributionModel)1 BayesianBridgeStatisticsProvider (dr.inference.distribution.shrinkage.BayesianBridgeStatisticsProvider)1 MatrixParameter (dr.inference.model.MatrixParameter)1 Parameter (dr.inference.model.Parameter)1