FarmTest (version 1.0.3)

farm.scree: Diagnostic plots and quantities arising from estimating the number of underlying factors

Description

Given the data, this function draws a scree plot and a plot of the eigenvalue ratios. The eignevalue ratio test is used to estimate the number of factors. See Ahn and Horenstein(2013).

Usage

farm.scree(X, K.scree = NULL, K.factors = NULL, robust = TRUE,
  cv = TRUE, tau = 2, show.plot = FALSE)

Arguments

X

an n x p data matrix with each row being a sample.

K.scree

an optional integer specifying the number of eigenvalues to be plotted in the scree plot. Default is min(n,p).

K.factors

an optional integer specifying the number of eigenvalues to be used for the eigenvalue ratio test. Default is min(n,p)/2.

robust

a TRUE/FALSE indicating whether to use a robust covariance estimator if TRUE, or the sample covariance estimator. Default is TRUE.

cv

a boolean, specifying whether or not to run cross-validation for the tuning parameter. Default is TRUE. Only used if robust is TRUE.

tau

>0, multiplier for the tuning parameter for Huber loss function. Default is 2. Only used if robust is TRUE and cv is FALSE. See details.

show.plot

a TRUE/FALSE indicating whether to show the resulting plots. Default is FALSE.

Value

An object with S3 class farm.scree containing:

  • eigenvalues Eigenvalues of the covariance matrix

  • proportions Proportion of variance explained by the principal components

  • eigenvalue.ratios Ratios calculated in the eigenvalue ratio test

  • nfactors Number of factors found using the eigenvalue ratio test

  • K.scree Number of eigenvalues plotted in the scree plot

  • K.factors Number of eigenvalues used in the eigenvalue ratio test

If show.plots=TRUE function returns two plots: First plot is the scree plot of the data. Second plot illustrates the eigenvalue ratio test.

Details

The maximum eigenvalue ratio is marked differently on the plot. The index of this maximum ratio gives the number of estimated factors.

If show.plots=TRUE, plots are output and user has to hit <Return> to see the second plot. Alternatively, one may use the plot method for this class.

The tuning parameter = tau * sigma * optimal rate where optimal rate is the optimal rate for the tuning parameter. For details, see Fan et al.(2017). sigma is the standard deviation of the data.

References

Ahn, S. C. and Horenstein, A. R. (2013). "Eigenvalue Ratio Test for the Number of Factors," Econometrica, 81 (3), 1203<U+2013>1227.

Fan, J., Ke, Y., Sun, Q. and Zhou, W-X. (2017). "FARM-Test: Factor-Adjusted Robust Multiple Testing with False Discovery Control", https://arxiv.org/abs/1711.05386.

Zhou, W-X., Bose, K., Fan, J. and Liu, H. (2017). "A New Perspective on Robust M-Estimation: Finite Sample Theory and Applications to Dependence-Adjusted Multiple Testing," Annals of Statistics, to appear, https://arxiv.org/abs/1711.05381.

See Also

plot.farm.scree and print.farm.scree

Examples

Run this code
# NOT RUN {
set.seed(100)
p = 100
n = 20
epsilon = matrix(rnorm( p*n, 0,1), nrow = n)
B = matrix(rnorm(p*3,0,1), nrow=p)
fx = matrix(rnorm(3*n, 0,1), nrow = n)
X = fx%*%t(B)+ epsilon
output = farm.scree(X,show.plot = TRUE, cv=FALSE)
output = farm.scree(X,show.plot = FALSE, cv=FALSE, K.scree=5, K.factors =10)
output
plot(output, scree.plot=FALSE, col="blue", main="Customized plot")

# }

Run the code above in your browser using DataLab