Sparse principal component analysis (sparse PCA) is a specialised technique used in statistical analysis and, in particular, in the analysis of multivariate data sets. It extends the classic method of principal component analysis (PCA) for the reduction of dimensionality of data by introducing sparsity structures to the input variables.
A particular disadvantage of ordinary PCA is that the principal components are usually linear combinations of all input variables. Sparse PCA overcomes this disadvantage by finding linear combinations that contain just a few input variables.
Contemporary datasets often have the number of input variables () comparable with or even much larger than the number of samples (). It has been shown that if does not converge to zero, the classical PCA is not consistent. But sparse PCA can retain consistency even if 
Consider a data matrix, , where each of the columns represent an input variable, and each of the rows represents an independent sample from data population. One assumes each column of has mean zero, otherwise one can subtract column-wise mean from each element of . Let be the empirical covariance matrix of , which has dimension . Given an integer with , the sparse PCA problem can be formulated as maximizing the variance along a direction represented by vector while constraining its cardinality:
- Eq. 1
The first constraint specifies that v is a unit vector. In the second constraint, represents the L0 norm of v, which is defined as the number of its non-zero components. So the second constraint specifies that the number of non-zero components in v is less than or equal to k, which is typically an integer that is much smaller than dimension p. The optimal value of Eq. 1 is known as the k-sparse largest eigenvalue.
If one takes k=p, the problem reduces to the ordinary PCA, and the optimal value becomes the largest eigenvalue of covariance matrix Σ.
After finding the optimal solution v, one deflates Σ to obtain a new matrix
and iterate this process to obtain further principal components. However, unlike PCA, sparse PCA cannot guarantee that different principal components are orthogonal. In order to achieve orthogonality, additional constraints must be enforced.
The following equivalent definition is in matrix form. Let be a p×p symmetric matrix, one can rewrite the sparse PCA problem as
- Eq. 2
Tr is the matrix trace, and represents the non-zero elements in matrix V. The last line specifies that V has matrix rank one and is positive semidefinite. The last line means that one has , so Eq. 2 is equivalent to Eq. 1.
Moreover, the rank constraint in this formulation is actually redundant, and therefore sparse PCA can be cast as the following mixed-integer semidefinite program
- Eq. 3
Because of the cardinality constraint, the maximization problem is hard to solve exactly, especially when dimension p is high. In fact, the sparse PCA problem in Eq. 1 is NP-hard in the strong sense.
Algorithms for Sparse PCA
Several alternative approaches (of Eq. 1) have been proposed, including
- a regression framework,
- a convex relaxation/semidefinite programming framework,
- a generalized power method framework
- an alternating maximization framework
- forward-backward greedy search and exact methods using branch-and-bound techniques,
- a certifiably optimal branch-and-bound approach
- Bayesian formulation framework.
- A certifiably optimal mixed-integer semidefinite branch-and-cut approach 
The methodological and theoretical developments of Sparse PCA as well as its applications in scientific studies are recently reviewed in a survey paper.
Regression approach via lasso (elastic net)
Semidefinite Programming Relaxation
It has been proposed that sparse PCA can be approximated by semidefinite programming (SDP). If one drops the rank constraint and relaxes the cardinality constraint by a 1-norm convex constraint, one gets a semidefinite programming relaxation, which can be solved efficiently in polynomial time:
- Eq. 3
In the second constraint, is a p×1 vector of ones, and |V| is the matrix whose elements are the absolute values of the elements of V.
The optimal solution to the relaxed problem Eq. 3 is not guaranteed to have rank one. In that case, can be truncated to retain only the dominant eigenvector.
While the semidefinite program does not scale beyond n=300 covariates, it has been shown that a second-order cone relaxation of the semidefinite relaxation is almost as tight and successfully solves problems with n=1000s of covariates 
Financial Data Analysis
Suppose ordinary PCA is applied to a dataset where each input variable represents a different asset, it may generate principal components that are weighted combination of all the assets. In contrast, sparse PCA would produce principal components that are weighted combination of only a few input assets, so one can easily interpret its meaning. Furthermore, if one uses a trading strategy based on these principal components, fewer assets imply less transaction costs.
Consider a dataset where each input variable corresponds to a specific gene. Sparse PCA can produce a principal component that involves only a few genes, so researchers can focus on these specific genes for further analysis.
High-dimensional Hypothesis Testing
Contemporary datasets often have the number of input variables () comparable with or even much larger than the number of samples (). It has been shown that if does not converge to zero, the classical PCA is not consistent. In other words, if we let in Eq. 1, then the optimal value does not converge to the largest eigenvalue of data population when the sample size , and the optimal solution does not converge to the direction of maximum variance. But sparse PCA can retain consistency even if 
The k-sparse largest eigenvalue (the optimal value of Eq. 1) can be used to discriminate an isometric model, where every direction has the same variance, from a spiked covariance model in high-dimensional setting. Consider a hypothesis test where the null hypothesis specifies that data are generated from a multivariate normal distribution with mean 0 and covariance equal to an identity matrix, and the alternative hypothesis specifies that data is generated from a spiked model with signal strength :
where has only k non-zero coordinates. The largest k-sparse eigenvalue can discriminate the two hypothesis if and only if .
Since computing k-sparse eigenvalue is NP-hard, one can approximate it by the optimal value of semidefinite programming relaxation (Eq. 3). If that case, we can discriminate the two hypotheses if . The additional term cannot be improved by any other polynomical time algorithm if the planted clique conjecture holds.
- elasticnet – R package for Sparse Estimation and Sparse PCA using Elastic-Nets 
- nsprcomp - R package for sparse and/or non-negative PCA based on thresholded power iterations
- Scikit-learn – Python library for machine learning which contains Sparse PCA and other techniques in the decomposition module.
- Iain M Johnstone; Arthur Yu Lu (2009). "On Consistency and Sparsity for Principal Components Analysis in High Dimensions". Journal of the American Statistical Association. 104 (486): 682–693. doi:10.1198/jasa.2009.0121. PMC 2898454. PMID 20617121.
Dimitris Bertsimas; Ryan Cory-Wright; Jean Pauphilet (2020). "Solving Large-Scale Sparse PCA to Certifiable (Near) Optimality". arXiv:2005.05195. Cite journal requires
- Andreas M. Tillmann; Marc E. Pfetsch (2013). "The Computational Complexity of the Restricted Isometry Property, the Nullspace Property, and Related Concepts in Compressed Sensing". IEEE Transactions on Information Theory. 60 (2): 1248–1259. arXiv:1205.2081. CiteSeerX 10.1.1.760.2559. doi:10.1109/TIT.2013.2290112. S2CID 2788088.
- Hui Zou; Trevor Hastie; Robert Tibshirani (2006). "Sparse principal component analysis" (PDF). Journal of Computational and Graphical Statistics. 15 (2): 262–286. CiteSeerX 10.1.1.62.580. doi:10.1198/106186006x113430. S2CID 5730904.
- Alexandre d’Aspremont; Laurent El Ghaoui; Michael I. Jordan; Gert R. G. Lanckriet (2007). "A Direct Formulation for Sparse PCA Using Semidefinite Programming" (PDF). SIAM Review. 49 (3): 434–448. arXiv:cs/0406021. doi:10.1137/050645506. S2CID 5490061.
- Michel Journee; Yurii Nesterov; Peter Richtarik; Rodolphe Sepulchre (2010). "Generalized Power Method for Sparse Principal Component Analysis" (PDF). Journal of Machine Learning Research. 11: 517–553. arXiv:0811.4724. Bibcode:2008arXiv0811.4724J. CORE Discussion Paper 2008/70.
- Peter Richtarik; Majid Jahani; S. Damla Ahipasaoglu; Martin Takac (2020). "Alternating Maximization: Unifying Framework for 8 Sparse PCA Formulations and Efficient Parallel Codes". Optimization and Engineering.
- Baback Moghaddam; Yair Weiss; Shai Avidan (2005). "Spectral Bounds for Sparse PCA: Exact and Greedy Algorithms" (PDF). Advances in Neural Information Processing Systems. 18. MIT Press.
- Lauren Berk; Dimitris Bertsimas (2019). "Certifiably optimal sparse principal component analysis". Mathematical Programming Computation. Springer. 11 (3): 381–420. doi:10.1007/s12532-018-0153-6. S2CID 126998398.
- Yue Guan; Jennifer Dy (2009). "Sparse Probabilistic Principal Component Analysis" (PDF). Journal of Machine Learning Research Workshop and Conference Proceedings. 5: 185.
- Hui Zou; Lingzhou Xue (2018). "A Selective Overview of Sparse Principal Component Analysis". Proceedings of the IEEE. 106 (8): 1311–1320. doi:10.1109/jproc.2018.2846588.
- Dimitris Bertsimas; Ryan Cory-Wright (2020). "On polyhedral and second-order cone decompositions of semidefinite optimization problems". Operations Research Letters. Elsevier. 48 (1): 78–85. doi:10.1016/j.orl.2019.12.003.
- Quentin Berthet; Philippe Rigollet (2013). "Optimal Detection of Sparse Principal Components in High Dimension". Annals of Statistics. 41 (1): 1780–1815. arXiv:1202.5070. doi:10.1214/13-aos1127. S2CID 7162068.
-  https://cran.r-project.org/web/packages/elasticnet/elasticnet.pdf
-  https://cran.r-project.org/package=nsprcomp
-  http://scikit-learn.org/stable/modules/generated/sklearn.decomposition.SparsePCA.html