From d4f70d475071505a769930d173e7e1c777fc302c Mon Sep 17 00:00:00 2001 From: Aaron Peikert Date: Fri, 24 Jun 2022 10:47:40 +0200 Subject: [PATCH 1/4] add DOI --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a7d9e4a39..ea15eeb1e 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,9 @@ # StructuralEquationModels.jl -| **Documentation** | **Build Status** | -|:-------------------------------------------------------------------------------:|:-----------------------------------------------------------------------------------------------:| -| [![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://structuralequationmodels.github.io/StructuralEquationModels.jl/) [![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://structuralequationmodels.github.io/StructuralEquationModels.jl/dev/) | [![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active) [![Github Action CI](https://github.com/StructuralEquationModels/StructuralEquationModels.jl/workflows/CI_extended/badge.svg)](https://github.com/StructuralEquationModels/StructuralEquationModels.jl/actions/) [![codecov](https://codecov.io/gh/StructuralEquationModels/StructuralEquationModels.jl/branch/main/graph/badge.svg?token=P2kjzpvM4V)](https://codecov.io/gh/StructuralEquationModels/StructuralEquationModels.jl) | +| **Documentation** | **Build Status** | Citation | +|:-------------------------------------------------------------------------------:|:-----------------------------------------------------------------------------------------------:|:-----------------------------------------------------------------------------------------------:| +| [![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://structuralequationmodels.github.io/StructuralEquationModels.jl/) [![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://structuralequationmodels.github.io/StructuralEquationModels.jl/dev/) | [![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active) [![Github Action CI](https://github.com/StructuralEquationModels/StructuralEquationModels.jl/workflows/CI_extended/badge.svg)](https://github.com/StructuralEquationModels/StructuralEquationModels.jl/actions/) [![codecov](https://codecov.io/gh/StructuralEquationModels/StructuralEquationModels.jl/branch/main/graph/badge.svg?token=P2kjzpvM4V)](https://codecov.io/gh/StructuralEquationModels/StructuralEquationModels.jl) | [![DOI](https://zenodo.org/badge/228649704.svg)](https://zenodo.org/badge/latestdoi/228649704) | + This is a package for Structural Equation Modeling. It is still *in development*. From 107dc0a432456521dc235e9edd955572e3a6f29f Mon Sep 17 00:00:00 2001 From: Aaron Peikert Date: Fri, 24 Jun 2022 10:50:21 +0200 Subject: [PATCH 2/4] add DOI to CFF file --- CITATION.cff | 1 + 1 file changed, 1 insertion(+) diff --git a/CITATION.cff b/CITATION.cff index f4f6b37d8..edb9d68cc 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -21,3 +21,4 @@ authors: repository-code: >- https://github.com/StructuralEquationModels/StructuralEquationModels.jl license: MIT +doi: 10.5281/zenodo.6719627 From 9ef40a64434b2fba5960702b7b00aa1679ae9b1b Mon Sep 17 00:00:00 2001 From: Aaron Peikert Date: Fri, 24 Jun 2022 14:01:51 +0200 Subject: [PATCH 3/4] use doi that resolves to latest version instead --- CITATION.cff | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CITATION.cff b/CITATION.cff index edb9d68cc..4d7ceb16b 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -21,4 +21,4 @@ authors: repository-code: >- https://github.com/StructuralEquationModels/StructuralEquationModels.jl license: MIT -doi: 10.5281/zenodo.6719627 +doi: 10.5281/zenodo.6719626 From 46a9ad81a1ac17ab1423a7f8d08f965267b2f8ce Mon Sep 17 00:00:00 2001 From: Andreas Brandmaier Date: Fri, 1 Jul 2022 11:11:09 +0200 Subject: [PATCH 4/4] created new loss function for square Hellinger distance --- src/loss/other/hellinger.jl | 61 +++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 src/loss/other/hellinger.jl diff --git a/src/loss/other/hellinger.jl b/src/loss/other/hellinger.jl new file mode 100644 index 000000000..cbdd171d5 --- /dev/null +++ b/src/loss/other/hellinger.jl @@ -0,0 +1,61 @@ +############################################################################################ +### Types +############################################################################################ +""" +Squared Hellinger distance loss. + +# Constructor + + Hellinger() + +# Examples +```julia + my_hellinger = Hellinger() +``` + +# Extended help +## Implementation +Subtype of `SemLossFunction`. +""" + +struct Hellinger <: SemLossFunction end + +using LinearAlgebra +import StructuralEquationModels: Σ, μ, obs_cov, obs_mean, objective! + +function objective!(hell::Hellinger, parameters, model::AbstractSem) + + # get model-implied covariance matrices + Σᵢ = Σ(imply(model)) + + # get observed covariance matrix + Σₒ = obs_cov(observed(model)) + + # get model-implued mean vector + μᵢ = μ(imply(model)) + + # get observed mean vector + μₒ = obs_mean(observed(model)) + + Sig = (Σᵢ + Σₒ)/2 + + + + # compute the objective + if isposdef(Symmetric(Σᵢ)) # is the model implied covariance matrix positive definite? + + loss = ( det(Σᵢ)^(1/4) * det(Σₒ)^(1/4) ) / sqrt(det(Sig)) + + if !isnothing(μᵢ) & !isnothing(μₒ) + μd = (μᵢ-μₒ) + loss = loss * exp(0.125 * (μd)*inv(Sig)*(μd)') + end + + loss = 1 - loss + + return loss + + else + return Inf + end +end \ No newline at end of file