| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
package dr.evomodel.continuous; |
| 27 |
|
| 28 |
import dr.inference.model.MatrixParameterInterface; |
| 29 |
import dr.inference.model.Parameter; |
| 30 |
import dr.math.distributions.TDistribution; |
| 31 |
import dr.xml.*; |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
public class MultivariateTDiffusionModel extends MultivariateDiffusionModel { |
| 37 |
|
| 38 |
public static final String DIFFUSION_PROCESS = "multivariateTDiffusionModel"; |
| 39 |
public static final String DIFFUSION_CONSTANT = "precisionParameter"; |
| 40 |
|
| 41 |
|
| 42 |
public static final String DF = "dfParameter"; |
| 43 |
|
| 44 |
public MultivariateTDiffusionModel(Parameter df, MatrixParameterInterface precision) { |
| 45 |
super(); |
| 46 |
this.dfParameter = df; |
| 47 |
this.precisionParameter = precision; |
| 48 |
addVariable(dfParameter); |
| 49 |
addVariable(precisionParameter); |
| 50 |
|
| 51 |
} |
| 52 |
|
| 53 |
public double getLogLikelihood(double[] start, double[] stop, double time) { |
| 54 |
|
| 55 |
double df = dfParameter.getParameterValue(0); |
| 56 |
|
| 57 |
|
| 58 |
double scale0 = precisionParameter.getParameterValue(0); |
| 59 |
double scale1 = precisionParameter.getParameterValue(1); |
| 60 |
|
| 61 |
return TDistribution.logPDF(stop[0], start[0], time / scale0, df) + |
| 62 |
TDistribution.logPDF(stop[1], start[1], time / scale1, df); |
| 63 |
} |
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
public MatrixParameterInterface getPrecisionParameter() { |
| 83 |
return precisionParameter; |
| 84 |
} |
| 85 |
|
| 86 |
protected void calculatePrecisionInfo() { |
| 87 |
|
| 88 |
} |
| 89 |
|
| 90 |
public static XMLObjectParser PARSER = new AbstractXMLObjectParser() { |
| 91 |
|
| 92 |
public String getParserName() { |
| 93 |
return DIFFUSION_PROCESS; |
| 94 |
} |
| 95 |
|
| 96 |
public Object parseXMLObject(XMLObject xo) throws XMLParseException { |
| 97 |
|
| 98 |
XMLObject cxo = xo.getChild(DIFFUSION_CONSTANT); |
| 99 |
MatrixParameterInterface diffusionParam = (MatrixParameterInterface) cxo.getChild(MatrixParameterInterface.class); |
| 100 |
cxo = xo.getChild(DF); |
| 101 |
Parameter df = (Parameter) cxo.getChild(Parameter.class); |
| 102 |
|
| 103 |
return new MultivariateTDiffusionModel(df, diffusionParam); |
| 104 |
} |
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
public String getParserDescription() { |
| 111 |
return "Describes a multivariate t-distribution diffusion process."; |
| 112 |
} |
| 113 |
|
| 114 |
public XMLSyntaxRule[] getSyntaxRules() { |
| 115 |
return rules; |
| 116 |
} |
| 117 |
|
| 118 |
private final XMLSyntaxRule[] rules = { |
| 119 |
new ElementRule(DIFFUSION_CONSTANT, |
| 120 |
new XMLSyntaxRule[]{new ElementRule(Parameter.class)}), |
| 121 |
new ElementRule(DF, |
| 122 |
new XMLSyntaxRule[]{new ElementRule(Parameter.class)}) |
| 123 |
}; |
| 124 |
|
| 125 |
public Class getReturnType() { |
| 126 |
return MultivariateTDiffusionModel.class; |
| 127 |
} |
| 128 |
}; |
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
private final Parameter dfParameter; |
| 135 |
private final MatrixParameterInterface precisionParameter; |
| 136 |
|
| 137 |
} |