use of dr.inference.distribution.HierarchicalGraphLikelihood in project beast-mcmc by beast-dev.
the class HierarchicalGraphLikelihoodParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
XMLObject cxo = xo.getChild(HIERARCHICAL_INDICATOR);
Parameter hierarchicalIndicator = (Parameter) cxo.getChild(Parameter.class);
cxo = xo.getChild(STRATA_INDICATOR);
MatrixParameter strataIndicatorMatrix = new MatrixParameter("matrix");
int dim = 0;
for (int i = 0; i < cxo.getChildCount(); i++) {
Parameter parameter = (Parameter) cxo.getChild(i);
strataIndicatorMatrix.addParameter(parameter);
if (i == 0)
dim = parameter.getDimension();
else if (dim != parameter.getDimension())
throw new XMLParseException("All parameters must have the same dimension to construct a rectangular matrix");
}
if (hierarchicalIndicator.getDimension() != strataIndicatorMatrix.getRowDimension())
throw new XMLParseException("Hierarchical and starta parameters don't have the same dimentions");
cxo = xo.getChild(PROB);
Parameter prob = (Parameter) cxo.getChild(Parameter.class);
return new HierarchicalGraphLikelihood(hierarchicalIndicator, strataIndicatorMatrix, prob);
}
Aggregations