Skip to content

Commit

Permalink
better testing of family for GLMM conversion (#66)
Browse files Browse the repository at this point in the history
* more robust familial testing

* extra link cleaning

* patch bump

* remove unused type param

* simplify

* Update src/merMod.jl
  • Loading branch information
palday authored Jul 4, 2023
1 parent 5066a51 commit 7e87c38
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "JellyMe4"
uuid = "19ac8677-9a15-4623-9afd-84acc6165ce7"
authors = ["Phillip Alday <[email protected]>"]
version = "1.1.0"
version = "1.1.1"

[deps]
CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597"
Expand Down
10 changes: 5 additions & 5 deletions src/glmerMod.jl
Original file line number Diff line number Diff line change
Expand Up @@ -151,18 +151,18 @@ function sexp(::Type{RClass{:glmerMod}},
# we construct this piece-by-piece because this keeps the warnings
# and everything in sync
supported = ("Bernoulli", "Binomial", "Poisson")
if family in ("Bernoulli", "Binomial")
if distribution <: Union{Bernoulli,Binomial}
family = "binomial"
elseif family == "Poisson"
elseif distribution <: Poisson
family = "poisson"
elseif family in ("Gamma", "Gaussian", "InverseGaussian")
elseif distribution <: Union{Gamma,Gaussian,InverseGaussian}
throw(ArgumentError("GLMMs with dispersion parameters are known to give incorrect results in MixedModels.jl (see PR#291), aborting."))
else
throw(ArgumentError("Family $family is not supported"))
end

urlink = string(Link(m.resp))
link = lowercase(replace(urlink, "Link()" => ""))
link = lowercase(replace(replace(urlink, "Link()" => ""), "GLM." => ""))

link in ["logit", "probit", "cauchit",
"log", "identity", "inverse", "sqrt",
Expand All @@ -184,7 +184,7 @@ function sexp(::Type{RClass{:glmerMod}},
# should we check for PooledArray? brings in another dependency...
if !(jellyme4_data[!, lhs.sym] isa CategoricalArray)
@warn "Response was not categorical, converting in place"
categorical!(jellyme4_data, [lhs.sym])
categorical!(jellyme4_data, lhs.sym)
end
end
formula = convert_julia_to_r(m.formula)
Expand Down
2 changes: 1 addition & 1 deletion src/merMod.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ function sexp(::Type{RClass{:merMod}}, x::Tuple{Union{DataFrame,ColumnTable},Mix
throw(ArgumentError("The order in your Tuple is reversed. It should be (Model, Data)"))
end

sexpclass(x::Tuple{Union{DataFrame,ColumnTable},MixedModel}) where {T} = RClass{:merMod}
sexpclass(x::Tuple{Union{DataFrame,ColumnTable},MixedModel}) = RClass{:merMod}

2 comments on commit 7e87c38

@palday
Copy link
Owner Author

@palday palday commented on 7e87c38 Jul 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/86845

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.1.1 -m "<description of version>" 7e87c38933560fac0854fb39f401b0d98459bf05
git push origin v1.1.1

Please sign in to comment.