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();
}
};
}
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);
}
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);
}
Aggregations