Learn R Programming

CoFM (version 1.1.4)

FanPC_CoFM: Perform Factor Analysis via Principal Component (FanPC) for CoFM

Description

This function estimates factor loadings and uniquenesses using a principal-component (FanPC) approach. It then compares these estimates with the true parameters (A and D) to calculate Mean Squared Errors (MSE) and relative loss metrics. This is designed to work with data generated by the CoFM function.

Usage

FanPC_CoFM(data, m, A, D)

Value

A list containing:

AF

Estimated factor loadings matrix (p x m).

DF

Estimated uniquenesses matrix (p x p).

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 extract.

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 FanPC and compute error metrics
fanpc_result <- FanPC_CoFM(data = obs_data, m = 2, A = true_A, D = true_D)

# 4. Inspect results
fanpc_result$MSESigmaA
fanpc_result$MSESigmaD
head(fanpc_result$AF)

Run the code above in your browser using DataLab