use of cern.colt.matrix.linalg.SingularValueDecomposition in project beast-mcmc by beast-dev.
the class GeneralizedLinearModelParser method checkFullRank.
private void checkFullRank(DesignMatrix designMatrix) throws XMLParseException {
int fullRank = designMatrix.getColumnDimension();
// System.err.println("designMatrix getColumnDimension = "+fullRank);
SingularValueDecomposition svd = new SingularValueDecomposition(new DenseDoubleMatrix2D(designMatrix.getParameterAsMatrix()));
int realRank = svd.rank();
if (realRank != fullRank) {
throw new XMLParseException("rank(" + designMatrix.getId() + ") = " + realRank + ".\nMatrix is not of full rank as colDim(" + designMatrix.getId() + ") = " + fullRank);
}
}
use of cern.colt.matrix.linalg.SingularValueDecomposition in project beast-mcmc by beast-dev.
the class GeneralizedLinearModel method getAllIndependentVariablesIdentifiable.
public boolean getAllIndependentVariablesIdentifiable() {
int totalColDim = 0;
for (DesignMatrix mat : designMatrix) {
totalColDim += mat.getColumnDimension();
}
double[][] grandDesignMatrix = new double[N][totalColDim];
int offset = 0;
for (DesignMatrix mat : designMatrix) {
final int length = mat.getColumnDimension();
for (int i = 0; i < N; ++i) {
for (int j = 0; j < length; ++j) {
grandDesignMatrix[i][offset + j] = mat.getParameterValue(i, j);
}
}
offset += length;
}
double[][] mat = grandDesignMatrix;
if (grandDesignMatrix.length < grandDesignMatrix[0].length) {
mat = new double[grandDesignMatrix[0].length][grandDesignMatrix.length];
for (int i = 0; i < grandDesignMatrix.length; ++i) {
for (int j = 0; j < grandDesignMatrix[i].length; ++j) {
mat[j][i] = grandDesignMatrix[i][j];
}
}
}
SingularValueDecomposition svd = new SingularValueDecomposition(new DenseDoubleMatrix2D(mat));
int rank = svd.rank();
boolean isFullRank = (totalColDim == rank);
Logger.getLogger("dr.inference").info("\tTotal # of predictors = " + totalColDim + " and rank = " + rank);
return isFullRank;
}
use of cern.colt.matrix.linalg.SingularValueDecomposition in project beast-mcmc by beast-dev.
the class GeneralizedLinearModel method getAllIndependentVariablesIdentifiable.
public boolean getAllIndependentVariablesIdentifiable() {
int totalColDim = 0;
for (DesignMatrix mat : designMatrix) {
totalColDim += mat.getColumnDimension();
}
double[][] grandDesignMatrix = new double[N][totalColDim];
int offset = 0;
for (DesignMatrix mat : designMatrix) {
final int length = mat.getColumnDimension();
for (int i = 0; i < N; ++i) {
for (int j = 0; j < length; ++j) {
grandDesignMatrix[i][offset + j] = mat.getParameterValue(i, j);
}
}
offset += length;
}
double[][] mat = grandDesignMatrix;
if (grandDesignMatrix.length < grandDesignMatrix[0].length) {
mat = new double[grandDesignMatrix[0].length][grandDesignMatrix.length];
for (int i = 0; i < grandDesignMatrix.length; ++i) {
for (int j = 0; j < grandDesignMatrix[i].length; ++j) {
mat[j][i] = grandDesignMatrix[i][j];
}
}
}
SingularValueDecomposition svd = new SingularValueDecomposition(new DenseDoubleMatrix2D(mat));
int rank = svd.rank();
boolean isFullRank = (totalColDim == rank);
Logger.getLogger("dr.inference").info("\tTotal # of predictors = " + totalColDim + " and rank = " + rank);
return isFullRank;
}
use of cern.colt.matrix.linalg.SingularValueDecomposition in project beast-mcmc by beast-dev.
the class GeneralizedLinearModelParser method checkFullRank.
private void checkFullRank(DesignMatrix designMatrix) throws XMLParseException {
int fullRank = designMatrix.getColumnDimension();
// System.err.println("designMatrix getColumnDimension = "+fullRank);
SingularValueDecomposition svd = new SingularValueDecomposition(new DenseDoubleMatrix2D(designMatrix.getParameterAsMatrix()));
int realRank = svd.rank();
if (realRank != fullRank) {
throw new XMLParseException("rank(" + designMatrix.getId() + ") = " + realRank + ".\nMatrix is not of full rank as colDim(" + designMatrix.getId() + ") = " + fullRank);
}
}
Aggregations