use of dr.inference.operators.factorAnalysis.LatentFactorModelPrecisionGibbsOperator in project beast-mcmc by beast-dev.
the class FactorRJMCMCOperatorParser method parseXMLObject.
@Override
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
// attributes
double weight = xo.getDoubleAttribute(WEIGHT);
int chainLength = xo.getIntegerAttribute(CHAIN_LENGTH);
double sizeParameter = xo.getDoubleAttribute(SIZE_PARAMETER);
// declaration
AdaptableSizeFastMatrixParameter factors, loadings, cutoffs, loadingsSparcity;
// parameters
if (xo.hasChildNamed(FACTORS))
factors = (AdaptableSizeFastMatrixParameter) xo.getChild(FACTORS).getChild(AdaptableSizeFastMatrixParameter.class);
else
factors = null;
loadings = (AdaptableSizeFastMatrixParameter) xo.getChild(LOADINGS).getChild(AdaptableSizeFastMatrixParameter.class);
if (xo.hasChildNamed(CUTOFFS)) {
cutoffs = (AdaptableSizeFastMatrixParameter) xo.getChild(CUTOFFS).getChild(AdaptableSizeFastMatrixParameter.class);
} else
cutoffs = null;
if (xo.hasChildNamed(LOADINGS_SPARSITY))
loadingsSparcity = (AdaptableSizeFastMatrixParameter) xo.getChild(LOADINGS_SPARSITY).getChild(AdaptableSizeFastMatrixParameter.class);
else
loadingsSparcity = null;
// models
DeterminentalPointProcessPrior DPP = null;
if (xo.getChild(SPARSITY_PRIOR) != null)
DPP = (DeterminentalPointProcessPrior) xo.getChild(SPARSITY_PRIOR).getChild(DeterminentalPointProcessPrior.class);
SimpleMCMCOperator NOp = null;
if (xo.getChild(NEGATION_OPERATOR) != null) {
NOp = (SimpleMCMCOperator) xo.getChild(NEGATION_OPERATOR).getChild(SimpleMCMCOperator.class);
}
AbstractModelLikelihood LFM = (AbstractModelLikelihood) xo.getChild(AbstractModelLikelihood.class);
RowDimensionPoissonPrior rowPrior = (RowDimensionPoissonPrior) xo.getChild(ROW_PRIOR).getChild(RowDimensionPoissonPrior.class);
Likelihood loadingsPrior = null;
if (xo.hasChildNamed(LOADINGS_PRIOR)) {
loadingsPrior = (Likelihood) xo.getChild(LOADINGS_PRIOR).getChild(Likelihood.class);
}
// operators
SimpleMCMCOperator sparsityOperator = null;
if (xo.getChild(BitFlipOperator.class) != null)
sparsityOperator = (BitFlipOperator) xo.getChild(BitFlipOperator.class);
if (xo.getChild(LoadingsSparsityOperator.class) != null) {
sparsityOperator = (LoadingsSparsityOperator) xo.getChild(LoadingsSparsityOperator.class);
}
SimpleMCMCOperator loadingsOperator = (SimpleMCMCOperator) xo.getChild(LOADINGS_OPERATOR).getChild(SimpleMCMCOperator.class);
SimpleMCMCOperator factorOperator = null;
if (xo.getChild(FACTOR_OPERATOR) != null)
factorOperator = (SimpleMCMCOperator) xo.getChild(FACTOR_OPERATOR).getChild(FactorTreeGibbsOperator.class);
LatentFactorModelPrecisionGibbsOperator precisionGibbsOperator = null;
if (xo.getChild(LatentFactorModelPrecisionGibbsOperator.class) != null) {
System.out.println("here");
precisionGibbsOperator = (LatentFactorModelPrecisionGibbsOperator) xo.getChild(LatentFactorModelPrecisionGibbsOperator.class);
}
return new FactorRJMCMCOperator(weight, sizeParameter, chainLength, factors, loadings, cutoffs, loadingsSparcity, LFM, DPP, loadingsPrior, loadingsOperator, factorOperator, sparsityOperator, NOp, rowPrior, precisionGibbsOperator);
}
use of dr.inference.operators.factorAnalysis.LatentFactorModelPrecisionGibbsOperator in project beast-mcmc by beast-dev.
the class LatentFactorModelPrecisionGibbsOperatorParser method parseXMLObject.
@Override
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
String weightTemp = (String) xo.getAttribute(WEIGHT);
double weight = Double.parseDouble(weightTemp);
LatentFactorModel LFM = (LatentFactorModel) xo.getChild(LatentFactorModel.class);
DistributionLikelihood prior = (DistributionLikelihood) xo.getChild(DistributionLikelihood.class);
boolean randomScan = xo.getAttribute(RANDOM_SCAN, true);
LatentFactorModelPrecisionGibbsOperator lfmOp = new LatentFactorModelPrecisionGibbsOperator(LFM, prior, weight, randomScan);
if (xo.hasAttribute(PATH_PARAMETER)) {
System.out.println("WARNING: Setting Path Parameter is intended for debugging purposes only!");
lfmOp.setPathParameter(xo.getDoubleAttribute(PATH_PARAMETER));
}
return lfmOp;
}
Aggregations