| Title: | Advanced Methods for Principal Component Analysis and Principal Component Regression |
|---|---|
| Description: | Provides a unified framework for principal component analysis (PCA) and principal component regression (PCR), including standard PCA, sparse PCA, robust PCA, and supervised PCA. The package supports automatic selection of the number of components using cumulative variance and elbow methods and integrates PCA with regression modelling through PCR models. It includes tools for PCA suitability assessment using Bartlett's test of sphericity and the Kaiser-Meyer-Olkin (KMO) measure. Visualisation utilities such as scree plots and biplots are provided for interpretation. The methods are designed to handle multicollinearity, outliers, and high-dimensional data, making them suitable for applied statistical modelling and data analysis. The methodology is based on established approaches described in Jolliffe (2002) <doi:10.1007/b98835>, Zou et al. (2006) <doi:10.1111/j.1467-9868.2005.00503.x>, and Hubert et al. (2005) <doi:10.1198/004017004000000563>. |
| Authors: | Dr. Pramit Pandit [aut, cre], Dr. Halagundegowda G R [aut], Dr. Kamidi Rahul [aut], Dr. S. Gandhi Doss [aut] |
| Maintainer: | Dr. Pramit Pandit <[email protected]> |
| License: | GPL-3 |
| Version: | 0.1.1 |
| Built: | 2026-05-31 17:17:10 UTC |
| Source: | https://github.com/cran/pcreg |
Performs PCA with Bartlett test, KMO measure, and visualizes scree plot and biplot (custom style).
pca(data, scale. = TRUE, center = TRUE, verbose = FALSE)pca(data, scale. = TRUE, center = TRUE, verbose = FALSE)
data |
A data frame or matrix |
scale. |
Logical; scale variables |
center |
Logical; center variables |
verbose |
Logical; if TRUE, prints Bartlett and KMO results. |
List with Bartlett test, KMO, loadings, scores, variance
{ data(mtcars) Result <- pca(mtcars) }{ data(mtcars) Result <- pca(mtcars) }
Performs Principal Component Analysis (PCA) on predictors followed by regression using selected principal components. Includes Bartlett's test, KMO measure, scree plot, biplot, and backward model selection.
pcreg(data, y, scale. = TRUE, center = TRUE, verbose = FALSE)pcreg(data, y, scale. = TRUE, center = TRUE, verbose = FALSE)
data |
A data frame or matrix |
y |
Response variable name |
scale. |
Logical; should variables be scaled? |
center |
Logical; should variables be centered? |
verbose |
Logical; print summaries? |
A list containing PCA results, regression models, diagnostics, and plots.
data(mtcars) result <- pcreg(mtcars, y = "mpg")data(mtcars) result <- pcreg(mtcars, y = "mpg")
Performs Robust PCA using MCD estimator with automatic K selection, PCA suitability tests (Bartlett & KMO), scree plot and biplot.
robust_pca(data, K = NULL, threshold = 0.9, verbose = FALSE)robust_pca(data, K = NULL, threshold = 0.9, verbose = FALSE)
data |
Numeric data frame or matrix |
K |
Number of components (auto if NULL) |
threshold |
Variance threshold for K selection |
verbose |
Logical; if TRUE prints progress messages |
List of results
data(iris) Result <- robust_pca(iris[, 1:4])data(iris) Result <- robust_pca(iris[, 1:4])
Performs Robust PCA using Minimum Covariance Determinant (MCD) followed by regression on robust principal components. Includes PCA suitability tests, summary, loadings, scree plot, biplot, and regression models.
robust_pcreg(data, y, K = NULL, threshold = 0.9, verbose = FALSE)robust_pcreg(data, y, K = NULL, threshold = 0.9, verbose = FALSE)
data |
A data frame or matrix |
y |
Response variable name (character) |
K |
Number of components (optional) |
threshold |
Variance threshold for automatic K selection |
verbose |
Logical; print detailed output |
A list containing Robust PCR outputs
set.seed(123) dat <- data.frame( y = rnorm(100), x1 = rnorm(100), x2 = rnorm(100), x3 = rnorm(100), x4 = rnorm(100) ) Result <- robust_pcreg(dat, y = "y")set.seed(123) dat <- data.frame( y = rnorm(100), x1 = rnorm(100), x2 = rnorm(100), x3 = rnorm(100), x4 = rnorm(100) ) Result <- robust_pcreg(dat, y = "y")
Performs Sparse PCA using elastic net regularisation with custom scree plot and biplot.
sparse_pca(data, K = NULL, threshold = 0.9, verbose = FALSE)sparse_pca(data, K = NULL, threshold = 0.9, verbose = FALSE)
data |
Numeric data frame or matrix |
K |
Number of components (auto if NULL) |
threshold |
Variance threshold for automatic K selection |
verbose |
Logical; prints diagnostic messages |
List with PCA results
{ data(mtcars) Result <- sparse_pca(mtcars) }{ data(mtcars) Result <- sparse_pca(mtcars) }
Performs Sparse PCA followed by regression with automatic selection of number of components. Includes PCA suitability tests, loadings, regression models, scree plot, and biplot.
sparse_pcreg(data, y, K = NULL, threshold = 0.9, verbose = FALSE)sparse_pcreg(data, y, K = NULL, threshold = 0.9, verbose = FALSE)
data |
A data frame or matrix |
y |
Response variable name (character) |
K |
Number of components (optional) |
threshold |
Variance threshold for automatic K selection |
verbose |
Logical; print messages and summaries |
A list containing model outputs and PCA results
data(mtcars) Result <- sparse_pcreg(mtcars, y = "mpg")data(mtcars) Result <- sparse_pcreg(mtcars, y = "mpg")
True SPCA (Bair et al.): screening + PCA
supervised_pca(data, response, K = NULL, threshold = 0.9, verbose = FALSE)supervised_pca(data, response, K = NULL, threshold = 0.9, verbose = FALSE)
data |
Numeric data frame or matrix |
response |
Numeric response vector |
K |
Number of components (auto if NULL) |
threshold |
Variance threshold for K selection |
verbose |
Logical; if TRUE prints progress messages |
List of SPCA results
data(mtcars) Result <- supervised_pca( mtcars[, -1], mtcars$mpg )data(mtcars) Result <- supervised_pca( mtcars[, -1], mtcars$mpg )
Performs supervised feature selection followed by Principal Component Regression (PCR). Includes Bartlett's test, KMO measure, scree plot, biplot, and regression models.
supervised_pcreg(data, response, K = NULL, threshold = 0.9, verbose = FALSE)supervised_pcreg(data, response, K = NULL, threshold = 0.9, verbose = FALSE)
data |
A data frame or matrix |
response |
Response variable name |
K |
Number of principal components |
threshold |
Cumulative variance threshold for automatic component selection |
verbose |
Logical; print summaries? |
A list containing PCA results, regression models, diagnostics, and plots.
data(mtcars) result <- supervised_pcreg( mtcars, response = "mpg" )data(mtcars) result <- supervised_pcreg( mtcars, response = "mpg" )