Skip to content

Commit c63ca4c

Browse files
refactor RMSEA
1 parent 618e2df commit c63ca4c

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

src/frontend/fit/fitmeasures/RMSEA.jl

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,20 @@ function RMSEA end
77

88
RMSEA(fit::SemFit) = RMSEA(fit, fit.model)
99

10-
RMSEA(fit::SemFit, model::AbstractSemSingle) = RMSEA(dof(fit), χ²(fit), nsamples(fit))
10+
function RMSEA(fit::SemFit, model::AbstractSemSingle)
11+
check_uniform_lossfun(model)
12+
return RMSEA(dof(fit), χ²(fit), nsamples(fit)-dof_correction(model.loss.functions[1]))
13+
end
1114

12-
RMSEA(fit::SemFit, model::SemEnsemble) =
13-
sqrt(length(model.sems)) * RMSEA(dof(fit), χ²(fit), nsamples(fit))
15+
function RMSEA(fit::SemFit, model::SemEnsemble)
16+
check_single_lossfun(model; throw_error = true)
17+
n = nsamples(fit)-model.n*dof_correction(model.sems[1].loss.functions[1])
18+
return sqrt(length(model.sems)) * RMSEA(dof(fit), χ²(fit), n)
19+
end
1420

15-
function RMSEA(dof, chi2, nsamples)
16-
rmsea = (chi2 - dof) / (nsamples * dof)
17-
rmsea > 0 ? nothing : rmsea = 0
21+
function RMSEA(dof, chi2, c)
22+
rmsea = (chi2 - dof) / (c * dof)
23+
rmsea = rmsea > 0 ? rmsea : 0
1824
return sqrt(rmsea)
1925
end
26+

0 commit comments

Comments
 (0)