easystats / easystats/effectsize
Add support for dynamic interpretation of CFI/RMSEA/SRMR
Open
Nobody has claimed this yet.
enhancement 🔥
low priority 😴
- Dominant language
- R
- Stars
- 353
- Forks
- 25
- Avg merge
- 9h 21m
- Merged PRs (30d)
- 1
Description
https://github.com/melissagwolf/dynamic/issues/3
get_dynamic <- function(model, type, level, rate = c(0.05, 0.10), verbose = TRUE) {
type <- match.arg(type, c("CFA.one", "CFA.multi"))
stopifnot(rate %in% c(0.05, 0.10))
rate <- rate[1] * 100
insight::check_if_installed("dynamic")
if (verbose) message("Simulating...")
foo <- switch (type,
CFA.one = dynamic::cfaOne,
CFA.multi = dynamic::cfaHB)
dynamic_res <- foo(model)[[c(2,1)]]
if (nrow(dynamic_res)/2 < level) {
warning()
level <- nrow(dynamic_res)/2
}
th <- dynamic_res[sprintf("Level %d: %d/%d", level, 100-rate, rate),]
th <- lapply(th, as.numeric)
th$CFI <- effectsize::rules(th$CFI, c("poor", "satisfactory"), right = FALSE)
th$RMSEA <- effectsize::rules(th$RMSEA, c("satisfactory", "poor"))
th$SRMR <- effectsize::rules(th$SRMR, c("satisfactory", "poor"))
th
}
dat <- lavaan::HolzingerSwineford1939
lavmod <- "F1 =~ x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9"
fit <- lavaan::cfa(lavmod,dat)
rules <- get_dynamic(fit, type = "CFA.one", level = 3L)
#> Simulating...
effectsize::interpret(
lavaan::fitMeasures(fit, "CFI"), rules = rules$CFI
)
#> cfi
#> "poor"
#> (Rules: Custom rules)
effectsize::interpret(
lavaan::fitMeasures(fit, "RMSEA"), rules = rules$RMSEA
)
#> rmsea
#> "poor"
#> (Rules: Custom rules)
effectsize::interpret(
lavaan::fitMeasures(fit, "SRMR"), rules = rules$SRMR
)
#> srmr
#> "poor"
#> (Rules: Custom rules)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the issue's get_dynamic example and the effectsize::interpret and effectsize::rules entry points; review how the package currently accepts custom rules for CFI, RMSEA, and SRMR. Compare the demonstrated dynamic::cfaOne and dynamic::cfaHB results with the existing interpretation behavior. Done means these three fit measures can use the dynamically generated thresholds shown in the example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- data
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100