|
1 | 1 | ### Terrence D. Jorgensen |
2 | 2 | ### - omegaCat() and deprecated functionality: Sunthud Pornprasertmanit |
3 | | -### Last updated: 6 February 2026 |
| 3 | +### Last updated: 10 February 2026 |
4 | 4 |
|
5 | 5 |
|
6 | 6 |
|
@@ -475,12 +475,6 @@ AVE <- function(object, obs.var = TRUE, omit.imps = c("no.conv","no.se"), |
475 | 475 | ##' |
476 | 476 | ##' **Multilevel Measurement Models**: |
477 | 477 | ##' |
478 | | - #TODO: incorporate `W=` details: |
479 | | -## multilevel SEMs, the syntax should include level-specific blocks, |
480 | | -## where the same composite name can be specified at both levels to calculate |
481 | | -## Lai's (2021) indices for observed-variable composites; otherwise, Geldhof |
482 | | -## et al.'s (2014) indices for level-specific latent composites |
483 | | - |
484 | 478 | ##' How to define reliability coefficients for scales employed in nested designs |
485 | 479 | ##' is an ongoing topic of methodological development, with some ongoing |
486 | 480 | ##' controversies about best practice when the target of measurement is the |
@@ -583,13 +577,13 @@ AVE <- function(object, obs.var = TRUE, omit.imps = c("no.conv","no.se"), |
583 | 577 | ##' (any indicator without a numeric `weight` is given a unit weight = 1). |
584 | 578 | ##' See **Details** and **Examples** about complicated CFAs (e.g., multilevel, |
585 | 579 | ##' higher-order, or bifactor). |
586 | | -##' @param return.total Only relevant for multidimensional CFAs, this `logical` |
| 580 | +##' @param return.total For multidimensional CFAs, this `logical` value |
587 | 581 | ##' indicates whether to return a final index for the reliability of a |
588 | 582 | ##' composite of all modeled indicators (labeled `.TOTAL.`). This is redundant |
589 | 583 | ##' whenever there is already a common factor indicated by all items (e.g., |
590 | 584 | ##' the general factor in a bifactor model). This argument is ignored when |
591 | 585 | ##' using the `W=` argument to specify composites (optionally with weights). |
592 | | -##' Setting a negative value (e.g., `-1` returns **only** the `.TOTAL.` |
| 586 | +##' Setting a negative value (e.g., `-1`) returns **only** the `.TOTAL.` |
593 | 587 | ##' composite reliability (i.e., excluding coefficients per factor). |
594 | 588 | ##' @param obs.var `logical` indicating whether to compute reliability |
595 | 589 | ##' using observed (co)variances to compute the denominator. Setting `FALSE` |
@@ -934,7 +928,6 @@ compRelSEM <- function(object, W = NULL, |
934 | 928 | ngroups <- lavInspect(object, "ngroups") |
935 | 929 | nLevels <- lavInspect(object, "nlevels") |
936 | 930 | nblocks <- ngroups*nLevels #FIXME: always true? |
937 | | - #FIXME: necessary in rewrite? return.total <- rep(return.total, nblocks) |
938 | 931 |
|
939 | 932 | ## extract parameter table |
940 | 933 | PT <- parTable(object) |
@@ -975,19 +968,25 @@ compRelSEM <- function(object, W = NULL, |
975 | 968 | if (return.total) { |
976 | 969 | ## loop over blocks to add a total score |
977 | 970 | for (b in 1:nblocks) { |
978 | | - ov.names <- lavNames(object, type = "ov.ind", block = b) |
979 | | - ind.idx <- unique(match(wPT$rhs, table = ov.names)) |
980 | | - totalPT <- wPT[ind.idx, ] |
981 | | - totalPT$lhs <- ".TOTAL." |
982 | | - if (return.total < 0L) { |
983 | | - ## only for the total composite |
984 | | - wPT <- totalPT |
985 | | - |
986 | | - ## add the total composite |
987 | | - } else wPT <- rbind(wPT, totalPT) |
988 | | - |
| 971 | + wPTb <- wPT[wPT$block == b, ] |
| 972 | + ov.names <- lavNames(object, type = "ov.ind", block = b) |
| 973 | + ind.idx <- unique(match(wPTb$rhs, table = ov.names)) |
| 974 | + totalPTb <- wPTb[ind.idx, ] |
| 975 | + totalPTb$lhs <- ".TOTAL." |
| 976 | + |
| 977 | + if (b == 1L) { |
| 978 | + totalPT <- totalPTb |
| 979 | + } else totalPT <- rbind(totalPT, totalPTb) |
989 | 980 | ## end loop over blocks |
990 | 981 | } |
| 982 | + |
| 983 | + if (return.total < 0L) { |
| 984 | + ## only the total composite |
| 985 | + wPT <- totalPT |
| 986 | + |
| 987 | + ## add the total composite |
| 988 | + } else wPT <- rbind(wPT, totalPT) |
| 989 | + |
991 | 990 | } |
992 | 991 | ## replace default integers with labels for groups |
993 | 992 | if (length(group.label) && is.integer(wPT$group)) { |
|
0 commit comments