Learn R Programming

psychonetrics (version 0.15)

meta_lvm: Meta-analytic latent variable model

Description

Single-stage meta-analytic latent variable model (LVM) for covariance or correlation matrices. Combines a latent variable model (CFA/SEM) for the mean structure with a random-effects model for between-study heterogeneity. Based on the MAGNA framework (Epskamp et al., 2024).

Usage

meta_lvm(covs, nobs, data, cors, studyvar, groups, groupvar,
                   corinput, Vmats, Vmethod = c("individual", "pooled",
                   "metaSEM_individual", "metaSEM_weighted"), Vestimation
                   = c("averaged", "per_study"),
                   lambda, beta = "zero",
                   latent = c("cov", "chol", "prec", "ggm"),
                   sigma_zeta = "full", kappa_zeta = "full",
                   omega_zeta = "full", lowertri_zeta = "full",
                   delta_zeta = "full",
                   residual = c("cov", "chol", "prec", "ggm"),
                   sigma_epsilon = "diag", kappa_epsilon = "diag",
                   omega_epsilon = "zero", lowertri_epsilon = "diag",
                   delta_epsilon = "diag",
                   identify = TRUE,
                   identification = c("loadings", "variance"),
                   randomEffects = c("chol", "cov", "prec", "ggm", "cor"),
                   sigma_randomEffects = "full",
                   kappa_randomEffects = "full",
                   omega_randomEffects = "full",
                   lowertri_randomEffects = "full",
                   delta_randomEffects = "full",
                   rho_randomEffects = "full",
                   SD_randomEffects = "full",
                   vars, latents,
                   baseline_saturated = TRUE, optimizer,
                   estimator = c("FIML", "ML"),
                   sampleStats, verbose = FALSE,
                   bootstrap = FALSE, boot_sub, boot_resample)

Value

An object of the class psychonetrics (psychonetrics-class)

Arguments

covs

A list of covariance or correlation matrices. Must contain rows and columns with NAs for variables not included in a study.

nobs

A vector with the number of observations per study.

data

Optional data frame. When supplied together with studyvar, covariance matrices and sample sizes are computed internally per study. Cannot be used together with covs, cors, or nobs.

cors

A list of correlation matrices. When supplied, the matrices are treated as covariance matrices with a warning (appropriate for standardized data). Requires nobs.

studyvar

A string indicating the column name in data that identifies the study. Required when data is supplied.

groups

Deprecated. Use groupvar instead. Multi-group support is not yet included for meta-analytic models.

groupvar

Not yet supported for meta-analytic models. Supplying this argument will produce an error.

corinput

Logical. Defaults to FALSE. Controls whether the input is treated as correlation matrices.

Vmats

Optional list with 'V' matrices (sampling error variance approximations).

Vmethod

Which method should be used to approximate the sampling error variance?

Vestimation

How should the sampling error estimates be evaluated?

lambda

A matrix encoding the factor loading structure. Can be a pattern matrix with TRUE/FALSE or 0/1 entries, or a matrix with starting values and higher integer codes for equality constraints.

beta

Structural (regression) matrix among latent variables. Defaults to "zero".

latent

Parameterization of the latent covariance structure. One of "cov", "chol", "prec", or "ggm".

sigma_zeta

Latent covariance matrix specification (used when latent = "cov").

kappa_zeta

Latent precision matrix specification (used when latent = "prec").

omega_zeta

Latent partial correlation matrix specification (used when latent = "ggm").

lowertri_zeta

Latent Cholesky factor specification (used when latent = "chol").

delta_zeta

Latent scaling matrix specification (used when latent = "ggm").

residual

Parameterization of the residual covariance structure. One of "cov", "chol", "prec", or "ggm".

sigma_epsilon

Residual covariance matrix specification (used when residual = "cov"). Defaults to "diag". Diagonal elements are always fixed (derived from the correlation constraint).

kappa_epsilon

Residual precision matrix specification (used when residual = "prec").

omega_epsilon

Residual partial correlation matrix specification (used when residual = "ggm").

lowertri_epsilon

Residual Cholesky factor specification (used when residual = "chol").

delta_epsilon

Residual scaling matrix specification (used when residual = "ggm").

identify

Logical, should the model be identified? Defaults to TRUE.

identification

How to identify the model. "loadings" or "variance".

randomEffects

Parameterization of the random effects covariance structure.

sigma_randomEffects

Random effects covariance matrix specification (used when randomEffects = "cov").

kappa_randomEffects

Random effects precision matrix specification (used when randomEffects = "prec").

omega_randomEffects

Random effects partial correlation matrix specification (used when randomEffects = "ggm").

lowertri_randomEffects

Random effects Cholesky factor specification (used when randomEffects = "chol").

delta_randomEffects

Random effects scaling matrix specification (used when randomEffects = "ggm").

rho_randomEffects

Random effects correlation matrix specification (used when randomEffects = "cor").

SD_randomEffects

Random effects standard deviation matrix specification (used when randomEffects = "cor").

vars

Character vector of observed variable names. If missing, names are taken from the correlation matrices.

latents

Character vector of latent variable names.

baseline_saturated

Logical indicating if baseline and saturated models should be included.

optimizer

The optimizer to be used. Defaults to "nlminb".

estimator

The estimator to be used. "ML" or "FIML" (default).

sampleStats

Optional sample statistics object.

verbose

Logical, should progress be printed?

bootstrap

Should the data be bootstrapped?

boot_sub

Proportion of cases to subsample for bootstrap.

boot_resample

Logical, should bootstrap be with replacement?

Author

Sacha Epskamp <mail@sachaepskamp.com>

Details

This function implements a single-stage meta-analytic latent variable model. The model specifies that the mean of the vectorized correlation matrices follows an LVM-implied correlation structure:

$$\mu = \textrm{vechs}(\Lambda (I-B)^{-1} \Sigma_\zeta (I-B)^{-\top} \Lambda' + \Sigma_\varepsilon)$$

where diagonal elements of \(\Sigma_\varepsilon\) are derived from the constraint that \(\mu\) represents correlations (diagonal of implied covariance = 1).

Between-study heterogeneity is modeled as:

$$\Sigma = \Sigma^{(\textrm{ran})} + V$$

where \(V\) is the known sampling error covariance and \(\Sigma^{(\textrm{ran})}\) captures true between-study variation.

References

Epskamp, S. et al. (2024). Meta-Analytic Gaussian Network Aggregation. Psychometrika.

Jak, S., and Cheung, M. W. L. (2019). Meta-analytic structural equation modeling with moderating effects on SEM parameters. Psychological Methods.

See Also

meta_varcov, lvm

Examples

Run this code
if (FALSE) {
# Generate simulated data
set.seed(42)
nStudies <- 10
nvar <- 6
nlat <- 2

# True factor loading matrix
lambda_true <- matrix(0, nvar, nlat)
lambda_true[1:3, 1] <- c(0.7, 0.8, 0.6)
lambda_true[4:6, 2] <- c(0.7, 0.8, 0.6)

# Generate correlation matrices per study
cors <- list()
nobs <- sample(100:400, nStudies)
for (i in 1:nStudies) {
  sigma <- lambda_true %*% t(lambda_true) + diag(1 - rowSums(lambda_true^2))
  dat <- MASS::mvrnorm(nobs[i], rep(0, nvar), sigma)
  cors[[i]] <- cor(dat)
  colnames(cors[[i]]) <- rownames(cors[[i]]) <- paste0("V", 1:nvar)
}

# Fit meta-analytic CFA
mod <- meta_lvm(covs = cors, nobs = nobs, lambda = lambda_true != 0)
mod <- mod %>% runmodel

# Inspect results
print(mod)
parameters(mod)
getmatrix(mod, "lambda")
}

Run the code above in your browser using DataLab