Description Usage Arguments Value References See Also Examples
Perform the parameter updates for PPCA using either Expectation-
Maximisation or Variational Bayes as in Ilin and Raiko (2010).
Recommended to not use standalone, rather this function is called
within pca_full
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | pca_updates(
X,
V,
A,
Av,
Va,
S,
Sv,
Mu,
Muv,
Vmu,
hpVa,
hpVb,
hpV,
ndata,
Nobs_i,
Isv,
M,
IX,
JX,
rms,
errMx,
bias = 1L,
rotate2pca = 1L,
niter_broadprior = 100L,
use_prior = 1L,
use_postvar = 1L,
maxiters = 1000L,
verbose = 1L
)
|
X |
|
V |
|
A |
|
Av |
|
Va |
|
S |
|
Sv |
|
Mu |
|
Muv |
|
Vmu |
|
hpVa |
|
hpVb |
|
hpV |
|
ndata |
|
Nobs_i |
|
Isv |
|
M |
|
IX |
|
JX |
|
rms |
|
errMx |
|
bias |
|
rotate2pca |
|
niter_broadprior |
|
use_prior |
|
use_postvar |
|
maxiters |
|
verbose |
|
A list
of 6 elements:
matrix
– the estimated scores.
numeric
– the estimated mean vector.
numeric
– the estimated model variance.
matrix
– the estimated loadings.
matrix
– the estimated covariance matrix.
numeric
– the number of iterations.
Ilin, A. and Raiko, T., 2010. link.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | set.seed(102)
n <- 20
p <- 20
verbose <- 1
bias <- 1
rotate2pca <- 1
ncomp <- 2
maxiters <- 1000
opts <- list(init='random',
maxiters=as.numeric(1000),
niter_broadprior=as.numeric(100),
earlystop=as.numeric(0)
)
use_prior = 1
use_postvar = 1
X <- matrix(rnorm(50), p, n)
X <- t(scale(t(X), center=TRUE, scale=FALSE))
IX <- sample(1:p, 10)
JX <- sample(1:n, 10)
X[IX, JX] <- 0
M <- X!=0
Nobs_i = rowSums(M)
ndata <- length(IX)
# C++ indexing
IX <- IX -1
JX <- JX -1
initialisedParms <- initParms(p, n, ncomp, verbose = verbose)
A <- initialisedParms$A
S <- initialisedParms$S
Mu <- initialisedParms$Mu
V <- initialisedParms$V
Av <- initialisedParms$Av
Sv <- initialisedParms$Sv
Muv <- initialisedParms$Muv
Va <- 1000*rep(1,ncomp)
Vmu <- 1000
if (is.null(Mu)){
if (bias){
Mu <- rowSums(X) / Nobs_i
}else{
Mu = rep(0, p)
}
}
computedRMS <- compute_rms(X, A, S, M, ndata, verbose = verbose)
errMx <- computedRMS$errMx
rms <- computedRMS$rms
hpVa <- 0.001
hpVb <- 0.001
hpV <- 0.001
Isv <- rep(0, 2)
# data centering
X <- subtractMu(Mu, X, M, p, n, bias, verbose = verbose)
ppcaOutput <- pca_updates(X=X, V=V, A=A, Va=Va, Av = Av, S = S, Sv = Sv,
Mu = Mu, Muv = Muv, Vmu = Vmu,
hpVa = hpVa, hpVb = hpVb, hpV = hpV, ndata = ndata, Nobs_i = Nobs_i,
Isv = Isv, M = M, IX = IX, JX = JX, rms = rms, errMx = errMx,
bias = bias, rotate2pca = rotate2pca, niter_broadprior = opts$niter_broadprior,
use_prior = use_prior, use_postvar = use_postvar,
maxiters = maxiters, verbose = verbose)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.