Select the number of factors using maximum singular value ratio based method
MSVR(
XList,
Z,
types,
numvarmat,
Alist = NULL,
q_max = 20,
threshold = 1e-05,
...
)
a list consisting of multiple matrices in which each matrix has the same type of values, i.e., continuous, or count, or binomial/binary values.
a matrix, the fixed-dimensional covariate matrix with control variables.
a string vector, specify the variable type in each matrix in XList
;
a length(types)
-by-d matrix, specify the number of variables in modalities that belong to the same type.
an optional vector, the offset for each unit; default as full-zero vector.
an optional string, specify the maximum number of factors; default as 20.
an optional positive value, a cutoff to filter the singular values that are smaller than it.
other arguments passed to CMGFM
return the estimated number of factors.
None
None
None
pveclist <- list('gaussian'=c(50, 150),'poisson'=c(50, 150),
'binomial'=c(100,60))
q <- 6
sigmavec <- rep(1,3)
pvec <- unlist(pveclist)
datlist <- gendata_cmgfm(pveclist = pveclist, seed = 1, n = 300,d = 3,
q = q, rho = rep(1,length(pveclist)), rho_z=0.2,
sigmavec=sigmavec, sigma_eps=1)
XList <- datlist$XList
Z <- datlist$Z
numvarmat <- datlist$numvarmat
types <- datlist$types
hq <- MSVR(XList, Z, types=types, numvarmat, q_max=20)
#> iter = 2, ELBO= 1996035.418069, dELBO=1.000000
#> iter = 3, ELBO= 2008870.627112, dELBO=0.006430
#> iter = 4, ELBO= 2013435.994552, dELBO=0.002273
#> iter = 5, ELBO= 2015986.306571, dELBO=0.001267
#> iter = 6, ELBO= 2017732.464040, dELBO=0.000866
#> iter = 7, ELBO= 2019070.948777, dELBO=0.000663
#> iter = 8, ELBO= 2020159.327339, dELBO=0.000539
#> iter = 9, ELBO= 2021075.261893, dELBO=0.000453
#> iter = 10, ELBO= 2021863.407028, dELBO=0.000390
#> iter = 11, ELBO= 2022552.577602, dELBO=0.000341
#> iter = 12, ELBO= 2023162.854223, dELBO=0.000302
#> iter = 13, ELBO= 2023708.971291, dELBO=0.000270
#> iter = 14, ELBO= 2024202.148759, dELBO=0.000244
#> iter = 15, ELBO= 2024651.190246, dELBO=0.000222
#> iter = 16, ELBO= 2025063.193194, dELBO=0.000203
#> iter = 17, ELBO= 2025444.035769, dELBO=0.000188
#> iter = 18, ELBO= 2025798.729539, dELBO=0.000175
#> iter = 19, ELBO= 2026131.690543, dELBO=0.000164
#> iter = 20, ELBO= 2026446.958984, dELBO=0.000156
#> iter = 21, ELBO= 2026748.373341, dELBO=0.000149
#> iter = 22, ELBO= 2027039.650960, dELBO=0.000144
#> iter = 23, ELBO= 2027324.175770, dELBO=0.000140
#> iter = 24, ELBO= 2027603.928624, dELBO=0.000138
#> iter = 25, ELBO= 2027876.759301, dELBO=0.000135
#> iter = 26, ELBO= 2028134.184483, dELBO=0.000127
#> iter = 27, ELBO= 2028368.464175, dELBO=0.000116
#> iter = 28, ELBO= 2028582.168070, dELBO=0.000105
#> iter = 29, ELBO= 2028781.477125, dELBO=0.000098
#> iter = 30, ELBO= 2028969.583657, dELBO=0.000093
print(c(q_true=q, q_est=hq))
#> q_true q_est
#> 6 6