Learn R Programming

CoFM (version 1.1.4)

PC_CoFM: Perform PCA-based Factor Estimation for CoFM

Description

This function performs Principal Component Analysis (PCA) on the correlation matrix of the data to estimate factor loadings and uniquenesses. It is designed to work with data generated by the CoFM function and calculates error metrics (MSE and relative loss) by comparing estimates against the true parameters.

Usage

PC_CoFM(data, m, A, D)

Value

A list containing:

A2

Estimated factor loadings matrix.

D2

Estimated uniquenesses matrix.

MSESigmaA

Mean Squared Error for factor loadings.

MSESigmaD

Mean Squared Error for uniquenesses.

LSigmaA

Relative loss metric for factor loadings.

LSigmaD

Relative loss metric for uniquenesses.

Arguments

data

A matrix or data frame of input data (n x p). Usually the $data output from CoFM.

m

Integer. The number of principal components (factors) to retain.

A

Matrix. The true factor loadings matrix (p x m). Usually $True_Params$A from CoFM.

D

Matrix. The true uniquenesses matrix (p x p). Usually $True_Params$D from CoFM.

Examples

Run this code
# Examples should be fast and reproducible for CRAN checks
set.seed(123)

# 1. Generate toy data using CoFM
sim_result <- CoFM(n = 200, p = 6, m = 2, type = "Clayton", param = 2.0)

# 2. Extract true parameters and observed data
true_A <- sim_result$True_Params$A
true_D <- sim_result$True_Params$D
obs_data <- sim_result$data

# 3. Apply PC method to estimate parameters and compute errors
pc_result <- PC_CoFM(data = obs_data, m = 2, A = true_A, D = true_D)

# 4. Inspect results
pc_result$MSESigmaA
pc_result$MSESigmaD
head(pc_result$A2)

Run the code above in your browser using DataLab