ppcaNet: Probabilistic PCA updates

Description Usage Arguments Value References See Also Examples

View source: R/RcppExports.R

Description

Perform parameter updates for PPCA using the Expectation-Maximisation framework from Porta (2005) and also in the R-package pcaMethods (Stacklies, 2007). Not recommended to use standalone, rather it is called from within ppcapM and its wrapper pcapM.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
ppcaNet(
  myMat,
  N,
  D,
  W,
  hidden,
  nMissing,
  nPcs = 2L,
  threshold = 1e-05,
  maxIterations = 1000L
)

Arguments

myMat

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

N

numeric – the number of observations.

D

numeric – the number of variables.

W

matrix – initialised loadings matrix with observed variables in rows and latent variables in columns.

hidden

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

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 4 elements:

W

matrix – the estimated loadings.

ss

numeric – the estimated model variance.

C

matrix – the estimated covariance matrix.

myMat

matrix – the data matrix with missing values replaced by their estimated projections.

References

Porta, J.M., Verbeek, J.J. and Kroese, B.J., 2005. link

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

See Also

ppcapM, pcapM

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
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)
threshold <- 1e-4
r <- sample(N)
W <- t(X[r[1:nPcs], ,drop = FALSE])
W <- matrix(rnorm(W), nrow(W), ncol(W), dimnames = labels(W) )
ppcaNetOutput <- ppcaNet(X, N, D, W, hidden, nMissing, nPcs, threshold, maxIterations)

HGray384/pcaNet documentation built on Nov. 14, 2020, 11:11 a.m.