Skip to content

Commit b60fd72

Browse files
Alexey Stukalovalyst
authored andcommitted
improve docstrings for fit measures
1 parent 1842135 commit b60fd72

7 files changed

Lines changed: 32 additions & 16 deletions

File tree

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
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)).
55
"""
6-
AIC(sem_fit::SemFit) = minus2ll(sem_fit) + 2nparams(sem_fit)
6+
AIC(fit::SemFit) = minus2ll(fit) + 2nparams(fit)
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
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)).
55
"""
6-
BIC(sem_fit::SemFit) = minus2ll(sem_fit) + log(nsamples(sem_fit)) * nparams(sem_fit)
6+
BIC(fit::SemFit) = minus2ll(fit) + log(nsamples(fit)) * nparams(fit)

src/frontend/fit/fitmeasures/RMSEA.jl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
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+
\\mathrm{RMSEA} = \\sqrt{\\frac{\\chi^2 - N_{\\mathrm{df}}}{N_{\\mathrm{obs}} * N_{\\mathrm{df}}}},
7+
``
8+
where `χ²` is the chi-squared statistic, `df` is the degrees of freedom, and `N_obs` is the number of observations
9+
for the SEM model.
510
"""
611
function RMSEA end
712

813
RMSEA(fit::SemFit) = RMSEA(fit, fit.model)
914

10-
RMSEA(fit::SemFit, model::AbstractSemSingle) = RMSEA(dof(fit), χ²(fit), nsamples(fit))
15+
RMSEA(fit::SemFit, model::AbstractSemSingle) =
16+
RMSEA(dof(fit), χ²(fit), nsamples(fit))
1117

1218
RMSEA(fit::SemFit, model::SemEnsemble) =
1319
sqrt(length(model.sems)) * RMSEA(dof(fit), χ²(fit), nsamples(fit))

src/frontend/fit/fitmeasures/chi2.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
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.
59
"""
610
χ²(fit::SemFit) = χ²(fit, fit.model)
711

src/frontend/fit/fitmeasures/dof.jl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
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 model with *N* observed variables
8+
is the difference between the number of parameters
9+
required to define the *N×N* covariance matrix (*½N(N+1)*)
10+
(plus *N* parameters for the observed means vector, if present),
11+
and the number of model parameters, [`nparams(model)`](@ref nparams).
612
"""
713
function dof end
814

9-
dof(sem_fit::SemFit) = dof(sem_fit.model)
15+
dof(fit::SemFit) = dof(fit.model)
1016

1117
dof(model::AbstractSem) = n_dp(model) - nparams(model)
1218

src/frontend/fit/fitmeasures/minus2ll.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
minus2ll(sem_fit::SemFit)
33
4-
Return the negative 2* log likelihood.
4+
Calculate the *-2log(likelihood(fit))*.
55
"""
66
function minus2ll end
77

src/frontend/fit/fitmeasures/p.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
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.
55
"""
6-
p_value(sem_fit::SemFit) = ccdf(Chisq(dof(sem_fit)), χ²(sem_fit))
6+
p_value(fit::SemFit) = ccdf(Chisq(dof(fit)), χ²(fit))

0 commit comments

Comments
 (0)