# nbfactors: Estimation of the optimal number of factors of the FA model In FAMT: Factor Analysis for Multiple Testing (FAMT) : simultaneous tests under dependence in high-dimensional data

## Description

The optimal number of factors of the FA model is estimated to minimize the variance of the number of false positives (see Friguet et al., 2009).

## Usage

 ```1 2``` ```nbfactors(data, x = 1, test = x[1], pvalues = NULL, maxnbfactors = 8, diagnostic.plot = FALSE, min.err = 0.001) ```

## Arguments

 `data` 'FAMTdata' object, see `as.FAMTdata` `x` Column number(s) corresponding to the experimental condition and the optional covariates (1 by default) in the covariates data frame `test` Column number corresponding to the experimental condition (x[1] by default) on which the test is performed `pvalues` Vector of p-values for the individual tests. If NULL, the classical procedure is applied (see `raw.pvalues`) `maxnbfactors` The maximum number of factors for the FA model (8 by default) `diagnostic.plot` boolean (FALSE by default). If TRUE, the values of the variance inflation criteria for each number of factors are plotted `min.err` Stopping criterion value for iterations (default value : 0.001)

## Value

 `optimalnbfactors` Optimal number of factors of the FA model (an elbow criterion is used) `criterion ` Variance criterion for each number of factors

David Causeur

## References

Friguet C., Kloareg M. and Causeur D. (2009). A factor model approach to multiple testing under dependence. Journal of the American Statistical Association, 104:488, p.1406-1415

`as.FAMTdata`, `emfa`
 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13``` ``` ## Reading 'FAMTdata' data(expression) data(covariates) data(annotations) chicken = as.FAMTdata(expression,covariates,annotations,idcovar=2) # Estimation of the number of factors ## Not run: nbfactors(chicken,x=c(3,6),test=6) # Estimation of the number of factors with a graph of variance inflation # criterion ## Not run: nbfactors(chicken,x=c(3,6),test=6, diagnostic.plot=TRUE) ```