GAMLj - plotting Random Effects in generalized mixed models

Everything related to the development of modules in jamovi
shabde
Posts: 16
Joined: Thu Aug 29, 2019 7:53 pm

GAMLj - plotting Random Effects in generalized mixed models

Post by shabde »

I am using Generalized Mixed Models in GAMLj.
I want to plot interactions between a metric and a binary predictor when using a Logit link.
This works in principle, but as soon as my model contains a binary predictor, I cannot plot Random Effects any more. I always get the error "contrasts apply only to factors". Since the same is very well possible in a normal mixed model, I would guess that this is a bug - at least when plotting the logit ("linear predictor) on Y, also plotting random effects should always be possible.
User avatar
mcfanda@gmail.com
Posts: 457
Joined: Thu Mar 23, 2017 9:24 pm

Re: GAMLj - plotting Random Effects in generalized mixed mod

Post by mcfanda@gmail.com »

Hi shabde
could you post an example of the issue so I can reproduce it and fix it?
thanks
mc
shabde
Posts: 16
Joined: Thu Aug 29, 2019 7:53 pm

Re: GAMLj - plotting Random Effects in generalized mixed mod

Post by shabde »

Hi,
sorry my late reply, but I was a bit busy...
You can see an example in the attached file, but it also appears with other multi-level datasets.

So I have a dichotomous variable "Hall" which is a median split from the continuous variable "Halligkeit".
I have cluster sampling (variable "subject") , so I am using Mixed Models to predict both by T30 (Continuous) and Position (Binary/Factor).

As you can see in the output, in the continuous case ("Halligkeit"), I am able to plot fixed and random effects from the estimated model as charme. In the binary case ("Hall" with LogitLink), I am only able to plot random effects when I take "Position" out of the model. If I leave it in the model, I receive an error ("contrasts apply only to factors"),even when I just want to Plot T30 against Hall (actually I want to plot the interaction, but even the main effect fails). Apart from that, model estimation etc. works. So there seems to be a bug in the plot function for random effects. Or am I missing something?

Cheers,
Shabde
Attachments
gamljprobdemo.omv
(87.4 KiB) Downloaded 865 times
User avatar
mcfanda@gmail.com
Posts: 457
Joined: Thu Mar 23, 2017 9:24 pm

Re: GAMLj - plotting Random Effects in generalized mixed mod

Post by mcfanda@gmail.com »

Hi
I think you found a bug. I'm going to fix it within this week,
thanks
User avatar
mcfanda@gmail.com
Posts: 457
Joined: Thu Mar 23, 2017 9:24 pm

Re: GAMLj - plotting Random Effects in generalized mixed mod

Post by mcfanda@gmail.com »

In the meantime, you can use a dataset in which "Hall" is coded (not computed) and it should work
User avatar
mcfanda@gmail.com
Posts: 457
Joined: Thu Mar 23, 2017 9:24 pm

Re: GAMLj - plotting Random Effects in generalized mixed mod

Post by mcfanda@gmail.com »

version 2.0.2 should fix this issue. It's out
User avatar
MAgojam
Posts: 421
Joined: Thu Jun 08, 2017 2:33 pm
Location: Parma (Italy)

Re: GAMLj - plotting Random Effects in generalized mixed mod

Post by MAgojam »

mcfanda@gmail.com wrote:version 2.0.2 should fix this issue. It's out
Hi, Marcello.

[SO: Win10pro (Ita), jamovi: 1.2.2.0, GAMLj: 2.0.0]

I wanted to point out that at the moment jamovi library, sees and updates GAMLj to version 2.0.1.
To test version 2.0.2 (it works well) I downloaded it from github and compiled locally from RStudio.
Thanks for your work of updating and improving the module.

Cheers,
Maurizio
User avatar
mcfanda@gmail.com
Posts: 457
Joined: Thu Mar 23, 2017 9:24 pm

Re: GAMLj - plotting Random Effects in generalized mixed mod

Post by mcfanda@gmail.com »

Well, thanks. However, I noticed that there is a bug in lme4::predict.glmer such that if you plot the random effects of a continuous variable estimated in a model with also a categorical variable, the plot of the random effects is meaningless. This is because lme4::predict.glmer() predicted values cannot be computed keeping constant the other variables in the model (as the other R predict() functions do). I'M working on it now
User avatar
mcfanda@gmail.com
Posts: 457
Joined: Thu Mar 23, 2017 9:24 pm

Re: GAMLj - plotting Random Effects in generalized mixed mod

Post by mcfanda@gmail.com »

The issue comes about when the categorical variable is not balanced across groups of the cluster variable
shabde
Posts: 16
Joined: Thu Aug 29, 2019 7:53 pm

Re: GAMLj - plotting Random Effects in generalized mixed mod

Post by shabde »

Thank you very much for fixing the issue in 2.0.2 - some of my students were very happy with finally being able to see their random effects also in the plot! :relaxed:
Thankfully, I just donated via Paypal 50 Dollars to you guys, because this is really a great feature that only few GUI-based software packages do so far! Congrats!

One other question, because I only just noticed it:
Is there a specific statistical reason that there is no LRT test for random effects in the GLMM, while in normal mixed model it is possible? Because I would think that in principle, LRT should also be feasible for GLMMs.
Post Reply