bpcaNet: Bayesian PCA updates

Description Usage Arguments Value References See Also Examples

View source: R/RcppExports.R

Description

Perform parameter updates for PPCA using the Variational Bayes framework from Oba (2003). Not recommended to use standalone, rather it is called from within bpcapM and its wrapper pcapM.

Usage

1
2
3
bpcaNet(myMat, covy, N, D, hidden, numberOfNonNAvaluesInEachCol,
  nomissIndex, missIndex, nMissing, nPcs = 2L, threshold = 1e-04,
  maxIterations = 200L)

Arguments

myMat

matrix – data matrix with observations in rows and variables in columns. (Note that this is the transpose of X in pca_full.)

covy

matrix – the unbiased sample covariance of the data matrix.

N

numeric – the number of observations.

D

numeric – the number of variables.

hidden

numeric – indices of missing values in 1:length(myMat).

numberOfNonNAvaluesInEachCol

numeric – number of observed values in each column of the data (i.e. variables).

nomissIndex

numeric – indices of rows (observations) without any missing values.

missIndex

numeric – indices of rows (observations) with missing values.

nMissing

numeric – total number of missing values.

nPcs

numeric – number of components/latent variables to use.

threshold

numeric – threshold for convergence, applied to the precision parameter tau. Updates for which the change in tau are below this threshold value stop the algorithm.

maxIterations

numeric – the maximum number of iterations to be completed.

Value

A list of 5 elements:

W

matrix – the estimated loadings.

ss

numeric – the estimated model variance.

C

matrix – the estimated covariance matrix.

scores

matrix – the estimated scores.

m

numeric – the estimated mean vector.

References

Oba, S., Sato, M.A., Takemasa, I., Monden, M., Matsubara, K.I. and Ishii, S., 2003. doi.

Stacklies, W., Redestig, H., Scholz, M., Walther, D. and Selbig, J., 2007. doi.

See Also

bpcapM, pcapM

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
set.seed(102)
  N <- 20
  D <- 20
  nPcs <- 2
  maxIterations <- 1000
  X <- matrix(rnorm(50), D, N)
  X <- scale(X, center=TRUE, scale=FALSE) # mean 0
  covX <- cov(X)
  IX <- sample(1:D, 10)
  JX <- sample(1:N, 10)
  nMissing <- length(IX)+length(JX)
  X[JX, IX] <- 0
  hidden <- which(X==0)
  numberOfNonNAvaluesInEachCol <- colSums(X!=0)
  nomissIndex <- which(rowSums(X!=0)==N)
  missIndex <- which(rowSums(X!=0)!=N)
  threshold <- 1e-4
  bpcaNetOutput <- bpcaNet(myMat=X, covy=covX, N=N, D=D, hidden=hidden,
    numberOfNonNAvaluesInEachCol=numberOfNonNAvaluesInEachCol,
    nomissIndex=nomissIndex, missIndex=missIndex, nMissing=nMissing,
    nPcs=nPcs, threshold=threshold, maxIterations=maxIterations)

HGray384/pcaNet documentation built on Oct. 5, 2019, 3:36 p.m.