cv.spfac {TOSI}R Documentation

Cross validation for selecting penalty parameters

Description

Evalute the CV values on a set of grids of penalty parameters.

Usage

  cv.spfac(X, lambda1_set, lambda2_set, nfolds=5)

Arguments

X

a n-by-p matrix, the observed data

lambda1_set

a positve vector, the grid for lambda_1.

lambda2_set

a positve vector, the grid for lambda_2.

nfolds

a positve integer, the folds of cross validation.

Value

return a list including following components:

lamcv.min

a 3-dimensional vector, the penalty value for lambda_1 and lambda_2 corresponding to the minimum CV on grids.

lamcvMat

a numeric matrix with three columns named lambda_1, lambda_2 and cv, where each row is corresponding to each grid.

lambda1_set

the used grid for lambda_1.

lambda2_set

the used grid for lambda_2.

Note

nothing

Author(s)

Liu Wei

References

Wei Liu, Huazhen Lin, (2019). Estimation and inference on high-dimensional sparse factor models.

See Also

gsspFactorm.

Examples

  datlist1 <- gendata_Fac(n= 100, p = 300, rho=1)
  X <- datlist1$X
  spfac <- gsspFactorm(X, q=NULL)  # use default values for lambda's.
  assessBsFun(spfac$sphB, datlist1$B0)
  lambda1_set <- seq(0.2, 2, by=0.3)
  lambda2_set <- 1:8
  # select lambda's values using CV method.
  lamList <- cv.spfac(X, lambda1_set, lambda2_set, nfolds=5)
  spfac <- gsspFactorm(X, q=NULL,lamList$lamcv.min[1], lamList$lamcv.min[2])
  assessBsFun(spfac$sphB, datlist1$B0)


[Package TOSI version 0.3.0 Index]