Fit the high-dimensional multi-study multi-modality covariate-augmented generalized factor model via variational inference.

MMGFM(
  XList,
  ZList,
  numvarmat,
  tauList = NULL,
  q = 15,
  qsvec = rep(2, length(XList)),
  init = c("MSFRVI", "random", "LFM"),
  epsELBO = 1e-12,
  maxIter = 30,
  verbose = TRUE,
  seed = 1
)

Arguments

XList

a S-length list with each component a m-length list composed by a combined modality matrix of the same type modalities, which is the observed matrix from each source/study and each modality, where m is the number of modality types.

ZList

a S-length list with each component a matrix that is the covariate matrix from each study.

numvarmat

a m-by-T matrix with rownames modality types that specifies the variable number for each modality of each modality type, where m is the number of modality types, T is the maximum number of modalities for one of modality types .

tauList

an optional S-length list with each component a m-length list correponding the offset term for each combined modality of each study; default as full-zero matrix.

q

an optional string, specify the number of study-shared factors; default as 15.

qsvec

a integer vector with length S, specify the number of study-specifed factors; default as 2.

init

an optional string, specify the initialization method, supporting "MSFRVI", "random" and "LFM", default as "MSFRVI".

epsELBO

an optional positive vlaue, tolerance of relative variation rate of the envidence lower bound value, defualt as '1e-5'.

maxIter

the maximum iteration of the VEM algorithm. The default is 30.

verbose

a logical value, whether output the information in iteration.

seed

an optional integer, specify the random seed for reproducibility in initialization.

Value

return a list including the following components:

  • hbeta - a M-length list composed by the estimated regression coefficient matrix for each modality;

  • hA - a M-length list composed by the loading matrix corresponding to study-shared factors for each modality;

  • hB - a S-length list composed by a M-length loading matrix list corresponding to study-specified factors for each study;

  • hF - a S-length list composed by the posterior estimation of study-shared factor matrix for each study;

  • hH - a S-length list composed by the posterior estimation of study-specified factor matrix for each study;

  • hSigma - a S-length list composed by the estimated posterior variance of the study-shared factor;

  • hPhi - a S-length list composed by the estimated posterior variance of study-specified factor;

  • hv - a S-length list composed by a M-length vector list corresponding to the posterior estimation of study-specified and modality variable-shared factor for each study and modality;

  • hzeta - the estimated posterior variance for study-specified and modality variable-shared factor;

  • hsigma2 - the estimated variance for study-specified and modality variable-shared factor;

  • hinvLambda - a S-length list composed by a M-length vector list corresponding to the inverse of the estimated variances of error;

  • S - the approximated posterior covariance for each row of F;

  • ELBO - the ELBO value when algorithm stops;

  • ELBO_seq - the sequence of ELBO values.

  • time_use - the running time in model fitting of SpaCOAP;

Details

If init="MSFRVI", it will use the results from multi-study linear factor model in MultiCOAP package as initial values; If init="LFM", it will use the results from linear factor model by combing data from all studies as initials.

References

None

See also

None

Examples

q <- 3; qsvec<-rep(2,3)
nvec <- c(100, 120, 100)
pveclist <-  list('gaussian'=rep(150, 1),'poisson'=rep(50, 2),'binomial'=rep(60, 2))
datlist <- gendata_mmgfm(seed = 1,  nvec = nvec, pveclist =pveclist,
                         q = q,  d= 3,qs = qsvec,  rho = rep(3,length(pveclist)), rho_z=0.5,
                         sigmavec=rep(0.5, length(pveclist)),  sigma_eps=1)
XList <- datlist$XList
ZList <- datlist$ZList
numvarmat <- datlist$numvarmat
### For illustration, we set maxIter=3. Set maxIter=50 when running formally
reslist1 <- MMGFM(XList, ZList=ZList, numvarmat, q=q, qsvec = qsvec, init='MSFRVI',maxIter = 3)
#> Data include 3 studies/sources
#> variables belong to 3 types: gaussian, poisson, binomial
#> Initialization...
#> Initialization using MSFR...
#> Finish Initialization!
#> Initialize the paramters related to s!
#> Initialize the paramters not related to s!
#> iter = 2, ELBO= 12862793052.045351, dELBO=1.000000 
#> iter = 3, ELBO= 12862808158.007158, dELBO=0.000001 
str(reslist1)
#> List of 15
#>  $ hbeta     :List of 5
#>   ..$ gaussian1: num [1:3, 1:150] 0.191 -0.77 -1.537 -4.184 1.89 ...
#>   ..$ poisson1 : num [1:3, 1:50] 2.1572 1.7201 0.1055 0.4514 0.0947 ...
#>   ..$ poisson2 : num [1:3, 1:50] 3.834 0.688 -1.535 0.347 0.867 ...
#>   ..$ binomial1: num [1:3, 1:60] 0.2728 -0.0187 -0.3275 0.1657 0.3694 ...
#>   ..$ binomial2: num [1:3, 1:60] -0.0245 0.3809 0.4262 0.2118 0.0424 ...
#>  $ hA        :List of 5
#>   ..$ gaussian1: num [1:150, 1:3] 0.0753 -1.4373 -0.3657 0.6579 -0.304 ...
#>   ..$ poisson1 : num [1:50, 1:3] 0.206 0.241 -1.125 -0.888 -0.419 ...
#>   ..$ poisson2 : num [1:50, 1:3] 0.42 0.143 0.769 -0.65 1.055 ...
#>   ..$ binomial1: num [1:60, 1:3] 0.10498 -0.00587 -0.24391 -0.05483 0.11832 ...
#>   ..$ binomial2: num [1:60, 1:3] 0.0286 0.2694 -0.1689 -0.1536 -0.0792 ...
#>  $ hB        :List of 3
#>   ..$ study1:List of 5
#>   .. ..$ gaussian1: num [1:150, 1:2] 0.603 0.56 0.314 0.829 0.906 ...
#>   .. ..$ poisson1 : num [1:50, 1:2] 0.1331 -0.0933 -1.2833 -0.1156 0.811 ...
#>   .. ..$ poisson2 : num [1:50, 1:2] 1.323 0.807 -1.477 -0.328 0.383 ...
#>   .. ..$ binomial1: num [1:60, 1:2] 0.0143 -0.0442 -0.0124 0.0302 0.0272 ...
#>   .. ..$ binomial2: num [1:60, 1:2] 0.05466 -0.01723 -0.12162 0.04792 0.00513 ...
#>   ..$ study2:List of 5
#>   .. ..$ gaussian1: num [1:150, 1:2] 1.3135 -0.3031 -0.5709 -0.0204 0.063 ...
#>   .. ..$ poisson1 : num [1:50, 1:2] 0.3486 0.0805 -1.0035 -0.2923 0.9222 ...
#>   .. ..$ poisson2 : num [1:50, 1:2] 0.919 0.15 0.316 0.113 -0.727 ...
#>   .. ..$ binomial1: num [1:60, 1:2] 0.1311 0.0447 -0.1486 -0.0534 0.1874 ...
#>   .. ..$ binomial2: num [1:60, 1:2] 0.1626 0.0878 0.1366 0.0945 -0.1452 ...
#>   ..$ study3:List of 5
#>   .. ..$ gaussian1: num [1:150, 1:2] 0.2601 0.4208 0.3556 0.1561 -0.0566 ...
#>   .. ..$ poisson1 : num [1:50, 1:2] 0.4907 -0.2033 -0.3901 -0.1395 -0.0524 ...
#>   .. ..$ poisson2 : num [1:50, 1:2] 0.1989 0.0289 0.863 -0.0898 -0.558 ...
#>   .. ..$ binomial1: num [1:60, 1:2] 0.0045 -0.2094 0.0998 -0.0764 0.0448 ...
#>   .. ..$ binomial2: num [1:60, 1:2] 0.0398 -0.0937 0.0384 0.0655 -0.1272 ...
#>  $ hF        :List of 3
#>   ..$ study1: num [1:100, 1:3] 1.5438 0.0894 -1.264 0.5073 -0.4048 ...
#>   ..$ study2: num [1:120, 1:3] -0.3116 0.6219 0.0717 0.9512 0.2413 ...
#>   ..$ study3: num [1:100, 1:3] 0.281 0.356 -0.903 -0.738 -1.082 ...
#>   ..- attr(*, "dim")= int [1:2] 3 1
#>  $ hH        :List of 3
#>   ..$ study1: num [1:100, 1:2] 1.68 -0.15 -3.82 2.92 1.53 ...
#>   ..$ study2: num [1:120, 1:2] -1.878 -0.115 -1.609 0.224 -3.018 ...
#>   ..$ study3: num [1:100, 1:2] 0.651 -1.97 0.146 1.907 -1.649 ...
#>   ..- attr(*, "dim")= int [1:2] 3 1
#>  $ hSigma    : num [1:3, 1:3, 1:3] 5.73e-03 7.05e-05 1.01e-04 7.05e-05 6.38e-03 ...
#>   ..- attr(*, "dim3names")= chr [1:3] "study1" "study2" "study3"
#>  $ hPhi      :List of 3
#>   ..$ : num [1:2, 1:2] 1.63e-02 9.77e-05 9.77e-05 2.16e-02
#>   ..$ : num [1:2, 1:2] 0.014449 -0.000106 -0.000106 0.020319
#>   ..$ : num [1:2, 1:2] 1.35e-02 -7.06e-05 -7.06e-05 2.41e-02
#>   ..- attr(*, "dim")= int [1:2] 3 1
#>  $ hv        :List of 3
#>   ..$ study1:List of 5
#>   .. ..$ gaussian1: num [1:100, 1] 0.0263 -0.325 0.6912 -1.0238 -0.8442 ...
#>   .. ..$ poisson1 : num [1:100, 1] -0.685 -0.297 0.553 0.179 -0.529 ...
#>   .. ..$ poisson2 : num [1:100, 1] 0.4743 -0.0183 0.7623 0.5698 0.5027 ...
#>   .. ..$ binomial1: num [1:100, 1] -0.06892 0.06443 0.00536 -0.01501 0.03253 ...
#>   .. ..$ binomial2: num [1:100, 1] -0.085 0.0197 -0.0532 -0.0131 0.0258 ...
#>   ..$ study2:List of 5
#>   .. ..$ gaussian1: num [1:120, 1] -0.069 0.173 0.601 0.211 0.608 ...
#>   .. ..$ poisson1 : num [1:120, 1] 0.124 -0.474 0.42 0.43 1.36 ...
#>   .. ..$ poisson2 : num [1:120, 1] 0.58896 -1.46538 -0.7757 -0.00916 -0.139 ...
#>   .. ..$ binomial1: num [1:120, 1] -0.0824 0.109 -0.0177 0.0194 -0.0523 ...
#>   .. ..$ binomial2: num [1:120, 1] -0.036455 -0.045551 0.000932 -0.012184 -0.047325 ...
#>   ..$ study3:List of 5
#>   .. ..$ gaussian1: num [1:100, 1] 0.7993 -0.3831 0.3638 1.1865 -0.0366 ...
#>   .. ..$ poisson1 : num [1:100, 1] 0.233 0.768 0.122 1.2 -0.471 ...
#>   .. ..$ poisson2 : num [1:100, 1] -0.129 -0.486 -0.834 -0.457 1.669 ...
#>   .. ..$ binomial1: num [1:100, 1] 0.04172 -0.04848 0.01663 0.01948 -0.00685 ...
#>   .. ..$ binomial2: num [1:100, 1] 0.0327 0.0771 -0.0277 0.0034 -0.0473 ...
#>  $ hzeta     : num [1:2, 1:3, 1:3] 0.00651 NA 0.02315 0.0231 0.0094 ...
#>  $ hsigma2   : num [1:2, 1:3, 1:3] 1.3373 NA 0.361 0.3705 0.0355 ...
#>  $ hinvLambda:List of 3
#>   ..$ study1:List of 5
#>   .. ..$ gaussian1: num [1:150, 1] 1.265 0.983 0.89 0.942 0.943 ...
#>   .. ..$ poisson1 : num [1:50, 1] 0.968 1.427 0.85 1.102 1.112 ...
#>   .. ..$ poisson2 : num [1:50, 1] 0.809 0.764 0.89 1.062 0.61 ...
#>   .. ..$ binomial1: num [1:60, 1] 1.31 1.29 1.31 1.32 1.29 ...
#>   .. ..$ binomial2: num [1:60, 1] 1.31 1.32 1.27 1.3 1.32 ...
#>   ..$ study2:List of 5
#>   .. ..$ gaussian1: num [1:150, 1] 1.102 1.36 0.907 0.843 1.224 ...
#>   .. ..$ poisson1 : num [1:50, 1] 1.026 1.231 0.939 0.96 1.078 ...
#>   .. ..$ poisson2 : num [1:50, 1] 0.988 0.885 0.851 0.665 0.61 ...
#>   .. ..$ binomial1: num [1:60, 1] 1.28 1.3 1.3 1.31 1.29 ...
#>   .. ..$ binomial2: num [1:60, 1] 1.3 1.3 1.29 1.26 1.3 ...
#>   ..$ study3:List of 5
#>   .. ..$ gaussian1: num [1:150, 1] 0.894 0.984 1.004 0.936 1.14 ...
#>   .. ..$ poisson1 : num [1:50, 1] 1.297 0.826 1.003 1.193 1.082 ...
#>   .. ..$ poisson2 : num [1:50, 1] 1.11 1.07 1.181 0.901 0.657 ...
#>   .. ..$ binomial1: num [1:60, 1] 1.3 1.31 1.32 1.31 1.29 ...
#>   .. ..$ binomial2: num [1:60, 1] 1.29 1.29 1.28 1.28 1.34 ...
#>  $ ELBO      : num 1.29e+10
#>  $ dELBO     : num 15106
#>  $ ELBO_seq  : num [1:2] 1.29e+10 1.29e+10
#>  $ time.use  : Named num 0.04
#>   ..- attr(*, "names")= chr "elapsed"