| Type: | Package |
| Title: | Advanced Principal Component Analysis |
| Version: | 1.0.0 |
| Date: | 2026-04-19 |
| Description: | Provides nine computational algorithms for dimensionality reduction via Principal Component Analysis (PCA), built using an object-oriented (S3) architecture. The package includes classical and modern methods: Singular Value Decomposition (SVD) based on Eckart and Young (1936) <doi:10.1007/BF02288367>, Power Iteration based on Hotelling (1933) <doi:10.1037/h0071325>, QR Algorithm based on Francis (1961) <doi:10.1093/comjnl/4.3.265>, Jacobi Algorithm based on Jacobi (1846) <doi:10.1515/crll.1846.30.51>, Arnoldi Iteration based on Arnoldi (1951) <doi:10.1090/qam/42792>, 'NIPALS' based on Wold (1975) <doi:10.1017/S0021900200047604>, Alternating Least Squares (ALS) based on Kolda and Bader (2009) <doi:10.1137/07070111X>, Probabilistic PCA (PPCA) with EM Algorithm based on Tipping and Bishop (1999) <doi:10.1111/1467-9868.00196>, and Generalized Hebbian Algorithm (GHA) based on Sanger (1989) <doi:10.1016/0893-6080(89)90044-0>. |
| License: | MIT + file LICENSE |
| Encoding: | UTF-8 |
| Language: | en-US |
| RoxygenNote: | 7.3.3 |
| Imports: | stats |
| NeedsCompilation: | no |
| Packaged: | 2026-04-24 12:56:22 UTC; A0812 |
| Author: | Angga Dwi Mulyanto [aut, cre] (Institut Teknologi Sepuluh Nopember, Universitas Islam Negeri Maulana Malik Ibrahim Malang), Bambang Widjanarko Otok [aut] (Institut Teknologi Sepuluh Nopember), Jerry Dwi Trijoyo Purnomo [aut] (Institut Teknologi Sepuluh Nopember) |
| Maintainer: | Angga Dwi Mulyanto <angga.dwi.m@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-04-28 18:40:24 UTC |
Advanced Principal Component Analysis (APCA)
Description
Performs PCA using one of nine different computational algorithms. This is the main wrapper function for the apca package.
Usage
apca(data, n_components = 2, method = "svd", center = TRUE, scale = FALSE)
Arguments
data |
A numeric matrix or data frame. |
n_components |
Integer. Number of principal components to extract. |
method |
Character. The algorithm to use: "svd", "power", "qr", "nipals", "jacobi", "arnoldi", "als", "ppca", or "gha". |
center |
Logical. Whether to mean-center the data. Default is TRUE. |
scale |
Logical. Whether to scale variables to unit variance. Default is FALSE. |
Value
An object of class "apca" containing scores, loadings, and variance metrics.
Examples
# Run PCA using the classical SVD algorithm
data(mtcars)
res_svd <- apca(mtcars, n_components = 2, method = "svd", scale = TRUE)
# Print basic information
print(res_svd)
# ---------------------------------------------------------
# Extracting specific mathematical components
# ---------------------------------------------------------
# 1. Extract the PCA scores (useful for clustering/regression)
my_scores <- res_svd$scores
head(my_scores)
# 2. Extract the loadings matrix (variable weights)
my_loadings <- res_svd$loadings
print(my_loadings)
# 3. Extract the eigenvalues
my_eigen <- res_svd$eigenvalues
print(my_eigen)
# Run PCA using the NIPALS algorithm
res_nipals <- apca(mtcars, n_components = 2, method = "nipals", scale = TRUE)
Plot Method for APCA Objects
Description
Generates a scatter plot of the principal component scores.
Usage
## S3 method for class 'apca'
plot(
x,
pc_x = 1,
pc_y = 2,
col = "steelblue",
pch = 16,
cex = 1.2,
las = 1,
...
)
Arguments
x |
An object of class "apca". |
pc_x |
Integer. The principal component to plot on the X-axis (default: 1). |
pc_y |
Integer. The principal component to plot on the Y-axis (default: 2). |
col |
Color of the points (default: "steelblue"). |
pch |
Point character (default: 16). |
cex |
Point size (default: 1.2). |
las |
Axis label orientation (default: 1). |
... |
Additional graphical parameters passed to the base plot function. |
Value
No return value, called for side effects (plotting).
Examples
data(mtcars)
res <- apca(mtcars, n_components = 3, method = "svd", scale = TRUE)
# Plot PC1 vs PC2 (Default)
plot(res)
# Plot PC1 vs PC3 with custom base R graphical parameters
plot(res, pc_x = 1, pc_y = 3, col = "red", pch = 19)
Summary Method for APCA Objects
Description
Extracts and calculates cumulative variance metrics from an APCA object.
Usage
## S3 method for class 'apca'
summary(object, ...)
Arguments
object |
An object of class "apca". |
... |
Additional arguments affecting the summary produced. |
Value
A list of class "summary.apca" containing variance explained, cumulative variance, and other specific algorithm metrics (like noise variance).
Examples
data(mtcars)
res <- apca(mtcars, n_components = 3, method = "svd", scale = TRUE)
# Display cumulative variance summary
summary(res)