R/mcoap.R
MultiCOAP.RdFit the high-dimensional multi-study covariate-augmented overdispersed Poisson factor model via variational inference.
a length-M list with each component a count matrix, which is the observed count matrix from each source/study.
a length-M list with each component a matrix that is the covariate matrix from each study.
an optional string, specify the number of study-shared factors; default as 15.
a integer vector with length M, specify the number of study-specifed factors; default as 2.
an optional integer, specify the rank of the regression coefficient matrix; default as NULL, which means that rank is the dimension of covariates in Z.
an optional length-M list with each component a vector, the normalization factors of each study; default as full-one vector.
an optional string, specify the initialization method, default as "MSFRVI".
an optional positive vlaue, tolerance of relative variation rate of the envidence lower bound value, defualt as '1e-5'.
the maximum iteration of the VEM algorithm. The default is 30.
a logical value, whether output the information in iteration.
an optional integer, specify the random seed for reproducibility in initialization.
return a list including the following components: (1) F, a list composed by the posterior estimation of study-shared factor matrix for each study; (2) H, a list composed by the posterior estimation of study-specified factor matrix for each study; (3) Sf, a list consisting of the posterior estimation of covariance matrix of study-shared factors for each study; (4) Sh, a list consisting of the posterior estimation of covariance matrix of study-specified factors for each study; (5) A, the loading matrix corresponding to study-shared factors; (6) B, a list composed by the loading matrices corresponding to the study-specified factors; (7) bbeta, the estimated regression coefficient matrix; (8) invLambda, the inverse of the estimated variances of error; (9) ELBO: the ELBO value when algorithm stops; (7) ELBO_seq: the sequence of ELBO values. (11) qrlist, the number of factors and rank of regression coefficient matrix used in fitting; (12) time.use, the elapsed time for model fitting.
If init="MSFRVI", it will use the results from multi-study linear factor model as initial values; If init="LFM", it will use the results from linear factor model by combing data from all studies as initials.
None
seed <- 1; nvec <- c(100,300); p<- 300;
d <- 3; q<- 3; qs <- rep(2,2)
datlist <- gendata_simu_multi2(seed=seed, nvec=nvec, p=p, d=d, q=3, qs=qs)
fit_mcoap <- MultiCOAP(datlist$Xlist, ZList = datlist$Zlist, q=3, qs=qs, rank_use = d)
#> iter = 2, ELBO= -90889.644953, dELBO=0.999958
#> iter = 3, ELBO= -80088.223117, dELBO=0.118841
#> iter = 4, ELBO= -75759.764645, dELBO=0.054046
#> iter = 5, ELBO= -73171.507470, dELBO=0.034164
#> iter = 6, ELBO= -71962.833715, dELBO=0.016518
#> iter = 7, ELBO= -74819.780396, dELBO=0.039700
#> iter = 8, ELBO= -72546.405591, dELBO=0.030385
#> iter = 9, ELBO= -73387.279677, dELBO=0.011591
#> iter = 10, ELBO= -78559.045054, dELBO=0.070472
#> iter = 11, ELBO= -73495.533378, dELBO=0.064455
#> iter = 12, ELBO= -72182.038358, dELBO=0.017872
#> iter = 13, ELBO= -71269.814019, dELBO=0.012638
#> iter = 14, ELBO= -71175.423331, dELBO=0.001324
#> iter = 15, ELBO= -72042.181646, dELBO=0.012178
#> iter = 16, ELBO= -73908.999501, dELBO=0.025913
#> iter = 17, ELBO= -71946.489098, dELBO=0.026553
#> iter = 18, ELBO= -76495.391328, dELBO=0.063226
#> iter = 19, ELBO= -73208.440675, dELBO=0.042969
#> iter = 20, ELBO= -71948.064700, dELBO=0.017216
#> iter = 21, ELBO= -71825.188285, dELBO=0.001708
#> iter = 22, ELBO= -71808.429994, dELBO=0.000233
#> iter = 23, ELBO= -70920.619481, dELBO=0.012364
#> iter = 24, ELBO= -70799.276626, dELBO=0.001711
#> iter = 25, ELBO= -72588.783734, dELBO=0.025276
#> iter = 26, ELBO= -71595.350758, dELBO=0.013686
#> iter = 27, ELBO= -72507.920086, dELBO=0.012746
#> iter = 28, ELBO= -71380.723517, dELBO=0.015546
#> iter = 29, ELBO= -70604.166784, dELBO=0.010879
#> iter = 30, ELBO= -78083.887857, dELBO=0.105939
str(fit_mcoap)
#> List of 15
#> $ F :List of 2
#> ..$ : num [1:100, 1:3] -0.139 -0.359 0.283 1.616 0.401 ...
#> ..$ : num [1:300, 1:3] -2.7231 1.5022 -0.5362 0.0178 -1.2687 ...
#> ..- attr(*, "dim")= int [1:2] 2 1
#> $ H :List of 2
#> ..$ : num [1:100, 1:2] 1.457 2.779 0.999 -1.02 1.021 ...
#> ..$ : num [1:300, 1:2] 1.3815 -0.8341 -1.4763 -0.7487 0.0234 ...
#> ..- attr(*, "dim")= int [1:2] 2 1
#> $ Sf :List of 2
#> ..$ : num [1:3, 1:3] 0.0388 0 0 0 0.0589 ...
#> ..$ : num [1:3, 1:3] 0.0369 0 0 0 0.0561 ...
#> ..- attr(*, "dim")= int [1:2] 2 1
#> $ Sh :List of 2
#> ..$ : num [1:2, 1:2] 0.272 0 0 0.4
#> ..$ : num [1:2, 1:2] 0.106 0 0 0.184
#> ..- attr(*, "dim")= int [1:2] 2 1
#> $ A : num [1:300, 1:3] 0.1509 0.0652 0.0987 -0.3762 -0.0505 ...
#> $ B :List of 2
#> ..$ : num [1:300, 1:2] 0.2 -0.1419 0.0683 0.021 -0.1491 ...
#> ..$ : num [1:300, 1:2] 0.0116 0.1813 0.2533 -0.0739 0.0174 ...
#> ..- attr(*, "dim")= int [1:2] 2 1
#> $ bbeta : num [1:300, 1:3] 0.289 0.168 0.249 0.249 0.181 ...
#> $ invLambda: num [1:2, 1] 1.16 1.1
#> $ Mu_y :List of 2
#> ..$ : num [1:100, 1:300] 0.253 0.217 0.331 1.77 0.955 ...
#> ..$ : num [1:300, 1:300] -0.4728 0.2185 0.0191 0.5416 -0.4073 ...
#> ..- attr(*, "dim")= int [1:2] 2 1
#> $ ELBO : num -78084
#> $ dELBO : num -7480
#> $ ELBO_seq : num [1:30] -2.15e+09 -9.09e+04 -8.01e+04 -7.58e+04 -7.32e+04 ...
#> $ Lambda : num [1:2, 1] 0.859 0.905
#> $ qrlist :List of 3
#> ..$ q : num 3
#> ..$ qs: num [1:2] 2 2
#> ..$ r : num 3
#> $ time.use : Named num 0.61
#> ..- attr(*, "names")= chr "elapsed"