To conduct a cross validation for Zero Inflated Poisson factor analysis to find the number of factors.
cv_ZIPFA(X, k, fold, tau = 0.1, cut = 0.8, tolLnlikelihood = 5e-4,
iter = 20, tol = 1e-4, maxiter = 100, initialtau = 'iteration',
Madj = TRUE, display = TRUE, parallel = FALSE)The matrix to be decomposed.
A vector containing the number of factors to try.
The number of folds used in cross validation.
Initial tau value to fit. Will be overwritten by the first value in initial argument.
To delete columns that has more than 100('Cut')% zeros. Cut = 1, if no filtering.
The max percentage of log likelihood differences in two iterations.
Max iterations.
A character specifying the way to choose the initial value of tau at the beginning of EM iteration. stable: estimate tau from fitted beta in last round; initial: always use the initially assigned tau in tau or initial. Use the default tau = 0.1 if 'initial' is empty. iteration: use fitted tau in last round.
Percentage of l2 norm change of [tau beta].
Max iteration number in the zero inflated poisson regression.
If TRUE then adjust for relative library size M.
If TRUE display the fitting procedure.
Use doParallel and foreach package to accelerate.
The function returns a matrix. Each row the CV likelihood of one fold. Each column is the result of number of factors in k.
The function conducts cross validation on the zero-inflated Poisson factor analysis to determine the rank.
# NOT RUN {
# }
# NOT RUN {
data(X)
cv_ZIPFA(X, fold = 10, k = c(3,4))
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab