From 5066a516e2a02f810f9a216ab15ae701e10dfe3a Mon Sep 17 00:00:00 2001 From: Tristan-Siegfried <129814507+Tristan-Siegfried@users.noreply.github.com> Date: Thu, 22 Jun 2023 20:34:25 -0500 Subject: [PATCH] Update formula.jl to include asinh (#67) * Update formula.jl to include asinh asinh transformation is parallel in R and Julia, so can treat it like exp and log transformations * Add asinh transformation test * Bump Version to 1.1.0 --- Project.toml | 2 +- src/formula.jl | 1 + test/glmerMod.jl | 11 +++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 296fa0e..9ba3408 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "JellyMe4" uuid = "19ac8677-9a15-4623-9afd-84acc6165ce7" authors = ["Phillip Alday "] -version = "1.0.1" +version = "1.1.0" [deps] CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597" diff --git a/src/formula.jl b/src/formula.jl index 34ce00d..bdc72d6 100644 --- a/src/formula.jl +++ b/src/formula.jl @@ -76,6 +76,7 @@ function convert_julia_to_r(f::StatsModels.FormulaTerm)::AbstractString formula = replace(formula, ":(log" => "(log") formula = replace(formula, ":(exp" => "(exp") + formula = replace(formula, ":(asinh" => "(asinh") # should we consider supporting division on the lhs? # what about nesting syntax on the rhs? # zscore won't work here because the operations within a formula are broadcast diff --git a/test/glmerMod.jl b/test/glmerMod.jl index d450b53..781af40 100644 --- a/test/glmerMod.jl +++ b/test/glmerMod.jl @@ -235,5 +235,16 @@ logistic(x) = 1 / (1 + exp(-x)) @rput jm @test fixef(jlmm) ≈ rcopy(R"fixef(jm)") end + @testset "asinh transformation" begin + dat = dataset(:verbagg) + + jlmm = fit(MixedModel, + @formula(r2 ~ 1 + asinh(anger) + gender + btype + situ + (1 | subj) + + (1 | item)), + dat, Bernoulli()) + jm = (jlmm, dat) + @rput jm + @test fixef(jlmm) ≈ rcopy(R"fixef(jm)") + end end end