Determines the number of non-spurious latent factors via Monte Carlo
eigenvalue comparison against simulated null distributions. Drop-in
replacement for GenomicSEM::paLDSC(): prints the same
"Parallel Analysis suggests extracting N components" banner and
writes the same canonical PDF filenames (PA_LDSC.pdf,
Diagonalized_PA_LDSC.pdf, FA_PA_LDSC.pdf,
FA_Diagonalized_PA_LDSC.pdf) when save.pdf = TRUE. The
return value is returned invisibly so interactive callers don't see
the rich list dumped to the console, but if you assign it you get
the structured fields described below.
Usage
paLDSC(
S = S,
V = V,
r = NULL,
p = NULL,
save.pdf = FALSE,
diag = FALSE,
fa = FALSE,
fm = NULL,
nfactors = NULL,
parallel = TRUE,
cores = NULL
)Arguments
- S
Genetic covariance matrix (from LDSC output)
- V
Sampling covariance matrix (from LDSC output)
- r
Number of Monte Carlo simulations (default NULL = 500)
- p
Percentile threshold for null distribution (default NULL = 0.95)
- save.pdf
When
TRUE, write the canonical PDF filenames matching RGenomicSEM::paLDSCto the working directory.- diag
Additionally run the analysis against
diag(V)only and print/save the diagonalized variant (default FALSE).- fa
Additionally run psych factor analysis on the correlation matrix (default FALSE; requires psych).
- fm
Factor method for psych::fa (e.g. "minres", "ml", "pa"; default NULL = "minres")
- nfactors
Number of factors to extract when using fa (default NULL = auto from eigenvalue analysis)
- parallel
Use a parallel rayon worker pool for the Monte Carlo simulation loop (default
TRUE). Set toFALSEto force single-threaded execution.- cores
Integer cap on the rayon pool size. When
NULL(the default) rayon honoursRAYON_NUM_THREADSif set, else it uses the number of logical cores reported by the OS. On many-core machines (32+) or when the underlying BLAS is multithreaded, set this explicitly to avoid oversubscribing CPUs with nested BLAS threads.
Value
Invisibly, a list with components:
- observed
Observed eigenvalues (descending)
- simulated_95
Simulated eigenvalues at the given percentile
- n_factors
Suggested number of factors from the eigenvalue-based parallel analysis
- diag
(when
diag=TRUE) the same three fields for the diagonalized variant- fa
(when
fa=TRUE) loadings + uniquenesses from psych