Skip to contents

Fits a 1-factor CFA model to the genetic covariance structure, with sandwich-corrected standard errors and fit indices.

Usage

commonfactor(covstruc, estimation = "DWLS")

Arguments

covstruc

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

estimation

Estimation method: "DWLS" (default) or "ML"

Value

A list with components:

results

Data frame of parameter estimates (lhs, op, rhs, est, se, z, p)

modelfit

Named vector of fit indices (chisq, df, p_chisq, aic, cfi, srmr)

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
)
cf <- commonfactor(covstruc, estimation = "DWLS")
cf$results   # parameter estimates
#>   lhs op rhs  est         se         z           p
#> 1  F1 =~  V1 0.70 0.05527708 12.663476 0.000000000
#> 2  F1 =~  V2 0.60 0.04738035 12.663476 0.000000000
#> 3  F1 =~  V3 0.50 0.03948363 12.663476 0.000000000
#> 4  V1 ~~  V1 0.11 0.08359957  1.315796 0.376484934
#> 5  V2 ~~  V2 0.14 0.06505884  2.151898 0.062810765
#> 6  V3 ~~  V3 0.15 0.05058613  2.965239 0.006048948
cf$modelfit  # chisq, df, p_chisq, AIC, CFI, SRMR
#>        chisq           df      p_chisq          AIC          CFI         SRMR 
#> 3.068317e-16 0.000000e+00 1.000000e+00 1.200000e+01 1.000000e+00 4.759581e-10