This function generates population-level parameter matrices for simulation studies in partially confirmatory factor analysis (PCFA), bifactor models, and MTMM-type structures. This function constructs the true loading matrix, latent factor correlation matrix, and residual covariance matrix.

The function supports: - Multiple general factors Multiple specific (method) factors - Flexible loading magnitudes - Correlated general and/or specific factors - Optional sparse specific factor structure - Residual covariance structures - Identification constraints for CFA-type estimation

sim_matrix(
  n_generals = 0,
  items_per_general = 0,
  n_specifics,
  items_per_specific,
  blocks_spe = 1,
  loadings_g = c(0.7, 0.7),
  loadings_s = c(0.3, 0.3),
  lac_spe = 0,
  cpf_spe = 0,
  generals_rho = 0,
  specifics_rho = 0,
  sparse_spe = 999,
  seed = 123,
  ecr = 0,
  necw = 0,
  necb = 0
)

Arguments

n_generals

Integer. Number of general factors.

items_per_general

Integer. Number of items loading on each general factor.

n_specifics

Integer. Number of specific (group/testlet/method) factors.

items_per_specific

Integer. Number of items loading on each specific factor.

blocks_spe

Integer. Number of blocks used to evenly distribute specific-factor loadings across item clusters. When greater than 1, each specific factor is partitioned into multiple non-zero blocks. Useful for MTMM designs.

loadings_g

Numeric vector. Population loading values for general factors.

loadings_s

Numeric vector. Population loading values for specific factors.

lac_spe

Numeric. Cross-loading value.

cpf_spe

Integer. Cross-loading per factor for specific factors.

generals_rho

Numeric. Correlation among general factors.

specifics_rho

Numeric. Correlation among specific factors.

sparse_spe

Integer. number of nonzero factor correlation for special factor. Controls sparsity of specific factor correlation (large value means dense). default= 999: full correlated

seed

Integer. Random seed for reproducibility.

ecr

Numeric. Residual correlation strength.

necw

Integer. Number of residual covariance elements within factor

necb

Integer. Number of residual covariance elements between factor

Value

A list containing:

A

Loading matrix.

R

Implied population correlation matrix.

Phi

Latent factor covariance matrix.

uniquenesses

Diagonal residual variances (uniqueness terms).

fixloading

Indicator matrix specifying which loadings are fixed to 1 for model identification (especially useful for non-standard CFA or MTMM estimation).

ecm

Residual covariance matrix (error covariance matrix).

Details

If no general factor is desired (i.e., simple CFA), set the general factor component to zero. n_generals =0. The resulting structure corresponds to a standard multi-factor CFA model.

Examples

params <- sim_matrix(
  n_generals = 1,
  items_per_general = 6,
  n_specifics = 2,
  items_per_specific = 3
)

str(params)
#> List of 6
#>  $ A           : num [1:6, 1:3] 0.7 0.7 0.7 0.7 0.7 0.7 0.3 0.3 0.3 0 ...
#>   ..- attr(*, "dimnames")=List of 2
#>   .. ..$ : chr [1:6] "item1" "item2" "item3" "item4" ...
#>   .. ..$ : chr [1:3] "G1" "S1" "S2"
#>  $ R           : num [1:6, 1:6] 1 0.58 0.58 0.49 0.49 0.49 0.58 1 0.58 0.49 ...
#>   ..- attr(*, "dimnames")=List of 2
#>   .. ..$ : chr [1:6] "item1" "item2" "item3" "item4" ...
#>   .. ..$ : chr [1:6] "item1" "item2" "item3" "item4" ...
#>  $ Phi         : num [1:3, 1:3] 1 0 0 0 1 0 0 0 1
#>  $ uniquenesses: Named num [1:6] 0.42 0.42 0.42 0.42 0.42 0.42
#>   ..- attr(*, "names")= chr [1:6] "item1" "item2" "item3" "item4" ...
#>  $ fixloading  : num [1:6, 1:3] 0 1 0 0 0 0 1 0 0 0 ...
#>  $ ecm         : num [1:6, 1:6] 0.42 0 0 0 0 0 0 0.42 0 0 ...