Description Usage Arguments Value Examples
Zero-Inflated Probabilistic PCA (ZIPPCA), for dimension reduction and data ordination of multivariate abundance data, and propose an efficient variational approximation method for estimation, inference, and prediction.
1 2 |
X |
matrix of observations. |
V |
vector of the sample covariate. |
family |
distribution of models. Two options are "poisson" and "negative.binomial". Defaults to "negative.binomial". |
n.factors |
the rank or number of factors, after dimensional reduction. Defaults to 2. |
rank |
logical, if TRUE, the rank or number of factors, is chosen from 1 to 5 by HIC (hybrid information criterion). Defaults to FALSE. |
trace |
logical, defaults to |
maxit |
maximum number of iterations within |
parallel |
logical, if TRUE, use parallel toolbox to accelerate. |
VLB |
variational lower bound of log likelihood |
lvs |
list of latent variables
|
params |
list of model parameters
|
hic |
the number of the rank selection, chosen by HIC type information criterion |
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 | n.n = 100
n.m = 50
n.factors = 2
set.seed(37)
f <- matrix(0,nrow = n.n, ncol = n.factors)
for(i in 1:n.n){
f[i,] <- rnorm(n.factors, mean = 0, sd = 1)
}
betaj <- matrix(0,nrow = n.m, ncol = n.factors)
for(j in 1:n.m){
betaj[j,] <- rnorm(n.factors, mean =0, sd = 1)
}
beta0 <- rep(1,n.m)
alpha <- rep(0,n.n)
l <- matrix(alpha,n.n,n.m) +matrix(beta0,n.n,n.m,byrow=TRUE) + f %*% t(betaj)
lambda <- exp(l)
eta_j <- runif(n.m, 0,1)
z <- matrix(0,n.n,n.m)
for(i in 1:n.n){
z[i,] <- rbinom(n.m, size=1, prob=eta_j)
}
X <- matrix(0,n.n,n.m,byrow = TRUE)
for(i in 1:n.n){
for(j in 1:n.m){
X[i,j] <- rnbinom(n=1,size=10,mu=lambda[i,j])
}
}
X[z==1]=0
zerorow <- which(rowSums(X)==0)
if(length(zerorow) >0 ){
X <- X[-zerorow,];f <- f[-zerorow,]
}
zerocol <- which(colSums(X)==0)
if(length(zerocol) >0 ){
X <- X[,-zerocol];betaj <- t(t(betaj)[,-zerocol])
}
result <- ZIPPCA::ZIPPCApn(X)
f_coordinates <- result$lvs$factor_scores
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.