Search in sources :

Example 1 with BayesianBridgeStatisticsProvider

use of dr.inference.distribution.shrinkage.BayesianBridgeStatisticsProvider 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 BayesianBridgeStatisticsProvider

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

the class BayesianBridgeShrinkageOperatorParser method parseXMLObject.

@Override
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    double weight = xo.getDoubleAttribute(WEIGHT);
    BayesianBridgeStatisticsProvider bayesianBridge = (BayesianBridgeStatisticsProvider) xo.getChild(BayesianBridgeStatisticsProvider.class);
    if (bayesianBridge == null) {
        bayesianBridge = parseAutoCorrelatedRates(xo);
    }
    DistributionLikelihood prior = (DistributionLikelihood) xo.getChild(DistributionLikelihood.class);
    if (!(prior.getDistribution() instanceof GammaDistribution)) {
        throw new XMLParseException("Gibbs sampler only implemented for a gamma distributed global scale");
    }
    GammaDistribution globalScalePrior = (GammaDistribution) prior.getDistribution();
    return new BayesianBridgeShrinkageOperator(bayesianBridge, globalScalePrior, weight);
}
Also used : BayesianBridgeStatisticsProvider(dr.inference.distribution.shrinkage.BayesianBridgeStatisticsProvider) BayesianBridgeShrinkageOperator(dr.inference.operators.shrinkage.BayesianBridgeShrinkageOperator) DistributionLikelihood(dr.inference.distribution.DistributionLikelihood) GammaDistribution(dr.math.distributions.GammaDistribution)

Aggregations

BayesianBridgeStatisticsProvider (dr.inference.distribution.shrinkage.BayesianBridgeStatisticsProvider)2 AutoCorrelatedBranchRatesDistribution (dr.evomodel.branchratemodel.AutoCorrelatedBranchRatesDistribution)1 DistributionLikelihood (dr.inference.distribution.DistributionLikelihood)1 BayesianBridgeDistributionModel (dr.inference.distribution.shrinkage.BayesianBridgeDistributionModel)1 BayesianBridgeShrinkageOperator (dr.inference.operators.shrinkage.BayesianBridgeShrinkageOperator)1 GammaDistribution (dr.math.distributions.GammaDistribution)1