Skip to contents

Fits a common factor model and computes the model-implied genetic correlation matrix R and its sampling covariance V_R.

Usage

rgmodel(LDSCoutput, model, std.lv = TRUE, estimation = TRUE, sub = NULL, ...)

Arguments

LDSCoutput

LDSC result (named list with S, V, I, N, m components)

model

lavaan-style model syntax (optional, uses common factor if missing)

std.lv

Standardize latent variables (default TRUE)

estimation

Estimation method: TRUE means "DWLS", "ML" for ML

sub

Subset of output (default NULL = all)

...

Additional arguments (ignored)

Value

A list with components:

R

Model-implied genetic correlation matrix

V_R

Sampling covariance of vech(R)

Examples

# Synthetic 3-trait covariance structure (normally from `ldsc()`).
covstruc <- list(
  S = matrix(c(0.60, 0.42, 0.35,
               0.42, 0.50, 0.30,
               0.35, 0.30, 0.40), 3, 3,
             dimnames = list(c("V1", "V2", "V3"), c("V1", "V2", "V3"))),
  V = diag(6) * 0.001,
  I = diag(3),
  N = c(1e5, 1e5, 1e5),
  m = 1e6
)
rg <- rgmodel(covstruc)
rg$R    # model-implied genetic correlation matrix
#>           [,1]      [,2]      [,3]
#> [1,] 1.0000000 0.7668116 0.7144345
#> [2,] 0.7668116 1.0000000 0.6708204
#> [3,] 0.7144345 0.6708204 1.0000000