Pca

case class Pca(mat: DenseMatrix[Double], colNames: Seq[String])

Principal components analysis

Computed using SVD of the centred data matrix rather than from the spectral decomposition of the covariance matrix. eg. More like the R function "prcomp" than the R function "princomp".

NOTE: .loadings are transposed relative to the PCA function in Breeze

Value Params
colNames

Sequence of column names of mat

mat

Data matrix with rows corresponding to observations and columns corresponding to variables

Returns

An object of type Pca with methods such as .loadings, .scores, .sdev and .summary

Companion
object
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any

Value members

Concrete methods

def plots: Figure

Diagnostic plots for the PCA

Diagnostic plots for the PCA

def summary: Unit

Prints a summary of the PCA to console

Prints a summary of the PCA to console

Inherited methods

def productElementNames: Iterator[String]
Inherited from
Product
def productIterator: Iterator[Any]
Inherited from
Product

Concrete fields

val SVD: SVD[DenseMatrix[Double], DenseVector[Double]]

Breeze SVD object for the centred data matrix

Breeze SVD object for the centred data matrix

lazy val cumuvar: DenseVector[Double]

Cumulative variance of the principal components

Cumulative variance of the principal components

val loadings: DenseMatrix[Double]

Loadings/rotation matrix. Note that this is the TRANSPOSE of the corresponding Breeze method. But this is the usual way the rotations are reported. See how the .summary method labels the rows and columns if you are confused.

Loadings/rotation matrix. Note that this is the TRANSPOSE of the corresponding Breeze method. But this is the usual way the rotations are reported. See how the .summary method labels the rows and columns if you are confused.

val n: Int

Number of observations

Number of observations

val names: List[String]

Column names (as a List)

Column names (as a List)

val p: Int

Number of variables

Number of variables

lazy val propvar: DenseVector[Double]

Proportion of variance explained by each principal component

Proportion of variance explained by each principal component

lazy val scores: DenseMatrix[Double]

n x p matrix of scores - the rotated data

n x p matrix of scores - the rotated data

val sdev: DenseVector[Double]

Standard deviations of the principal components

Standard deviations of the principal components

lazy val totVar: Double

The total variance of the principal components

The total variance of the principal components

lazy val variance: DenseVector[Double]

Variances of the principal components

Variances of the principal components

val x: DenseMatrix[Double]

Centred data matrix

Centred data matrix

val xBar: DenseVector[Double]

Column means (for centring)

Column means (for centring)