bwpca {scde} | R Documentation

## Determine principal components of a matrix using per-observation/per-variable weights

### Description

Implements a weighted PCA

### Usage

    bwpca(mat, matw = NULL, npcs = 2, nstarts = 1, smooth = 0,
      em.tol = 1e-06, em.maxiter = 25, seed = 1, center = TRUE,
      n.shuffles = 0)

### Arguments

`mat` | matrix of variables (columns) and observations (rows)
`matw` | corresponding weights
`npcs` | number of principal components to extract
`nstarts` | number of random starts to use
`smooth` | smoothing span
`em.tol` | desired EM algorithm tolerance
`em.maxiter` | maximum number of EM iterations
`seed` | random seed
`center` | whether mat should be centered (weighted centering)
`n.shuffles` | optional number of per-observation randomizations that should be performed in addition to the main calculations to determine the lambda1 (PC1 eigenvalue) magnitude under such randomizations (returned in $randvar)

### Value

a list containing eigenvector matrix ($rotation), projections ($scores), variance (weighted) explained by each component ($var), total (weighted) variance of the dataset ($totalvar)

### Examples

    set.seed(0)
    mat <- matrix( c(rnorm(5*10,mean=0,sd=1), rnorm(5*10,mean=5,sd=1)), 10, 10)  # random matrix
    base.pca <- bwpca(mat)  # non-weighted pca, equal weights set automatically
    matw <- matrix( c(rnorm(5*10,mean=0,sd=1), rnorm(5*10,mean=5,sd=1)), 10, 10)  # random weight matrix
    matw <- abs(matw)/max(matw)
    base.pca.weighted <- bwpca(mat, matw)  # weighted pca

[Package scde version 2.14.0 Index]