Search in sources :

Example 1 with GeneralizedLinearModel

use of dr.inference.glm.GeneralizedLinearModel in project beast-mcmc by beast-dev.

the class GLMSubstitutionModelParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    DataType dataType = DataTypeUtils.getDataType(xo);
    if (dataType == null)
        dataType = (DataType) xo.getChild(DataType.class);
    int rateCount = (dataType.getStateCount() - 1) * dataType.getStateCount();
    // Should be constructed as a log-linear model
    GeneralizedLinearModel glm = (GeneralizedLinearModel) xo.getChild(GeneralizedLinearModel.class);
    // LogLinearModel glm = (LogLinearModel) xo.getChild(GeneralizedLinearModel.class);
    int length = glm.getXBeta().length;
    if (length != rateCount) {
        throw new XMLParseException("Rates parameter in " + getParserName() + " element should have " + (rateCount) + " dimensions.  However GLM dimension is " + length);
    }
    XMLObject cxo = xo.getChild(ComplexSubstitutionModelParser.ROOT_FREQUENCIES);
    FrequencyModel rootFreq = (FrequencyModel) cxo.getChild(FrequencyModel.class);
    if (dataType != rootFreq.getDataType()) {
        throw new XMLParseException("Data type of " + getParserName() + " element does not match that of its rootFrequencyModel.");
    }
    return new GLMSubstitutionModel(xo.getId(), dataType, rootFreq, glm);
}
Also used : FrequencyModel(dr.evomodel.substmodel.FrequencyModel) GeneralizedLinearModel(dr.inference.glm.GeneralizedLinearModel) DataType(dr.evolution.datatype.DataType) GLMSubstitutionModel(dr.evomodel.substmodel.GLMSubstitutionModel)

Aggregations

DataType (dr.evolution.datatype.DataType)1 FrequencyModel (dr.evomodel.substmodel.FrequencyModel)1 GLMSubstitutionModel (dr.evomodel.substmodel.GLMSubstitutionModel)1 GeneralizedLinearModel (dr.inference.glm.GeneralizedLinearModel)1