| Version: | 1.3.2 |
| Title: | Elliptical Factor Models |
| Description: | The elliptical factor model extends the traditional factor model to accommodate heavy-tailed data. This package implements sparse principal component (SPC) methods and bi-sparse online principal component estimation (SPOC) for parameter estimation. The package also provides functions for calculating mean squared error, relative error, and the sparsity of loading matrices. The underlying methodology is described in Guo (2023) <doi:10.1007/s00180-022-01270-z>. The package also includes the Zibo pet survey dataset. |
| License: | MIT + file LICENSE |
| Encoding: | UTF-8 |
| RoxygenNote: | 7.3.3 |
| Imports: | MASS, stats, SOPC, matrixcalc |
| Suggests: | testthat (≥ 3.0.0), ggplot2, pracma, psych, sn, roxygen2, rmarkdown, knitr, devtools |
| Depends: | R (≥ 3.5.0) |
| NeedsCompilation: | no |
| Language: | en-US |
| LazyData: | true |
| Packaged: | 2026-11-25 11:49:19 UTC; 86187 |
| Author: | Guangbao Guo [aut, cre], Yuanyuan Zhou [aut] |
| Maintainer: | Guangbao Guo <ggb11111111@163.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-11-30 12:20:02 UTC |
Distributed Incremental Partial Principal Components for Elliptical Factor Model
Description
Distributed incremental partial principal component analysis (DIPPC) for elliptical factor models, adopting PAST incremental updates at each distributed node.
Usage
DIPPC(
data,
K,
m,
n1,
L,
epsilon = 0.001,
sigma = 0.01,
eta = 0.1,
beta = 0.95,
delta = 1e-06
)
Arguments
data |
Numeric n x p data matrix. |
K |
Number of distributed nodes. |
m |
Number of common factors. |
n1 |
Local sample size per node. |
L |
K-by-n1 matrix of sample indices assigned to each node. |
epsilon |
Perturbation intensity. |
sigma |
Standard deviation of Gaussian perturbation. |
eta |
Step size for exponential moving average updates. |
beta |
Forgetting factor of the PAST algorithm. |
delta |
Minimum uniqueness variance threshold. |
Value
A list containing Ahat_list, Dhat_list, Fhat_list, Sigmahat_list, Abar, Dbar and Sigmabar.
Examples
data <- matrix(rnorm(500), nrow = 100, ncol = 5)
K <- 5
m <- 2
n1 <- 20
index <- sample.int(nrow(data))
L <- matrix(index, nrow = K, ncol = n1, byrow = TRUE)
res <- DIPPC(data = data, K = K, m = m, n1 = n1, L = L)
dim(res$Abar)
Distributed Principal Projection Components for Elliptical Factor Model
Description
Distributed implementation of Principal Projection Components for Elliptical Factor Model.
Usage
DPPC_EFM(data, m, n1, K, epsilon = 0.001, sigma = 0.01, A, D)
Arguments
data |
Numeric n x p data matrix (total dataset). |
m |
Number of common factors. |
n1 |
Subset sample size for each node. |
K |
Number of distributed nodes. |
epsilon |
Perturbation scale. Default = 1e-3. |
sigma |
Random perturbation standard deviation. Default = 0.01. |
A |
True loading matrix (optional, for error calculation). |
D |
True uniqueness matrix (optional, for error calculation). |
Value
A list containing distributed estimates:
- Ahat
List of estimated projection loading matrices (Apro) for each node.
- Dhat
List of estimated uniqueness diagonal matrices (Dpro) for each node.
- Sigmahat
List of sample covariance matrices for each node.
- ErrorMetrics
List of error metrics (MSEA, MSED, LA, LD) for each node.
Examples
set.seed(123)
data <- matrix(rt(500, df = 5), nrow = 100, ncol = 5)
DPPC_EFM(data = data, m = 3, n1 = 20, K = 5)
Distributed Robust Perturbed Principal Components for Elliptical Factor Model
Description
Distributed robust perturbed principal component analysis (DRPPC) for elliptical factor models.
Usage
DRPPC(
data,
K,
m,
n1,
L,
epsilon = 0.001,
sigma = 0.01,
delta = 1e-06,
A = NULL,
D = NULL
)
Arguments
data |
Numeric n x p data matrix. |
K |
Number of distributed nodes. |
m |
Number of common factors. |
n1 |
Local sample size per node. |
L |
K-by-n1 index matrix storing sample indices assigned to each node. |
epsilon |
Perturbation scale. |
sigma |
Standard deviation of random perturbation. |
delta |
Minimum uniqueness variance threshold. |
A |
True loading matrix (optional). |
D |
True uniqueness matrix (optional). |
Value
A list containing local and global estimates.
Examples
data <- matrix(rnorm(500), nrow = 100, ncol = 5)
K <- 5
m <- 2
n1 <- 20
n <- nrow(data)
index <- sample.int(n)
L <- matrix(index, nrow = K, ncol = n1, byrow = TRUE)
res <- DRPPC(data = data, K = K, m = m, n1 = n1, L = L)
dim(res$Abar)
Distributed Sparse Perturbed Principal Components for Elliptical Factor Model
Description
Distributed sparse perturbed principal component analysis (DSPPC) for elliptical factor models, incorporating soft-threshold sparse loading estimation.
Usage
DSPPC(
data,
K,
m,
n1,
L,
epsilon = 0.001,
sigma = 0.01,
lambda = 0.3,
eta = 0.1,
delta = 1e-06,
A = NULL,
D = NULL,
T = 100,
tol = 1e-07
)
Arguments
data |
Numeric n x p data matrix. |
K |
Number of distributed nodes. |
m |
Number of common factors. |
n1 |
Local sample size per node. |
L |
K-by-n1 index matrix storing sample indices assigned to each node. |
epsilon |
Perturbation scale for the local covariance matrix. |
sigma |
Standard deviation of random symmetric perturbation. |
lambda |
Soft-threshold penalty parameter. |
eta |
Step size for sparse projection update. |
delta |
Minimum uniqueness variance threshold. |
A |
True loading matrix (optional). |
D |
True uniqueness matrix (optional). |
T |
Maximum number of sparse iterations. |
tol |
Convergence tolerance for sparse iterations. |
Value
A list containing local and global estimates, including Ahat_list, Dhat_list, Fhat_list, Sigmahat_list, Abar, Dbar, Sigmabar and iterations.
Examples
data <- matrix(rnorm(500), nrow = 100, ncol = 5)
K <- 5
m <- 2
n1 <- 20
n <- nrow(data)
index <- sample.int(n)
L <- matrix(index, nrow = K, ncol = n1, byrow = TRUE)
res <- DSPPC(data = data, K = K, m = m, n1 = n1, L = L)
dim(res$Abar)
The EFM function is to generate Elliptical Factor Models data.
Description
The function supports various distribution types for generating the data, including: Elliptical-Normal Distribution, Elliptical-t Distribution.
Usage
EFM(n, p, m, nu, distribution_type)
Arguments
n |
Sample size. |
p |
Sample dimensionality. |
m |
Number of factors. |
nu |
A numerical parameter used exclusively in the "Elliptical-t" distribution, representing the degrees of freedom. |
distribution_type |
The type of distribution ("Elliptical-Normal Distribution" or "Elliptical-t Distribution"). |
Value
A list containing:
data |
A matrix of generated data (n x p). |
A |
A matrix representing the factor loadings (p x m). |
D |
A diagonal matrix representing the unique variances (p x p). |
Examples
library(MASS)
library(pracma)
n <- 2000
p <- 10
m <- 5
nu <- 5
distribution_type <- "Elliptical-Normal Distribution"
X <- EFM(n, p, m, nu, distribution_type)
Apply the FanPC method to the Elliptical Factor Model
Description
This function performs Factor Analysis via Principal Component (FanPC) on a given data set. It calculates the estimated factor loading matrix (AF), specific variance matrix (DF), and the mean squared errors.
Usage
FanPC.EFM(data, m, A, D, p)
Arguments
data |
A matrix of input data. |
m |
The number of principal components. |
A |
The true factor loadings matrix. |
D |
The true uniquenesses matrix. |
p |
The number of variables. |
Value
A list containing:
AF |
Estimated factor loadings. |
DF |
Estimated uniquenesses. |
MSESigmaA |
Mean squared error for factor loadings. |
MSESigmaD |
Mean squared error for uniquenesses. |
LSigmaA |
Loss metric for factor loadings. |
LSigmaD |
Loss metric for uniquenesses. |
Examples
library(matrixcalc)
library(MASS)
n <- 100
p <- 10
m <- 5
mu <- t(matrix(rep(runif(p, 0, 1000), n), p, n))
mu0 <- as.matrix(runif(m, 0))
sigma0 <- diag(runif(m, 1))
F_matrix <- matrix(mvrnorm(n, mu0, sigma0), nrow = n)
A <- matrix(runif(p * m, -1, 1), nrow = p)
r <- rnorm(n * p, 0, 1)
epsilon <- matrix(r, nrow = n)
D <- diag(as.vector(apply(epsilon, 2, function(x) sum(x^2))))
data <- mu + F_matrix %*% t(A) + epsilon
results <- FanPC.EFM(data, m, A, D, p)
print(results)
Incremental Perturbed Principal Components for Elliptical Factor Model
Description
This function performs incremental perturbed principal component analysis (IPPC) for parameter estimation in elliptical factor models. It adopts PAST incremental updates for subspace estimation and adds symmetric Gaussian perturbation to the low-dimensional moment matrix for perturbed factor loading estimation.
Usage
IPPC(data, m, epsilon = 1e-3, sigma = 0.01,
eta = 0.1, beta = 0.95, delta = 1e-6, A = NULL, D = NULL)
Arguments
data |
Numeric n x p data matrix. |
m |
Number of common factors. |
epsilon |
Perturbation scale for symmetric Gaussian noise on moment matrix M. |
sigma |
Random perturbation standard deviation for constructing symmetric noise matrix H. |
eta |
Incremental smoothing coefficient for M and uniqueness variance Dvec. |
beta |
Forgetting factor of the PAST algorithm. |
delta |
Minimum uniqueness variance threshold. |
A |
True loading matrix (optional, for error metrics). |
D |
True uniqueness diagonal matrix (optional, for error metrics). |
Value
A list containing:
A_hat |
Estimated p x m factor loadings matrix. |
D_hat |
Estimated p x p uniqueness matrix. |
Dvec |
p-dimensional estimated uniqueness variance vector. |
Sigma_hat |
Estimated p x p covariance matrix reconstructed by factor model. |
MSE_A |
Mean squared error for factor loadings (if true A is provided). |
MSE_D |
Mean squared error for uniqueness variances (if true D is provided). |
L_A |
Relative Frobenius loss for factor loadings. |
L_D |
Relative Frobenius loss for uniqueness variances. |
Examples
set.seed(123)
data <- matrix(rnorm(1000), nrow = 100, ncol = 10)
res <- IPPC(data = data, m = 3, epsilon = 1e-3,
sigma = 0.01, eta = 0.1, beta = 0.95, delta = 1e-6)
print(res$Sigma_hat)
Apply the PC method to the Elliptical Factor Model
Description
This function performs Principal Component Analysis (PCA) on a given data set to reduce dimensionality. It calculates the estimated values for the loadings, specific variances, and the covariance matrix.
Usage
PC1.EFM(data, m, A, D)
Arguments
data |
The total data set to be analyzed. |
m |
The number of principal components to retain in the analysis. |
A |
The true factor loadings matrix. |
D |
The true uniquenesses matrix. |
Value
A list containing:
A1 |
Estimated factor loadings. |
D1 |
Estimated uniquenesses. |
MSESigmaA |
Mean squared error for factor loadings. |
MSESigmaD |
Mean squared error for uniquenesses. |
LSigmaA |
Loss metric for factor loadings. |
LSigmaD |
Loss metric for uniquenesses. |
Examples
library(matrixcalc)
library(MASS)
n <- 100
p <- 10
m <- 5
mu <- t(matrix(rep(runif(p, 0, 1000), n), p, n))
mu0 <- as.matrix(runif(m, 0))
sigma0 <- diag(runif(m, 1))
F_matrix <- matrix(mvrnorm(n, mu0, sigma0), nrow = n)
A <- matrix(runif(p * m, -1, 1), nrow = p)
r <- rnorm(n * p, 0, 1)
epsilon <- matrix(r, nrow = n)
D <- diag(as.vector(apply(epsilon, 2, function(x) sum(x^2))))
data <- mu + F_matrix %*% t(A) + epsilon
results <- PC1.EFM(data, m, A, D)
print(results)
Perturbed Principal Component Analysis for Elliptical Factor Model
Description
Perturbed Principal Component Analysis for Elliptical Factor Model
Usage
PPC(data, m, epsilon = 0.001, sigma = 0.01, A, D)
Arguments
data |
Numeric n x p data matrix. |
m |
Number of common factors. |
epsilon |
Perturbation scale. |
sigma |
Random perturbation standard deviation. |
A |
True loading matrix (optional). |
D |
True uniqueness matrix (optional). |
Value
A list containing estimated loadings, uniquenesses, and error metrics.
Examples
library(matrixcalc)
library(MASS)
set.seed(123)
n <- 100
p <- 10
m <- 5
mu <- t(matrix(rep(runif(p, 0, 1000), n), p, n))
mu0 <- as.matrix(runif(m, 0))
sigma0 <- diag(runif(m, 1))
F_matrix <- matrix(mvrnorm(n, mu0, sigma0), nrow = n)
A <- matrix(runif(p * m, -1, 1), nrow = p)
r <- rnorm(n * p, 0, 1)
epsilon <- matrix(r, nrow = n)
D <- diag(as.vector(apply(epsilon, 2, var)))
data <- mu + F_matrix %*% t(A) + epsilon
results <- PPC(data, m, epsilon = 1e-3, sigma = 0.01, A = A, D = D)
print(results)
Apply the PPC method to the Elliptical Factor Model
Description
This function computes Perturbation Principal Component Analysis (PPC) for the provided input data, estimating factor loadings and uniquenesses. It calculates mean squared errors and loss metrics for the estimated values compared to true values.
Usage
PPC1.EFM(data, m, A, D, p)
Arguments
data |
A matrix of input data. |
m |
The number of principal components. |
A |
The true factor loadings matrix. |
D |
The true uniquenesses matrix. |
p |
The number of variables. |
Value
A list containing:
Ap |
Estimated factor loadings. |
Dp |
Estimated uniquenesses. |
MSESigmaA |
Mean squared error for factor loadings. |
MSESigmaD |
Mean squared error for uniquenesses. |
LSigmaA |
Loss metric for factor loadings. |
LSigmaD |
Loss metric for uniquenesses. |
Examples
library(matrixcalc)
library(MASS)
n <- 100
p <- 10
m <- 5
mu <- t(matrix(rep(runif(p, 0, 1000), n), p, n))
mu0 <- as.matrix(runif(m, 0))
sigma0 <- diag(runif(m, 1))
F_matrix <- matrix(mvrnorm(n, mu0, sigma0), nrow = n)
A <- matrix(runif(p * m, -1, 1), nrow = p)
r <- rnorm(n * p, 0, 1)
epsilon <- matrix(r, nrow = n)
D <- diag(as.vector(apply(epsilon, 2, function(x) sum(x^2))))
data <- mu + F_matrix %*% t(A) + epsilon
results <- PPC1.EFM(data, m, A, D, p)
print(results)
Robust Perturbed PCA for Elliptical Factor Model
Description
This function performs robust perturbed principal component analysis (RPPC) for parameter estimation in elliptical factor models. A symmetric Gaussian perturbation is added to the sample covariance matrix to improve numerical stability and robustness under high-dimensional settings.
Usage
RPPC(data, m, epsilon = 1e-3, sigma = 0.01,
delta = 1e-6, A = NULL, D = NULL)
Arguments
data |
Numeric n x p data matrix. |
m |
Number of common factors. |
epsilon |
Perturbation scale. |
sigma |
Random perturbation standard deviation. |
delta |
Minimum uniqueness variance threshold. |
A |
True loading matrix (optional, for error metrics). |
D |
True uniqueness matrix (optional, for error metrics). |
Value
A list containing:
A_hat |
Estimated factor loadings matrix. |
D_hat |
Estimated uniqueness matrix. |
Sigma_hat |
Estimated covariance matrix. |
MSE_A |
Mean squared error for factor loadings (if A provided). |
MSE_D |
Mean squared error for uniquenesses (if D provided). |
L_A |
Relative loss for factor loadings. |
L_D |
Relative loss for uniquenesses. |
Examples
set.seed(123)
data <- matrix(rnorm(1000), nrow = 100, ncol = 10)
res <- RPPC(data = data, m = 3, epsilon = 1e-3,
sigma = 0.01, delta = 1e-6)
print(res$A_hat)
print(res$Sigma_hat)
SOPC Estimation Function for Elliptical Factor Model
Description
This function processes Elliptical Factor Model (EFM) data using the Sparse Online Principal Component (SOPC) method.
Usage
SOPC.EFM(data, m, p, A, D)
Arguments
data |
A numeric matrix containing the data used in the SOPC analysis. |
m |
An integer specifying the number of subsets or common factors. |
p |
An integer specifying the number of variables in the data. |
A |
A numeric matrix representing the true factor loadings. |
D |
A numeric matrix representing the true uniquenesses. |
Value
A list containing the following metrics:
Aso |
Estimated factor loadings matrix. |
Dso |
Estimated uniquenesses matrix. |
MSEA |
Mean squared error of the estimated factor loadings (Aso) compared to the true loadings (A). |
MSED |
Mean squared error of the estimated uniquenesses (Dso) compared to the true uniquenesses (D). |
LSA |
Loss metric for the estimated factor loadings (Aso), indicating the relative error compared to the true loadings (A). |
LSD |
Loss metric for the estimated uniquenesses (Dso), indicating the relative error compared to the true uniquenesses (D). |
tauA |
Proportion of zero factor loadings in the estimated loadings matrix (Aso), representing the sparsity. |
Examples
library(matrixcalc)
library(MASS)
n <- 100
p <- 10
m <- 5
mu <- t(matrix(rep(runif(p, 0, 1000), n), p, n))
mu0 <- as.matrix(runif(m, 0))
sigma0 <- diag(runif(m, 1))
F_matrix <- matrix(mvrnorm(n, mu0, sigma0), nrow = n)
A <- matrix(runif(p * m, -1, 1), nrow = p)
r <- rnorm(n * p, 0, 1)
epsilon <- matrix(r, nrow = n)
D <- diag(as.vector(apply(epsilon, 2, function(x) sum(x^2))))
data <- mu + F_matrix %*% t(A) + epsilon
results <- SOPC.EFM(data, m, p, A, D)
print(results)
Sparse Perturbed PCA for Elliptical Factor Model
Description
This function performs sparse perturbed principal component analysis (SPPC) for parameter estimation in elliptical factor models. Random perturbation is applied to the sample covariance matrix, while soft-thresholding induces sparse factor loadings and variable selection.
Usage
SPPC(data, m, lambda = 0.3, eta = 0.1, epsilon = 1e-3,
sigma = 0.01, delta = 1e-6, max_iter = 100,
tol = 1e-7, A = NULL, D = NULL)
Arguments
data |
Numeric n x p data matrix. |
m |
Number of common factors. |
lambda |
Sparsity penalty parameter. |
eta |
Gradient step size in subspace update (0<eta<=1). |
epsilon |
Perturbation scale. |
sigma |
Random perturbation standard deviation. |
delta |
Minimum uniqueness variance threshold. |
max_iter |
Maximum number of iterations. |
tol |
Convergence tolerance. |
A |
True loading matrix (optional). |
D |
True uniqueness matrix (optional). |
Value
A list containing:
A_hat |
Estimated sparse factor loadings matrix. |
D_hat |
Estimated uniqueness matrix. |
Sigma_hat |
Estimated covariance matrix. |
iterations |
Number of iterations performed. |
converged |
Logical indicator of convergence. |
MSE_A |
Mean squared error for factor loadings (if A provided). |
MSE_D |
Mean squared error for uniquenesses (if D provided). |
L_A |
Relative loss for factor loadings. |
L_D |
Relative loss for uniquenesses. |
Examples
set.seed(123)
data <- matrix(rnorm(1200), nrow = 100, ncol = 12)
res <- SPPC(data = data, m = 3, lambda = 0.3, eta = 0.1,
epsilon = 1e-3, sigma = 0.01, delta = 1e-6,
max_iter = 100, tol = 1e-7)
print(res$iterations)
print(res$A_hat)
Calculate errors for elliptical distributions
Description
This function calculates errors for elliptical distributions, including Elliptical-Normal Distribution and Elliptical-t Distribution.
Usage
elliptical_errors(data, distribution = "normal", df = NULL)
Arguments
data |
Matrix of data following an elliptical distribution. |
distribution |
Type of elliptical distribution ("normal" or "t"). |
df |
Degrees of freedom for Elliptical-t Distribution (required if distribution is "t"). |
Details
Calculate errors for elliptical distributions
Value
A list containing error metrics for the specified elliptical distribution.
Examples
set.seed(123)
n <- 100; p <- 5
data_normal <- MASS::mvrnorm(n, rep(0, p), diag(p))
errors_normal <- elliptical_errors(data_normal, distribution = "normal")
data_t <- matrix(stats::rt(n * p, df = 5), nrow = n, ncol = p)
errors_t <- elliptical_errors(data_t, distribution = "t", df = 5)
print(errors_normal)
print(errors_t)
Zibo City Pet Survey Dataset
Description
A dataset containing survey responses related to pet consumption, purchasing behavior, customer satisfaction, and the pet industry in Zibo City, China.
Format
A data frame with 500 observations and 35 variables.
Details
The dataset contains questionnaire responses covering pet products, purchasing behavior, consumer preferences, service quality, satisfaction, and industry development.
Data collection date: March 2024.
Author(s)
Guangbao Guo, Yifei Gao
Source
Zibo City Pet Survey, March 2024.