Learn R Programming

multivarious

This package is intended to provide some basic abstractions and default implementations of basic computational infrastructure for multivariate component-based modeling such as principal components analysis.

The main idea is to model multivariate decompositions as involving projections from an input data space to a lower dimensional component space. This idea is encapsulated by the projector class and the project function. Support for two-way mapping (row projection and column projection) is provided by the derived class bi-projector. Generic functions for common operations are included:

  • project for mapping from input space into (usually) reduced-dimensional output space
  • partial_project for mapping a subset of input space into output space
  • project_vars for mapping new variables (“supplementary variables”) to output space
  • reconstruct for reconstructing input data from its low-dimensional representation
  • residuals for extracting residuals of a fit with n components.

Installation

You can install the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("bbuchsbaum/multivarious")

Example

This is a basic example which shows you how to solve a common problem:

library(multivarious)
#> 
#> Attaching package: 'multivarious'
#> The following objects are masked from 'package:stats':
#> 
#>     residuals, screeplot
#> The following objects are masked from 'package:base':
#> 
#>     transform, truncate
## basic example code

Albers theme

This package uses the albersdown theme. Vignettes are styled with vignettes/albers.css and a local vignettes/albers.js; the palette family is provided via params$family (default ‘red’). The pkgdown site uses template: { package: albersdown }.

Copy Link

Version

Install

install.packages('multivarious')

Monthly Downloads

262

Version

0.3.1

License

MIT + file LICENSE

Maintainer

Bradley Buchsbaum

Last Published

January 21st, 2026

Functions in multivarious (0.3.1)

center

center a data matrix
bootstrap_pca

Fast, Exact Bootstrap for PCA Results from pca function
bootstrap

Bootstrap Resampling for Multivariate Models
bootstrap_plsc

Bootstrap inference for PLSC loadings
classifier.discriminant_projector

Create a k-NN classifier for a discriminant projector
check_fitted

Check if preprocessor is fitted and error if not
coef.composed_projector

Get Coefficients of a Composed Projector
classifier.multiblock_biprojector

Multiblock Bi-Projector Classifier
classifier

Construct a Classifier
cPCAplus

Contrastive PCA++ (cPCA++) Performs Contrastive PCA++ (cPCA++) to find directions that capture variation enriched in a "foreground" dataset relative to a "background" dataset. This implementation follows the cPCA++ approach which directly solves the generalized eigenvalue problem Rf v = lambda Rb v, where Rf and Rb are the covariance matrices of the foreground and background data, centered using the background mean.
components

get the components
cv_generic

Generic cross-validation engine
compose_partial_projector

Compose Multiple Partial Projectors
compose_projector

Compose Two Projectors
cv

Cross-validation Framework
colscale

scale a data matrix
concat_pre_processors

bind together blockwise pre-processors
cross_projector

Two-way (cross) projection to latent components
coef.multiblock_projector

Coefficients for a Multiblock Projector
coef.cross_projector

Extract coefficients from a cross_projector object
get_fitted_state

Get fitted state from attributes
geneig

Generalized Eigenvalue Decomposition
discriminant_projector

Construct a Discriminant Projector
fit

Fit a preprocessing pipeline
feature_importance.classifier

Evaluate Feature Importance for a Classifier
feature_importance

Evaluate feature importance
group_means

Compute column-wise mean in X for each factor level of Y
init_transform

initialize a transform
inverse_projection

Inverse of the Component Matrix
is_orthogonal.projector

Stricter check for true orthogonality
fit_transform

Fit and transform data in one step
fresh

Get a fresh pre-processing node cleared of any cached data
measure_reconstruction_error

Compute reconstruction-based error metrics
mark_fitted

Enhanced fitted state tracking
inverse_projection.cross_projector

Default inverse_projection method for cross_projector
measure_interblock_transfer_error

Compute inter-block transfer error metrics for a cross_projector
inverse_transform

Inverse transform data using a fitted preprocessing pipeline
inverse_projection.composed_projector

Compute the Inverse Projection for a Composed Projector
is_orthogonal

is it orthogonal
is_fitted

Check if a preprocessing object is fitted
nystrom_approx

Nyström approximation for kernel-based decomposition (Unified Version)
nblocks

get the number of blocks
partial_inverse_projection.regress

Partial Inverse Projection for a regress Object
partial_project

Partially project a new sample onto subspace
multiblock_biprojector

Create a Multiblock Bi-Projector
partial_inverse_projection.cross_projector

Partial Inverse Projection of a Subset of the Loading Matrix in cross_projector
partial_inverse_projection

Partial Inverse Projection of a Columnwise Subset of Component Matrix
multiblock_projector

Create a Multiblock Projector
partial_project.composed_partial_projector

Partial Project Through a Composed Partial Projector
ncomp

Get the number of components
partial_project.cross_projector

Partially project data for a cross_projector
perm_test

Generic Permutation-Based Test
pca

Principal Components Analysis (PCA)
pca_outliers

PCA Outlier Diagnostics
plsc

Partial Least Squares Correlation (PLSC)
pass

a no-op pre-processing step
predict.classifier

Predict Class Labels using a Classifier Object
perm_test.plsc

Permutation test for PLSC latent variables
partial_projector

Construct a partial projector
perm_ci

Permutation Confidence Intervals
predict.discriminant_projector

Predict method for a discriminant_projector, supporting LDA or Euclid
predict.rf_classifier

Predict Class Labels using a Random Forest Classifier Object
print.bootstrap_pca_result

Print method for bootstrap_pca_result
prinang

Calculate Principal Angles Between Subspaces
print.bi_projector

Pretty Print S3 Method for bi_projector Class
print.classifier

Pretty Print Method for classifier Objects
preprocess

Convenience function for preprocessing workflow
prep

prepare a dataset by applying a pre-processing pipeline
principal_angles

Principal angles (two sub‑spaces)
print.concat_pre_processor

Print a concat_pre_processor object
print.pre_processor

Print a pre_processor object
print.prepper

Print a prepper pipeline
print.multiblock_biprojector

Pretty Print Method for multiblock_biprojector Objects
print.perm_test_pca

Print Method for perm_test_pca Objects
print.regress

Pretty Print Method for regress Objects
print.rf_classifier

Pretty Print Method for rf_classifier Objects
print.pca

Print Method for PCA Objects
project.cross_projector

project a cross_projector instance
print.perm_test

Print Method for perm_test Objects
project

New sample projection
project.nystrom_approx

Project new data using a Nyström approximation model
rank_score

Calculate Rank Score for Predictions
reconstruct.regress

Reconstruct fitted or subsetted outputs for a regress object
reconstruct

Reconstruct the data
reconstruct.composed_projector

Reconstruct Data from Scores using a Composed Projector
projector

Construct a projector instance
project_block.multiblock_projector

Project Data onto a Specific Block
reconstruct.pca

Reconstruct Data from PCA Results
project_block

Project a single "block" of data onto the subspace
project_vars

Project one or more variables onto a subspace
rf_classifier

construct a random forest wrapper classifier
reverse_transform

reverse a pre-processing transform
reprocess.cross_projector

reprocess a cross_projector instance
reprocess.nystrom_approx

Reprocess data for Nyström approximation
reconstruct_new

Reconstruct new data in a model's subspace
residualize

Compute a regression model for each column in a matrix and return residual matrix
residuals

Obtain residuals of a component model fit
reprocess

apply pre-processing parameters to a new data matrix
regress

Multi-output linear regression
rotate.pca

Rotate PCA Loadings
rotate

Rotate a Component Solution
screeplot

Screeplot for PCA
shape

Shape of the Projector
sdev

standard deviations
robust_inv_vTv

Possibly use ridge-regularized inversion of crossprod(v)
refit

refit a model
rf_classifier.projector

Create a random forest classifier
topk

top-k accuracy indicator
svd_wrapper

Singular Value Decomposition (SVD) Wrapper
shape.cross_projector

shape of a cross_projector instance
standardize

center and scale each vector of a matrix
transpose

Transpose a model
transform

Transform data using a fitted preprocessing pipeline
truncate

truncate a component fit
std_scores.svd

Calculate Standardized Scores for SVD results
std_scores

Compute standardized component scores
truncate.composed_projector

Truncate a Composed Projector
subspace_similarity

Compute subspace similarity
scores.plsc

Extract scores from a PLSC fit
scores

Retrieve the component scores
transfer.cross_projector

Transfer from X domain to Y domain (or vice versa) in a cross_projector
screeplot.pca

Screeplot for PCA
transfer

Transfer data from one domain/block to another via a latent space
summary.composed_projector

Summarize a Composed Projector
vars_for_component

Identify Original Variables for a Specific Component
variables_used

Identify Original Variables Used by a Projector
bi_projector

Construct a bi_projector instance
block_indices

get block_indices
apply_transform

apply a pre-processing transform
bi_projector_union

A Union of Concatenated bi_projector Fits
add_node

add a pre-processing stage
block_lengths

get block_lengths
biplot.pca

Biplot for PCA Objects (Enhanced with ggrepel)
block_indices.multiblock_projector

Extract the Block Indices from a Multiblock Projector
add_node.prepper

Add a pre-processing node to a pipeline
apply_rotation

Apply rotation