spca-methods: Display and summarize sparse PCA fits

spca-methodsR Documentation

Display and summarize sparse PCA fits

Description

Print sparse loading coefficients and adjusted score statistics, or return a compact variance-summary matrix for a fitted model.

Usage

## S3 method for class 'spca'
print(x, ...)

## S3 method for class 'rspca'
print(x, ...)

## S3 method for class 'robspca'
print(x, ...)

## S3 method for class 'spca'
summary(object, ...)

## S3 method for class 'rspca'
summary(object, ...)

## S3 method for class 'robspca'
summary(object, ...)

Arguments

x, object

A fitted object returned by spca, rspca, or robspca.

...

Additional arguments; currently ignored.

Details

Statistics use the conventions in spca. The field eigenvalues contains adjusted score energies. Their square roots appear under the historical label “Standard deviations”. Sparse components can be correlated. These values generally differ from covariance eigenvalues and marginal score standard deviations. The summary divides by total processed input energy, including directions omitted from the model, rather than by the sum of retained values. For zero input energy it displays zero proportions by convention.

With center = FALSE, the displayed quantities use uncentered squared energies divided by n-1. For robust fits the statistics summarize the score map and do not measure the amount of outlier contamination removed. Inspect objective, iterations, and converged for optimization diagnostics.

Value

summary returns a numeric matrix with one column per component and rows named “Explained variance”, “Standard deviations”, “Proportion of variance”, and “Cumulative proportion”, rounded to three decimal places. The print methods display standard deviations, adjusted variances, and sparse loadings and invisibly return the rounded loading matrix.

Reading the summary

Each column describes one fitted score coordinate. The adjusted variance measures the part of that score not explained by earlier score columns, with the fitted loading scale retained. Therefore component order matters, the values need not decrease, and their proportions need not sum to one. The historical labels are retained for compatibility with existing code.

The sum of adjusted variance proportions is not generally 1-\|X-XBA^T\|_F^2/\|X\|_F^2. The former describes score geometry; the latter measures the reconstruction produced by the fitted reconstruction factor. Use the actual residual to assess reconstruction and cor(object$scores) to inspect score correlations when no score column is constant. Neither statistic chooses a scientifically appropriate number of components automatically.

Display precision and computation

Printing and summaries round values to three decimal places. A small nonzero loading can therefore look like zero on screen. Count selected coefficients with object$loadings != 0, using the stored full-precision matrix, and use object$eigenvalues, object$score_variance, and object$var for numerical work. For a higher-precision display, call print(object$loadings, digits = 6) directly.

The print methods invisibly return the rounded loading matrix for compatibility; they do not return the complete fit. Keep the fitted object rather than replacing it with the result of print. Arguments in ..., including a requested number of digits, are currently ignored by these fitted-object methods.

See Also

spca, rspca, robspca, predict.spca.

Examples

X <- as.matrix(iris[, 1:4])
fit <- spca(X, k = 2, alpha = 0.01, scale = TRUE, verbose = FALSE)
print(fit)
summary(fit)
cbind(adjusted = fit$eigenvalues, marginal = fit$score_variance)
colSums(fit$loadings != 0)

# Full-model reconstruction answers a different question to score variance.
processed <- scale(X, center = fit$center, scale = fit$scale)
residual <- processed - tcrossprod(fit$scores, fit$transform)
1 - sum(residual^2) / sum(processed^2)

sparsepca documentation built on Nov. 6, 2026, 5:06 p.m.