Search in sources :

Example 11 with DemographicFunction

use of dr.evolution.coalescent.DemographicFunction in project beast-mcmc by beast-dev.

the class TransmissionLikelihood method calculateLogLikelihood.

/**
     * Calculates the log likelihood of this set of coalescent intervals,
     * given a demographic model.
     */
public double calculateLogLikelihood() {
    makeDirty();
    setupHosts();
    for (int i = 0; i < hostCount; i++) {
        intervals[i].resetEvents();
        donorSize[i] = -1;
    }
    try {
        setupIntervals(virusTree.getRoot());
    } catch (IncompatibleException re) {
        // register the compatibility failure
        return Double.NEGATIVE_INFINITY;
    }
    for (int i = 0; i < hostCount; i++) {
        donorSize[i] = -1;
    }
    DemographicFunction demoFunction = sourceDemographic.getDemographicFunction();
    double logL = Coalescent.calculateLogLikelihood(intervals[0], demoFunction);
    for (int i = 1; i < hostCount; i++) {
        double ds = getDonorSize(i);
        demoFunction = transmissionModel.getDemographicFunction(transmissionTime[i], ds, i);
        logL += Coalescent.calculateLogLikelihood(intervals[i], demoFunction);
    }
    return logL;
}
Also used : DemographicFunction(dr.evolution.coalescent.DemographicFunction)

Example 12 with DemographicFunction

use of dr.evolution.coalescent.DemographicFunction in project beast-mcmc by beast-dev.

the class TransmissionLikelihood method getDonorSize.

private double getDonorSize(int host) {
    if (donorSize[host] > 0.0) {
        return donorSize[host];
    }
    DemographicFunction demoFunction;
    if (donorHost[host] == 0) {
        demoFunction = sourceDemographic.getDemographicFunction();
    } else {
        double ds = getDonorSize(donorHost[host]);
        demoFunction = transmissionModel.getDemographicFunction(transmissionTime[host], ds, host);
    }
    donorSize[host] = demoFunction.getDemographic(transmissionTime[host]);
    return donorSize[host];
}
Also used : DemographicFunction(dr.evolution.coalescent.DemographicFunction)

Aggregations

DemographicFunction (dr.evolution.coalescent.DemographicFunction)12 ScaledDemographic (dr.evolution.coalescent.ScaledDemographic)3 NodeRef (dr.evolution.tree.NodeRef)3 ConstantPopulation (dr.evolution.coalescent.ConstantPopulation)2 ExponentialGrowth (dr.evolution.coalescent.ExponentialGrowth)2 Tree (dr.evolution.tree.Tree)2 FixedBitSet (jebl.util.FixedBitSet)2 Arguments (dr.app.util.Arguments)1 SimpleNode (dr.evolution.tree.SimpleNode)1 SimpleTree (dr.evolution.tree.SimpleTree)1 LogisticGrowthN0 (dr.evomodel.epidemiology.LogisticGrowthN0)1