View source: R/e_modelmodifications_transmod.R
transmod | R Documentation |
This function allows to transform a model variance–covariance structure from one type to another. Its main uses are to (1) use a Cholesky decomposition to estimate a saturated covariance matrix or GGM, and (2) to transform between conditional (ggm) and marginal associations (cov).
transmod(x, ..., verbose, keep_computed = FALSE, log = TRUE,
identify = TRUE)
x |
A psychonetrics model |
... |
Named arguments with the new types to use (e.g., |
verbose |
Logical, should messages be printed? |
keep_computed |
Logical, should the model be stated to be uncomputed adter the transformation? In general, a model does not need to be re-computed as transformed parameters should be at the maximum likelihood estimate. |
log |
Logical, should a logbook entry be made? |
identify |
Logical, should the model be identified after transforming? |
Transformations are only possible if the model is diagonal (e.g., no partial correlations) or saturated (e.g., all covariances included).
Sacha Epskamp
# Load bfi data from psych package:
library("psychTools")
data(bfi)
# Also load dplyr for the pipe operator:
library("dplyr")
# Let's take the agreeableness items, and gender:
ConsData <- bfi %>%
select(A1:A5, gender) %>%
na.omit # Let's remove missingness (otherwise use Estimator = "FIML)
# Define variables:
vars <- names(ConsData)[1:5]
# Model with Cholesky decompositon:
mod <- varcov(ConsData, vars = vars, type = "chol")
# Run model:
mod <- mod %>% runmodel
# Transform to GGM:
mod_trans <- transmod(mod, type = "ggm") %>% runmodel
# Note: runmodel often not needed
# Obtain thresholded GGM:
getmatrix(mod_trans, "omega", threshold = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.