/** * @param weight Weight matrix. * @throws NonSquareMatrixException if the argument is not a square matrix. */ public Weight(RealMatrix weight) { if (weight.getColumnDimension() != weight.getRowDimension()) { throw new NonSquareMatrixException(weight.getColumnDimension(), weight.getRowDimension()); } weightMatrix = weight.copy(); }
/** * Applies rank transform to each of the columns of <code>matrix</code> using the current <code> * rankingAlgorithm</code> * * @param matrix matrix to transform * @return a rank-transformed matrix */ private RealMatrix rankTransform(final RealMatrix matrix) { RealMatrix transformed = null; if (rankingAlgorithm instanceof NaturalRanking && ((NaturalRanking) rankingAlgorithm).getNanStrategy() == NaNStrategy.REMOVED) { final Set<Integer> nanPositions = new HashSet<Integer>(); for (int i = 0; i < matrix.getColumnDimension(); i++) { nanPositions.addAll(getNaNPositions(matrix.getColumn(i))); } // if we have found NaN values, we have to update the matrix size if (!nanPositions.isEmpty()) { transformed = new BlockRealMatrix( matrix.getRowDimension() - nanPositions.size(), matrix.getColumnDimension()); for (int i = 0; i < transformed.getColumnDimension(); i++) { transformed.setColumn(i, removeValues(matrix.getColumn(i), nanPositions)); } } } if (transformed == null) { transformed = matrix.copy(); } for (int i = 0; i < transformed.getColumnDimension(); i++) { transformed.setColumn(i, rankingAlgorithm.rank(transformed.getColumn(i))); } return transformed; }
public WeightedLeastSquaresMethod(RealMatrix R, int nFactors, RotationMethod rotationMethod) { this.nVariables = R.getColumnDimension(); this.nParam = nVariables; this.nFactors = nFactors; this.rotationMethod = rotationMethod; this.R = R; this.R2 = R.copy(); }
/** * Gets the initial guess. * * @return the initial guess. */ public RealMatrix getWeight() { return weightMatrix.copy(); }