This function is designed to chooose the number of factors for a generalized factor model.

chooseFacNumber(XList, types, q_set = 2: 10,
          select_method = c("SVR", "IC"),offset=FALSE,
          dc_eps=1e-4, maxIter=30, verbose = TRUE, parallelList=NULL)

Arguments

XList

a list consisting of matrices with the same rows n, and different columns (p1,p2, ..., p_d),observational mixed data matrix list, d is the types of variables, p_j is the dimension of varibles with the j-th type.

types

a d-dimensional character vector, specify the type of variables. For example, types=c('gaussian','poisson', 'binomial'), implies the components of XList are matrices with continuous, count and binomial values, respectively.

q_set

a positive integer vector, specify the candidates of factor number q, (optional) default as c(2:10) according to Bai (2013).

select_method

a string, specify the method to choose the number of factors. Two methods are supported: the singular value ratio (SVR) and information criterion (IC) based methods, default as 'SVR'. Empirically, 'SVR' is much faster than 'IC', especially for high-dimensional large-scale data.

offset

a logical value, whether add an offset term (the total counts for each row in the count component of XList) when there are Poisson variables.

dc_eps

positive real number, specify the tolerance of varing quantity of objective function in the algorithm. Optional parameter with default as 1e-4.

maxIter

a positive integer, specify the times of iteration. Optional parameter with default as 50.

verbose

a logical value, specify whether ouput the information in iteration process, (optional) default as TRUE.

parallelList

a list with two components:

(1) parallel: a logical value with TRUE or FALSE, indicates wheter to use prallel computating. Optional parameter with default as FALSE.

(2)ncores: a positive integer, specify the number of cores when parallel computing is used.

This argument plays its role if only select_method='IC'.

Value

return an integer value, the estimated number of factors.

Author

Liu Wei

Note

nothing

See also

nothing

Examples


  ## mix of normal and Poisson

  dat <- gendata(seed=1, n=60, p=60, type='norm_pois', q=2, rho=2)
  ## we set maxIter=2 for example.
  hq <- chooseFacNumber(dat$XList, dat$types, verbose = FALSE, maxIter=2)
#> Starting the varitional EM algorithm...
#> Finish the varitional EM algorithm...
#> The singular value ratio (SVR) method estimates the factor number q  as 2.