Michael Thomas Flanagan's Java Scientific Library

RankAnalysis Class:     Matrix Rank Analysis

     

Last update: 12 October 2008                                                                                                                              Main Page of Michael Thomas Flanagan's Java Scientific Library

This class contains methods for performing a matrix rank analysis
A matrix A is reduced to a matrix A* by first swapping rows and cloumns to place the element of largest absolute value in the top left hand position, i.e. at a0,0, and then performing the operation
    
on all elements other than those in the first row. This procedure is the applied to the new submatrix with element, a1,1, in its top left hand position and so on for the subsequent m−2 submatrices where m is the number of diagonal elements, i.e. the minimum of the number of rows and number of columns.

An error propagation
    
is carried out, for all above reduction opertaions, on the elements of a matrix, S, whose elements, si,j, are the errors of each element, ai,j.
The number of components is estimated by comparing the diagonal elements of the reduced value matrix, A*, with the corresponding diagonal elements of the reduced error matrix, S*.
The errors may be entered as a matrix of individual elements, an array of errors, each common to a single row or as a single error common to all elements. If no errors are entered an error matrix is constructed from a rough estimate of the potential rounding errors.
The root mean square criteria
    
of McMullen et al. are also calculated.

References:
Ainsworth, S. and Bingham, W.S., (1968), Biochim. Biophys. Acta, 160, 10.
Magar, E.M., (1972), Data Analysis in Biochemistry and Biophysics, Academic Press, New York & London, pp 284-298.
McMullen, D.W., Jaskunas, S.R. and Tinoco, I., Jr., (1967), Biopolymers, 5, 589.
Wallace, R. and Katz, S.M. (1964), J. Phys. Chem. 68, 3890.

See PCA class for principal component analysis.
See Matrix class for the general matrix methods and Stat class for the general statistical methods and functions.
See Cronbach class for consistency analysis.

import directive: import flanagan.analysis.RankAnalysis;

SUMMARY OF METHODS

Constructors with a matrix of individual errors public RankAnalysis(double[][] value, double[][] error)
public RankAnalysis(float[][] value, float[][] error)
public RankAnalysis(int[][] value, int[][] error)
public RankAnalysis(long[][] value, long[][] error)
public RankAnalysis(BigDecimal[][] value, BigDecimal[][] error)
public RankAnalysis(BigInteger[][] value, BigInteger[][] error)
public RankAnalysis(ArrayMaths[] value, ArrayMaths[] error)
public RankAnalysis(ArrayList<Object>[] value, ArrayList<Object>[] error)
public RankAnalysis(Vector<Object>[] value, Vector<Object>[] error)
public RankAnalysis(Matrix value, Matrix error)
with an array of common row errors public RankAnalysis(double[][] value, double[] error)
public RankAnalysis(float[][] value, float[] error)
public RankAnalysis(int[][] value, int[] error)
public RankAnalysis(long[][] value, long[] error)
public RankAnalysis(BigDecimal[][] value, BigDecimal[] error)
public RankAnalysis(BigInteger[][] value, BigInteger[] error)
public RankAnalysis(ArrayMaths[] value, ArrayMathserror)
public RankAnalysis(ArrayList<Object>[] value, ArrayList<Object> error)
public RankAnalysis(Vector<Object>[] value, Vector<Object> error)
public RankAnalysis(Scores value)
public RankAnalysis(Cronbach value)
public RankAnalysis(PCA value)
with a single common error public RankAnalysis(double[][] value, double error)
public RankAnalysis(float[][] value, float error)
public RankAnalysis(int[][] value, int error)
public RankAnalysis(long[][] value, long error)
public RankAnalysis(BigDecimal[][] value, BigDecimal error)
public RankAnalysis(BigInteger[][] value, BigInteger error)
public RankAnalysis(ArrayMaths[] value, double error)
public RankAnalysis(ArrayList<Object>[] value, double error)
public RankAnalysis(Vector<Object>[] value, double error)
public RankAnalysis(Matrix value, double error)
no errors entered public RankAnalysis(double[][] value)
public RankAnalysis(float[][] value)
public RankAnalysis(int[][] value)
public RankAnalysis(long[][] value)
public RankAnalysis(BigDecimal[][] value)
public RankAnalysis(BigInteger[][] value)
public RankAnalysis(ArrayMaths[] value)
public RankAnalysis(ArrayList<Object>[] value)
public RankAnalysis(Vector<Object>[] value)
public RankAnalysis(Matrix value)
Missing errors   public void useErrorRowMeans()
public void useErrorColumnMeans()
public int nMissingErrors()
Reduced Data Matrices Reduced Values Matrix public double[][] reducedvalues()
Reduced Errors Matrix public double[][] reducedErrors()
Number of rows public int nRows()
Number of columns public int nColumns()
Diagonals Reduced Values Diagonal public double[] reducedValuesDiagonal()
Reduced Errors Diagonal public double[] reducedErrorsDiagonal()
Reduced Value over Error Diagonal public double[] reducedRatiosDiagonal()
P-value Diagonal public double[] probabilityValues()
McMullen rms Diagonal public double[] mcMullenValues()
Number of diagonal elements public int nDiagonalElements()
Original Data Matrices Original Values Matrix public double[][] originalvalues()
Original Errors Matrix public double[][] originalErrors()
Write an rank analysis to a text file   public void analysis( String fileName)
public void analysis()




CONSTRUCTORS

Constructors with a matrix of individual errors
public RankAnalysis(double[][] value, double[][] error)
public RankAnalysis(float[][] value, float[][] error)
public RankAnalysis(int[][] value, int[][] error)
public RankAnalysis(long[][] value, long[][] error)
public RankAnalysis(BigDecimal[][] value, BigDecimal[][] error)
public RankAnalysis(BigInteger[][] value, BigInteger[][] error)
public RankAnalysis(ArrayMaths[] value, ArrayMaths[] error)
public RankAnalysis(ArrayList<Object>[] value, ArrayList<Object>[] error)
public RankAnalysis(Vector<Object>[] value, Vector<Object>[] error)
public RankAnalysis(Matrix value, Matrix error)
Usage:                      RankAnalysis ra = new RankAnalysis(value, error);
Creates an instance of RankAnalysis with an internal matrix of values and an error matrix of individual errors. The data are stored as two dimensional arrays of double but may be entered as:
  • two dimensional arrays of   double,   float,   long,   int,   BigDecimal  or  BigInteger
  • one dimensional arrays of ArrayMaths objects,   an ArrayList<Object>  or  a Vector<Object>
  • the internal two dimensional arrays of instances of Matrix enterted as the instances of Matrix
Missing error measurements may be entered as Double.NaN or Float.NaN using the appropriate constructor. See Missing Error Measurements for the options available for replacing the missing errors with a meaningful values.

Constructors with an array of common row errors
public RankAnalysis(double[][] value, double[] error)
public RankAnalysis(float[][] value, float[] error)
public RankAnalysis(int[][] value, int[] error)
public RankAnalysis(long[][] value, long[] error)
public RankAnalysis(BigDecimal[][] value, BigDecimal[] error)
public RankAnalysis(BigInteger[][] value, BigInteger[] error)
public RankAnalysis(ArrayMaths[] value, ArrayMathserror)
public RankAnalysis(ArrayList<Object>[] value, ArrayList<Object> error)
public RankAnalysis(Vector<Object>[] value, Vector<Object> error)
public RankAnalysis(Scores value)
public RankAnalysis(Cronbach value)
public RankAnalysis(PCA value)
Usage:                      RankAnalysis ra = new RankAnalysis(value, error);
Creates an instance of RankAnalysis with an internal matrix of values and an internal error matrix each of row of which is the common error entered for that row. The data are stored as two dimensional arrays of double but may be entered as:
  • a two dimensional array of   double,   float,   long,   int,   BigDecimal  or  BigInteger for the values
    a one dimensional array of   double,   float,   long,   int,   BigDecimal  or  BigInteger for the errors
  • a one dimensional array of ArrayMaths objects,   an ArrayList<Object>  or  a Vector<Object> for the values
    a single ArrayMaths object,   an ArrayList<Object>  or  a Vector<Object> for the errors
  • the internal two dimensional array of an instance of Scores, Cronbach or PCA enterted as an instance of Scores, Cronbach or PCA. The values are taken as the used scores ordered as item per row. The common row error is calculated ast the standard deviation of the row values.

Constructors with a single common error
public RankAnalysis(double[][] value, double error)
public RankAnalysis(float[][] value, float error)
public RankAnalysis(int[][] value, int error)
public RankAnalysis(long[][] value, long error)
public RankAnalysis(BigDecimal[][] value, BigDecimal error)
public RankAnalysis(BigInteger[][] value, BigInteger error)
public RankAnalysis(ArrayMaths[] value, double error)
public RankAnalysis(ArrayList<Object>[] value, double error)
public RankAnalysis(Vector<Object>[] value, double error)
public RankAnalysis(Matrix[] value, double error)
Usage:                      RankAnalysis ra = new RankAnalysis(value, error);
Creates an instance of RankAnalysis with an internal matrix of values and an internal error matrix with all elements set as the entered single common error. The data are stored as two dimensional arrays of double but may be entered as:
  • a two dimensional array of   double,   float,   long,   int,   BigDecimal  or  BigInteger for the values
    a single   double,   float,   long,   int,   BigDecimal  or  BigInteger for the errors
  • a one dimensional array of ArrayMaths objects,   an ArrayList<Object>  or  a Vector<Object> for the values
    a single double for the errors
  • the internal two dimensional array of an instance of Matrix, enterted as the instance of Matrix, for the values.
    a single double for the errors.

Constructors with no errors entered
public RankAnalysis(double[][] value)
public RankAnalysis(float[][] value)
public RankAnalysis(int[][] value)
public RankAnalysis(long[][] value)
public RankAnalysis(BigDecimal[][] value)
public RankAnalysis(BigInteger[][] value)
public RankAnalysis(ArrayMaths[] value)
public RankAnalysis(ArrayList<Object>[] value)
public RankAnalysis(Vector<Object>[] value)
public RankAnalysis(Matrix value)
Usage:                      RankAnalysis ra = new RankAnalysis(value);
Creates an instance of RankAnalysis with an internal matrix of values. The internal error array is constructed using an estimate of the potential rounding error of each elemnt. The data are stored as two dimensional arrays of double but the values may be entered as:
  • a two dimensional array of   double,   float,   long,   int,   BigDecimal  or  BigInteger
  • a one dimensional array of ArrayMaths objects,   an ArrayList<Object>  or  a Vector<Object>
  • the internal two dimensional array of an instance of Matrix, enterted as the instance of Matrix.



MISSING ERROR MEASUREMENTS

Individual missing error measurements may be entered as Double.NaN or Float.NaN using the appropriate Constructor. The following metods offer two options for replacing the entered Nan with a meaningful value.
Replace missing error by its row mean
public void useErrorRowMeans()
Usage:                      ra.useErrorRowMeans();
This method causes an individual missing error measurement to be replaced by the mean of all the other error values in the row in which it occurs.

Replace missing error by its column mean
public void useErrorColumnMeans()
Usage:                      ra.useErrorColumnMeans();
This method causes an individual missing error measurement to be replaced by the mean of all the other error values in the column in which it occurs.

Return number of missing error measurements
public int nMissingErrors()
Usage:                      nme = ra.nMissingErrors();
This method returns the number of missing error measurements.



REDUCED DATA

REDUCED MATRICES
Reduced Values Matrix
public double[][] reducedvalues()
Usage:                      values = ra.reducedvalues();
This method returns the reduced values as a two dimensional array of doubles.

Reduced Errors Matrix
public double[] reducedErrors()
Usage:                      errors = ra.reducedErrors();
This method returns the reduced errors as a two dimensional array of doubles. If no errors were entered this method returns the propagated estimates of the potential rounding errors.

Number of rows
public int[] nRows()
Usage:                      nrows = ra.nRows();
This method returns the number of rows.

Number of columns
public int[] nColumns()
Usage:                      nrows = ra.nColumns();
This method returns the number of columns.

REDUCED DIAGONALS
Reduced Values Diagonal
public double[] reducedValuesDiagonal()
Usage:                      values = ra.reducedValuesDiagonal();
This method returns the diagonal elements of the reduced values matrix.

Reduced errors Diagonal
public double[] reducedErrorsDiagonal()
Usage:                      errors = ra.reducedErrorsDiagonal();
This method returns the diagonal elements of the reduced errors matrix. If no errors were entered this method returns the diagonal elements of the reduced errors matrix obtained from the estimates of the potential rounding errors.

Diagonal reduced value over reduced error ratios
public double[] reducedRatiosDiagonal()
Usage:                      ratios = ra.reducedRatiosDiagonal();
This method returns the ratios of each diagonal reduced value element over the corresponding diagonal reduced error element, r.

P-values of the diagonal ratios
public double[] probabilityValues()
Usage:                      pvalues = ra.probabilityValues();
This method returns the P-Values, P(r),

for the
above ratios, r.

McMullen Root Mean Squares
public double[] mcMullenValues()
Usage:                      rms = ra.mcMullenValues();
This method returns McMullen root mean square values,

See
McMullen reference for details.

Number of Diagonal Elements
public int nDiagonalElements()
Usage:                      ndiag = ra.nDiagonalElements();
This method returns the number of diagonal elements, i.e. the minimum of the number of rows and the number of columns.



ORIGINAL DATA

Original Values Matrix
public double[][] originalValues()
Usage:                      values = ra.originalValues();
This method returns the original values as a two dimensional array of doubles.

Original Errors Matrix
public double[] originalErrors()
Usage:                      errors = ra.OriginalErrors();
This method returns the original errors as a two dimensional array of doubles. If no errors were entered this method returns the initial estimates of the potential rounding errors.



ANALYSIS

public void analysis(String fileTitle)
public void analysis()
Usage:                      ra.analysis(fileTitle);
This method writes to a text file, fileTitle:
  • time and date of program execution
  • number of rows
  • number of columns
  • number of missing errors if greater than zero
and a table, for each diagonal element, of:
  • the reduced value
  • the reduced error if errors have been entered
  • the estimated rounding error if errors have not been entered
  • the ratio of the reduced value over the reduced error
  • the corresponding P-value
  • the McMullen root mean square values
Usage:                      bc.analysis();
This method is identical to analysis(fileTitle) above, except that in the absence of a supplied file title the output file is named RankAnalysisOutput.txt.



OTHER CLASSES USED BY THIS CLASS

This class uses the following classes in this library:


This page was prepared by Dr Michael Thomas Flanagan