Description Usage Arguments Details Value Author(s) References See Also Examples
View source: R/vbpca.functions.R
Estimation of regularized PCA with a Variational Bayes algorithm.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | vbpca(X, D = 1, maxIter = 500, tolerance = 1e-05, verbose = FALSE, tau = 1,
updatetau = FALSE, priorvar = 'invgamma', SVS = FALSE, priorInclusion = 0.5,
global.var = FALSE, control = list(), suppressWarnings = FALSE)
## Default S3 method:
vbpca(X, D = 1, maxIter = 500, tolerance = 1e-05, verbose = FALSE, tau = 1,
updatetau = FALSE, priorvar = 'invgamma', SVS = FALSE, priorInclusion = 0.5,
global.var = FALSE, control = list(), suppressWarnings = FALSE)
## S3 method for class 'vbpca'
print(x, ...)
## S3 method for class 'vbpca'
summary(object, ...)
is.vbpca(object)
|
X |
array_like; |
D |
integer; |
maxIter |
integer; |
tolerance |
float; |
verbose |
bool; |
tau |
float; |
updatetau |
bool; |
priorvar |
character; |
SVS |
bool; |
priorInclusion |
float or array_like; |
global.var |
bool; |
control |
list; |
suppressWarnings |
bool; |
x, object |
vbpca oject; |
... |
not used. |
The function allows performing PCA decomposition of an (I, J) input matrix X. For D principal components, the factorization occurs through:
X = X W P^T + E
where P is the (J, D) orthogonal loading matrix (P^T P = I) and W is the
(J, D) weight matrix. E is an (I, J) residual matrix.
Principal components are defined by X W. In this context, focus of the inference is on the
weight matrix W. The Variational Bayes algorithm treats the elements
of W as latent variables; P and sigma^2
(the variance of the residuals) are
fixed parameters instead.
In order to regularize the elements of W, a Multivariate Normal (MVN) prior is assumed
for the columns of W. The multivariate normals have the 0-vector as mean, and diagonal
covariance matrix with variance tau
. Different specifications of tau
(either
fixed, updated via Type-II maximum likelihood, or random with Jeffrey's or Inverse Gamma priors)
allows achieving different levels of regularization on the elements of W. Furthermore,
tau
can be updated with local information, or by sharing information with other elements
of the same components of the matrix W (global.var = TRUE
). The latter option can be
useful when deciding how many components should be used during the estimation stage.
When Inverse Gamma priors are specified, its scale hyperparameter (alphatau
) is regarded as fixed;
while its shape hyperparameter betatau
can be fixed or random; in turn, a random
betatau
can be updated with local, component-specific, or global hyperpriors.
See vbpca_control
for further details on hyperparameter specification.
When SVS = TRUE
, a spike-and-slab priors allows for variable selection on the elements of
W. In particular, a mixture prior is imposed on the elements of W; priorInclusion
controls the proportions of such prior. Variables not included in the model are assumed to be
more likely to come from a Normal distributions with variance tau
scaled by a factor
v0
(see vbpca_control
for the specification of the factor).
Similar to tau
, priorInclusion
can be fixed, or
or treated as a random variable with Beta priors. Furthermore, priorInclusion
can
refer to prior probabilities of the whole model (across all components) when specified as
a scalar, or to component-specific
prior probabilties when specified as a D-dimensional array.
a vbpca
returns a 'vbpca' object, which is a list containing the following elements:
muW |
array_like; |
P |
array_like; |
Tau |
array_like; |
sigma2 |
float; |
HPDI |
list; |
priorAlpha |
array_like; |
priorBeta |
array_like; |
priorInclusion |
array_like; |
inclusionProbabilities |
array_like; |
elbo |
float; |
converged |
bool; |
time |
array_like; |
priorvar |
character; |
global.var |
bool; |
hypertype |
character; |
SVS |
bool; |
plot |
traceplot of the evidence lower bounds computed across the various iterations of the algorithm. |
D. Vidotto <d.vidotto@uvt.nl>
[1] C. M. Bishop. 'Variational PCA'. In Proc. Ninth Int. Conf. on Artificial Neural Networks. ICANN, 1999.
[2] E. I. George, R. E. McCulloch (1993). 'Variable Selection via Gibbs Sampling'. Journal of the American Statistical Association (88), 881-889.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # Create a synthetic dataset
I <- 1e+3
X1 <- rnorm(I, 0, 50)
X2 <- rnorm(I, 0, 30)
X3 <- rnorm(I, 0, 10)
X <- cbind(X1, X1, X1, X2, X2, X2, X3, X3 )
X <- X + matrix(rnorm(length(X), 0, 1), ncol = ncol(X), nrow = I )
# Estimate the Bayesian PCA model, with Inverse Gamma priors for tau
# and SVS with Beta priors for priorInclusion
ctrl <- vbpca_control( alphatau = 1., betatau = 1e-2, beta1pi = 1., beta2pi = 1. )
mod <- vbpca(X, D = 3, priorvar = 'invgamma', SVS = TRUE, control = ctrl )
summary(mod)
mod
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.