Skip to content

Commit

Permalink
Merged notes additional fit measures (#147)
Browse files Browse the repository at this point in the history
* merged notes

* merged more notes

* change the layout of multiple table notes

---------

Co-authored-by: Julius Pfadt <[email protected]>
  • Loading branch information
LSLindeloo and juliuspfadt authored Sep 12, 2023
1 parent fb24d76 commit 25627c6
Showing 1 changed file with 36 additions and 20 deletions.
56 changes: 36 additions & 20 deletions R/sem.R
Original file line number Diff line number Diff line change
Expand Up @@ -1100,6 +1100,7 @@ checkLavaanModel <- function(model, availableVars) {
fmli <- lapply(modelContainer[["results"]][["object"]], .fitMeasures)

# Fit indices
cfi_t_footnote <- ""
fitin[["index"]] <- c(
gettext("Comparative Fit Index (CFI)"),
gettext("T-size CFI"),
Expand All @@ -1113,22 +1114,29 @@ checkLavaanModel <- function(model, availableVars) {
)
if (length(options[["models"]]) == 1) {
fitin[["value"]] <- fmli[[1]][c("cfi", "cfi.t", "tli", "nnfi", "nfi", "pnfi", "rfi", "ifi", "rni")]
cfi_t_footnote <- gettextf("The T-size equivalents of the conventional CFI cut-off values (poor < 0.90 < fair < 0.95 < close) are <b>poor < %1$s < fair < %2$s < close</b> for model: %3$s",
round(fmli[[1]]["cfi.t.e90"], 3),
round(fmli[[1]]["cfi.t.e95"], 3),
options[["models"]][[1]][["name"]])
cfi_t_footnote <- paste0(cfi_t_footnote,
gettextf("T-size CFI is computed for <i>%1$s = 0.05</i>. The T-size equivalents of the
conventional CFI cut-off values (poor < 0.90 < fair < 0.95 < close) are <b>poor
< %2$s < fair < %3$s < close</b> for model: %4$s.", "\u03B1",
round(fmli[[1]]["cfi.t.e90"], 3),
round(fmli[[1]]["cfi.t.e95"], 3),
options[["models"]][[1]][["name"]]))
fitin$addFootnote(cfi_t_footnote)
} else {
for (i in seq_along(options[["models"]])) {
fitin[[paste0("value_", i)]] <- fmli[[i]][c("cfi", "cfi.t", "tli", "nnfi", "nfi", "pnfi", "rfi", "ifi", "rni")]
cfi_t_footnote <- gettextf("The T-size equivalents of the conventional CFI cut-off values (poor < 0.90 < fair < 0.95 < close) are <b>poor < %1$s < fair < %2$s < close</b> for model: %3$s",
round(fmli[[i]]["cfi.t.e90"], 3),
round(fmli[[i]]["cfi.t.e95"], 3),
options[["models"]][[i]][["name"]])
fitin$addFootnote(cfi_t_footnote)

cfi_t_footnote <- paste0(cfi_t_footnote,
gettextf(" The T-size equivalents of the conventional CFI cut-off values
(poor < 0.90 < fair < 0.95 < close) are <b>poor < %1$s < fair < %2$s <
close</b> for model: %3$s.",
round(fmli[[i]]["cfi.t.e90"], 3),
round(fmli[[i]]["cfi.t.e95"], 3),
options[["models"]][[i]][["name"]]))

}
fitin$addFootnote(cfi_t_footnote)
}
fitin$addFootnote(gettextf("T-size CFI is computed for <i>%s = 0.05</i>", "\u03B1"))

# information criteria
if (!options$estimator %in% c("dwls", "gls", "wls", "uls")) {
Expand All @@ -1151,6 +1159,7 @@ checkLavaanModel <- function(model, availableVars) {


# other fitmeasures
rmsea_t_footnote <- ""
fitot[["index"]] <- c(
gettext("Root mean square error of approximation (RMSEA)"),
gettextf("RMSEA 90%% CI lower bound"),
Expand All @@ -1167,23 +1176,30 @@ checkLavaanModel <- function(model, availableVars) {
if (length(options[["models"]]) == 1) {
fitot[["value"]] <- fmli[[1]][c("rmsea", "rmsea.ci.lower", "rmsea.ci.upper", "rmsea.pvalue", "rmsea.t",
"srmr", "cn_05", "cn_01", "gfi", "mfi", "ecvi")]
rmsea_t_footnote <- gettextf("The T-size equivalents of the conventional RMSEA cut-off values (close < 0.05 < fair < 0.08 < poor) are <b>close < %1$s < fair < %2$s < poor</b> for model: %3$s",
round(fmli[[1]]["rmsea.t.e05"], 3),
round(fmli[[1]]["rmsea.t.e08"], 3),
options[["models"]][[1]][["name"]])
rmsea_t_footnote <- paste0(rmsea_t_footnote,
gettextf("T-size RMSEA is computed for <i>%1$s = 0.05</i>. The T-size equivalents of the
conventional RMSEA cut-off values (close < 0.05 < fair < 0.08 < poor) are
<b>close < %2$s < fair < %3$s < poor</b> for model: %4$s.", "\u03B1",
round(fmli[[1]]["rmsea.t.e05"], 3),
round(fmli[[1]]["rmsea.t.e08"], 3),
options[["models"]][[1]][["name"]]))
fitot$addFootnote(rmsea_t_footnote)
} else {
for (i in seq_along(options[["models"]])) {
fitot[[paste0("value_", i)]] <- fmli[[i]][c("rmsea", "rmsea.ci.lower", "rmsea.ci.upper", "rmsea.pvalue", "rmsea.t",
"srmr", "cn_05", "cn_01", "gfi", "mfi", "ecvi")]
rmsea_t_footnote <- gettextf("The T-size equivalents of the conventional RMSEA cut-off values (close < 0.05 < fair < 0.08 < poor) are <b>close < %1$s < fair < %2$s < poor</b> for model: %3$s",
round(fmli[[i]]["rmsea.t.e05"], 3),
round(fmli[[i]]["rmsea.t.e08"], 3),
options[["models"]][[i]][["name"]])
fitot$addFootnote(rmsea_t_footnote)

rmsea_t_footnote <- paste0(rmsea_t_footnote,
gettextf(" The T-size equivalents of the conventional RMSEA cut-off values
(close < 0.05 < fair < 0.08 < poor) are <b>close < %1$s < fair < %2$s
< poor</b> for model: %3$s.",
round(fmli[[i]]["rmsea.t.e05"], 3),
round(fmli[[i]]["rmsea.t.e08"], 3),
options[["models"]][[i]][["name"]]))

}
fitot$addFootnote(rmsea_t_footnote)
}
fitot$addFootnote(gettextf("T-size RMSEA is computed for <i>%s = 0.05</i>", "\u03B1"))
}

.semRsquared <- function(modelContainer, dataset, options, ready) {
Expand Down

0 comments on commit 25627c6

Please sign in to comment.