Skip to content

Commit 1d9bc28

Browse files
Alexey StukalovMaximilian-Stefan-Ernst
authored andcommitted
improve docstrings for fit measures
1 parent 1d51d9a commit 1d9bc28

7 files changed

Lines changed: 59 additions & 16 deletions

File tree

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
"""
2-
AIC(sem_fit::SemFit)
2+
AIC(fit::SemFit)
33
4-
Return the akaike information criterion.
4+
Calculate the *AIC* ([*Akaike information criterion*](https://en.wikipedia.org/wiki/Akaike_information_criterion)).
5+
6+
# See also
7+
[`fit_measures`](@ref)
58
"""
6-
AIC(sem_fit::SemFit) = minus2ll(sem_fit) + 2nparams(sem_fit)
9+
AIC(fit::SemFit) = minus2ll(fit) + 2nparams(fit)
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
"""
2-
BIC(sem_fit::SemFit)
2+
BIC(fit::SemFit)
33
4-
Return the bayesian information criterion.
4+
Calculate the *BIC* ([*Bayesian information criterion*](https://en.wikipedia.org/wiki/Bayesian_information_criterion)).
5+
6+
# See also
7+
[`fit_measures`](@ref)
58
"""
6-
BIC(sem_fit::SemFit) = minus2ll(sem_fit) + log(nsamples(sem_fit)) * nparams(sem_fit)
9+
BIC(fit::SemFit) = minus2ll(fit) + log(nsamples(fit)) * nparams(fit)

src/frontend/fit/fitmeasures/RMSEA.jl

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,23 @@
11
"""
22
RMSEA(fit::SemFit)
33
4-
Return the RMSEA.
4+
Calculate the RMSEA ([*Root Mean Squared Error of Approximation*](https://meth.psychopen.eu/index.php/meth/article/download/2333/2333.html?inline=1#sec1)).
5+
6+
Uses the formula
7+
```math
8+
\\mathrm{RMSEA} = \\sqrt{\\frac{\\chi^2 - N_{\\mathrm{df}}}{N_{\\mathrm{obs}} * N_{\\mathrm{df}}}},
9+
```
10+
where *χ²* is the chi-squared statistic, ``N_{\\mathrm{df}}`` is the degrees of freedom,
11+
and ``N_{\\mathrm{obs}}`` is the (corrected) number of observations
12+
for the SEM model.
13+
14+
# See also
15+
[`fit_measures`](@ref), [`χ²`](@ref), [`dof`](@ref)
16+
17+
# Extended help
18+
19+
For multigroup models, the correction proposed by J.H. Steiger is applied
20+
(see [Steiger, J. H. (1998). *A note on multiple sample extensions of the RMSEA fit index*](https://doi.org/10.1080/10705519809540115)).
521
"""
622
function RMSEA end
723

src/frontend/fit/fitmeasures/chi2.jl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
"""
22
χ²(fit::SemFit)
33
4-
Return the χ² value.
4+
Calculate the *χ²* (*chi-square*) value for the `fit`.
5+
6+
The *χ²* is a test statistic for the SEM goodness-of-fit.
7+
It compares the *implied* covariance matrix of the SEM model
8+
with the *observed* covariance matrix.
9+
10+
# See also
11+
[`fit_measures`](@ref)
512
"""
613
χ²(fit::SemFit) = χ²(fit, fit.model)
714

src/frontend/fit/fitmeasures/dof.jl

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
"""
2-
dof(sem_fit::SemFit)
2+
dof(fit::SemFit)
33
dof(model::AbstractSem)
44
5-
Return the degrees of freedom.
5+
Get the *degrees of freedom* for the SEM model.
6+
7+
The *degrees of freedom* for the SEM with *N* observed variables is the difference
8+
between the number of non-redundant elements in the observed covariance matrix
9+
(*½N(N+1)*) and the number of model parameters, *q* ([`nparams(model)`](@ref nparams)).
10+
If the SEM also models the observed means, the formula becomes *½N(N+1) + N - q*.
11+
12+
# See also
13+
[`fit_measures`](@ref)
614
"""
715
function dof end
816

9-
dof(sem_fit::SemFit) = dof(sem_fit.model)
17+
dof(fit::SemFit) = dof(fit.model)
1018

1119
dof(model::AbstractSem) = n_dp(model) - nparams(model)
1220

src/frontend/fit/fitmeasures/minus2ll.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
"""
2-
minus2ll(sem_fit::SemFit)
2+
minus2ll(fit::SemFit)
33
4-
Return the negative 2* log likelihood.
4+
Calculate the *-2⋅log(likelihood(fit))*.
5+
6+
# See also
7+
[`fit_measures`](@ref)
58
"""
69
function minus2ll end
710

src/frontend/fit/fitmeasures/p.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
"""
2-
p(sem_fit::SemFit)
2+
p_value(fit::SemFit)
33
4-
Return the p value computed from the χ² test statistic.
4+
Calculate the *p*-value for the *χ²* test statistic.
5+
6+
# See also
7+
[`fit_measures`](@ref), [`χ²`](@ref)
58
"""
6-
p_value(sem_fit::SemFit) = ccdf(Chisq(dof(sem_fit)), χ²(sem_fit))
9+
p_value(fit::SemFit) = ccdf(Chisq(dof(fit)), χ²(fit))

0 commit comments

Comments
 (0)