Search in sources :

Example 1 with RandomLocalYuleModel

use of dr.evomodel.speciation.RandomLocalYuleModel in project beast-mcmc by beast-dev.

the class RLYModelTest method randomLocalYuleTester.

private void randomLocalYuleTester(TreeModel treeModel, Parameter I, Parameter b, OperatorSchedule schedule) {
    MCMC mcmc = new MCMC("mcmc1");
    MCMCOptions options = new MCMCOptions(1000000);
    TreeLengthStatistic tls = new TreeLengthStatistic(TL, treeModel);
    TreeHeightStatistic rootHeight = new TreeHeightStatistic(TREE_HEIGHT, treeModel);
    Parameter m = new Parameter.Default("m", 1.0, 0.0, Double.MAX_VALUE);
    SpeciationModel speciationModel = new RandomLocalYuleModel(b, I, m, false, Units.Type.YEARS, 4);
    Likelihood likelihood = new SpeciationLikelihood(treeModel, speciationModel, "randomYule.like");
    ArrayLogFormatter formatter = new ArrayLogFormatter(false);
    MCLogger[] loggers = new MCLogger[2];
    loggers[0] = new MCLogger(formatter, 100, false);
    loggers[0].add(likelihood);
    loggers[0].add(rootHeight);
    loggers[0].add(tls);
    loggers[0].add(I);
    loggers[1] = new MCLogger(new TabDelimitedFormatter(System.out), 100000, false);
    loggers[1].add(likelihood);
    loggers[1].add(rootHeight);
    loggers[1].add(tls);
    loggers[1].add(I);
    mcmc.setShowOperatorAnalysis(true);
    mcmc.init(options, likelihood, schedule, loggers);
    mcmc.run();
    List<Trace> traces = formatter.getTraces();
    ArrayTraceList traceList = new ArrayTraceList("yuleModelTest", traces, 0);
    for (int i = 1; i < traces.size(); i++) {
        traceList.analyseTrace(i);
    }
    TraceCorrelation tlStats = traceList.getCorrelationStatistics(traceList.getTraceIndex("root." + birthRateIndicator));
    System.out.println("mean = " + tlStats.getMean());
    System.out.println("expected mean = 0.5");
    assertExpectation("root." + birthRateIndicator, tlStats, 0.5);
}
Also used : TraceCorrelation(dr.inference.trace.TraceCorrelation) Likelihood(dr.inference.model.Likelihood) SpeciationLikelihood(dr.evomodel.speciation.SpeciationLikelihood) MCMC(dr.inference.mcmc.MCMC) SpeciationModel(dr.evomodel.speciation.SpeciationModel) TabDelimitedFormatter(dr.inference.loggers.TabDelimitedFormatter) SpeciationLikelihood(dr.evomodel.speciation.SpeciationLikelihood) Trace(dr.inference.trace.Trace) RandomLocalYuleModel(dr.evomodel.speciation.RandomLocalYuleModel) ArrayTraceList(dr.inference.trace.ArrayTraceList) MCMCOptions(dr.inference.mcmc.MCMCOptions) TreeLengthStatistic(dr.evomodel.tree.TreeLengthStatistic) TreeHeightStatistic(dr.evomodel.tree.TreeHeightStatistic) Parameter(dr.inference.model.Parameter) ArrayLogFormatter(dr.inference.loggers.ArrayLogFormatter) MCLogger(dr.inference.loggers.MCLogger)

Example 2 with RandomLocalYuleModel

use of dr.evomodel.speciation.RandomLocalYuleModel in project beast-mcmc by beast-dev.

the class RandomLocalYuleModelParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    Units.Type units = XMLUnits.Utils.getUnitsAttr(xo);
    XMLObject cxo = xo.getChild(BIRTH_RATE);
    Parameter brParameter = (Parameter) cxo.getChild(Parameter.class);
    cxo = xo.getChild(BIRTH_RATE_INDICATORS);
    Parameter indicatorsParameter = (Parameter) cxo.getChild(Parameter.class);
    Parameter meanRate = (Parameter) xo.getElementFirstChild(MEAN_RATE);
    boolean ratesAsMultipliers = xo.getBooleanAttribute(RATES_AS_MULTIPLIERS);
    int dp = xo.getAttribute("dp", 4);
    return new RandomLocalYuleModel(brParameter, indicatorsParameter, meanRate, ratesAsMultipliers, units, dp);
}
Also used : RandomLocalYuleModel(dr.evomodel.speciation.RandomLocalYuleModel) Parameter(dr.inference.model.Parameter) Units(dr.evolution.util.Units) XMLUnits(dr.evoxml.util.XMLUnits)

Aggregations

RandomLocalYuleModel (dr.evomodel.speciation.RandomLocalYuleModel)2 Parameter (dr.inference.model.Parameter)2 Units (dr.evolution.util.Units)1 SpeciationLikelihood (dr.evomodel.speciation.SpeciationLikelihood)1 SpeciationModel (dr.evomodel.speciation.SpeciationModel)1 TreeHeightStatistic (dr.evomodel.tree.TreeHeightStatistic)1 TreeLengthStatistic (dr.evomodel.tree.TreeLengthStatistic)1 XMLUnits (dr.evoxml.util.XMLUnits)1 ArrayLogFormatter (dr.inference.loggers.ArrayLogFormatter)1 MCLogger (dr.inference.loggers.MCLogger)1 TabDelimitedFormatter (dr.inference.loggers.TabDelimitedFormatter)1 MCMC (dr.inference.mcmc.MCMC)1 MCMCOptions (dr.inference.mcmc.MCMCOptions)1 Likelihood (dr.inference.model.Likelihood)1 ArrayTraceList (dr.inference.trace.ArrayTraceList)1 Trace (dr.inference.trace.Trace)1 TraceCorrelation (dr.inference.trace.TraceCorrelation)1