Thel1rotation package implements the l1-rotationcriterion ofFreyaldenhoven(2025) to simplify the loading matrix in factor models.
# Install from CRANinstall.packages("l1rotation")# Install latest version from GitHubinstall.packages("devtools")devtools::install_github("SimonFreyaldenhoven/l1rotation")Find a minimal example below. For more information see the packagewebsite,documentationandvignette.
library(l1rotation)set.seed(916)# Minimal example with 2 factors, where X is a 224 by 207 matrixlf<-local_factors(X = example_data,r =2)# Rerun with parallel processinglf_lambdas<-local_factors(X = example_data,r =2,parallel =TRUE,n_cores =10)# Visualize Principal Component estimate of the loadingslf$pc_plot
# Visualize l1-rotation loadingslf$rotated_plot
Simon Freyaldenhoven. “Identification Through Sparsity in FactorModels: the l1-rotation criterion.”Philadelphia Fed WorkingPaper 20-25, February 2025.
Simon Freyaldenhoven, Ryan Kobler. “l1rotation package.”Code and data repository athttps://github.com/SimonFreyaldenhoven/l1rotation, March2025.