I’ve been working on a RCall compatibility for MixedModels <=> lme4 in my package JellyMe4 (it’s on the Julia registry). The latest release won’t move glmer
to GeneralizedMixedModel
but should be able to move Bernoulli models in the other direction (and will preserve contrasts). The funny thing there is that I’m able to reproduce @laut 's fit that way:
julia> using RCall, JellyMe4
[ Info: Precompiling RCall [6f49c342-dc21-5d91-9882-a32aef131414]
[ Info: Precompiling JellyMe4 [19ac8677-9a15-4623-9afd-84acc6165ce7]
julia> model = (m, nonzero);
julia> @rput model;
[ Info: contrasts on interaction terms are assumed to decompose into products of contrasts on the first-order terms
[ Info: (if you don't know what that means, you're probably fine)
┌ Warning: Some accuracy is lost in translation for GLMMs. This is fine with plotting, but proceed with caution for inferences.
│ You can try letting the model "reconverge" in lme4 with
│ update(model, control=glmerControl(optimizer="nloptwrap", calc.derivs=FALSE)).
└ @ JellyMe4 ~/.julia/packages/JellyMe4/Hupt7/src/glmerMod.jl:144
[ Info: lme4 handles deviance for GLMMs differently than MixedModels.jl
[ Info: for the correct comparison, examine -2*logLik(RModel) and deviance(JuliaModel)
julia> R"summary(model)"
RObject{VecSxp}
Generalized linear mixed model fit by maximum likelihood (Laplace
Approximation) [glmerMod]
Family: binomial ( logit )
Formula: Survived ~ 1 + Age + Sex + Age:Sex + (1 | Class)
Data: jellyme4_data
Control: glmerControl(optimizer = "nloptwrap", optCtrl = list(maxeval = 1),
calc.derivs = FALSE)
AIC BIC logLik deviance df.resid
49.0 54.9 -19.5 39.0 19
Scaled residuals:
Min 1Q Median 3Q Max
-2.0631 -0.7030 0.5001 0.7373 2.1385
Random effects:
Groups Name Variance Std.Dev.
Class (Intercept) 0.4006 0.6329
Number of obs: 24, groups: Class, 4
Fixed effects:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 1.2618 0.9218 1.369 0.1710
AgeChild -0.1235 1.4687 -0.084 0.9330
SexMale -2.6101 1.2214 -2.137 0.0326 *
AgeChild:SexMale 1.8948 1.9781 0.958 0.3381
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Correlation of Fixed Effects:
(Intr) AgChld SexMal
AgeChild -0.552
SexMale -0.666 0.416
AgChld:SxMl 0.411 -0.728 -0.617
julia> m
Generalized Linear Mixed Model fit by maximum likelihood (nAGQ = 1)
Survived ~ 1 + Age + Sex + Age & Sex + (1 | Class)
Distribution: Bernoulli{Float64}
Link: LogitLink()
Deviance: 2210.0511
Variance components:
Column Variance Std.Dev.
Class (Intercept) 37.72355 6.14195
Number of obs: 24; levels of grouping factors: 4
Fixed-effects parameters:
─────────────────────────────────────────────────────────────────
Estimate Std.Error z value P(>|z|)
─────────────────────────────────────────────────────────────────
(Intercept) 1.26179 3.29347 0.383119 0.7016
Age: Child -0.123528 3.25191 -0.0379863 0.9697
Sex: Male -2.61011 1.45291 -1.79647 0.0724
Age: Child & Sex: Male 1.89476 4.19518 0.451653 0.6515
─────────────────────────────────────────────────────────────────
One thing to note is that weights don’t work in the current JellyMe4 release, so those are getting lost in translation. This suggests that something is happening with the weights in your bad run…