Modifying compRelSEM for a specific reason

14 views
Skip to first unread message

Ritika Chokhani

unread,
Sep 11, 2025, 1:31:41 PM (5 days ago) Sep 11
to lavaan
Dear all, 

I want to calculate omega hierarchical and omega hierarchical subscale for a bifactor model that has been fit using categorical indicators and multiple imputations. The issue is that this bifactor model was fit using data I no longer have access to and it was fit in a way that 7 items had negative loadings on the general factor while the others had positive loadings. If I understand correctly, this would mess up the omega calculation.  I have access to the fitted lavaan.mi object.  So I need to adjust compRelSEM in a way that it flips the loadings for these seven items & then calculates the reliability. 


and add an extra argument 

compRelSEM_manual <- function(object, obs.var = TRUE, tau.eq = FALSE, ord.scale = TRUE,
                       config = character(0), shared = character(0),
                       higher = character(0),
                       return.total = FALSE, dropSingle = TRUE,
                       omit.factors = character(0),
                       omit.indicators = character(0),
                       omit.imps = c("no.conv","no.se"), return.df = TRUE, flip_items = NULL)


specify 

flip_items <- list(general = c("item1", "item2", "item3", "item4", "item5", "item6", "item7"))

and insert 

    ## --- Ensure row/colnames ---
    for (b in seq_along(LAMBDA)) {
      if (is.null(rownames(LAMBDA[[b]]))) rownames(LAMBDA[[b]]) <- lavNames(object, block = b, type = "ov")
      if (is.null(colnames(LAMBDA[[b]]))) colnames(LAMBDA[[b]]) <- lavNames(object, block = b, type = "lv")
    }
    
    if (!is.null(flip_items)) {
      for (b in seq_along(LAMBDA)) {
        for (fac in names(flip_items)) {
          item_idx <- which(rownames(LAMBDA[[b]]) %in% flip_items[[fac]])
          g_idx <- which(colnames(LAMBDA[[b]]) == fac)
          if (length(item_idx) > 0 && length(g_idx) > 0) {
            LAMBDA[[b]][item_idx, g_idx] <- -LAMBDA[[b]
[item_idx, g_idx]
          }
        }
      }
    }


in the code after it extracts lambda. However, using this gives me omega values for my general factor above 1 and omega total value of above 1 as well (when using return.total = TRUE).

Since I am not the greatest at understanding such complicated code, might anyone know what is going wrong and what I need to do within the compRelSEM hood to flip the loadings for some specified items on the general factor and obtain the omegas I need?

Thank you so much for your kind help. 


Reply all
Reply to author
Forward
0 new messages