Select the number of factors and the rank of coefficient matrix in the covariate-augmented overdispersed Poisson factor model
a count matrix, the observed count matrix with shape n-by-p.
a sparse matrix, the weighted adjacency matrix;
a n-by-d matrix, the covariate matrix with low-rank regression coefficient matrix;
an optional matrix, the fixed-dimensional covariate matrix with control variables; default as a full-one column vector if there is no additional covariates.
an optional vector, the offset for each unit; default as full-zero vector.
an optional string, specify the upper bound for the number of factors; default as 15.
an optional integer, specify the upper bound for the rank of the regression coefficient matrix; default as 24.
an optional 2-dimensional positive vector, specify the the thresholds that filters the singular values of beta and B, respectively.
a logical value, whether output the information in iteration.
other arguments passed to the function SpaCOAP
.
return a named vector with names `hr` and `hq`, the estimated rank and number of factors.
The threshold is to filter the singular values with low signal, to assist the identification of underlying model structure.
None
width <- 20; height <- 15; p <- 300
d <- 20; k <- 3; q <- 6; r <- 3
datlist <- gendata_spacoap(width=width, height=height, p=p, d=d, k=k, q=q, rank0=r)
#> Loading required package: MASS
#> Loading required package: Matrix
set.seed(1)
para_vec <- chooseParams(X_count=datlist$X, Adj_sp=datlist$Adj_sp, H= datlist$H, Z = datlist$Z, r_max=6)
#> Calculate initial values...
#> Loading required package: irlba
#> Model fitting...
#> iter = 2, ELBO= 11862281583.710794, dELBO=6.523805
#> iter = 3, ELBO= 11862294363.620056, dELBO=0.000001
#> iter = 4, ELBO= 11862300321.562973, dELBO=0.000001
#> iter = 5, ELBO= 11862303727.445311, dELBO=0.000000
#> iter = 6, ELBO= 11862306064.884951, dELBO=0.000000
#> iter = 7, ELBO= 11862307506.121174, dELBO=0.000000
#> iter = 8, ELBO= 11862308363.670418, dELBO=0.000000
#> iter = 9, ELBO= 11862309356.043238, dELBO=0.000000
#> iter = 10, ELBO= 11862309518.625141, dELBO=0.000000
#> iter = 11, ELBO= 11862310038.486944, dELBO=0.000000
#> iter = 12, ELBO= 11862310411.646021, dELBO=0.000000
#> iter = 13, ELBO= 11862310032.750786, dELBO=0.000000
#> iter = 14, ELBO= 11862310199.577761, dELBO=0.000000
#> iter = 15, ELBO= 11862310301.618076, dELBO=0.000000
print(para_vec)
#> hr hq
#> 2 6