strengejacke / ggeffects

Estimated Marginal Means and Marginal Effects from Regression Models for ggplot2
https://strengejacke.github.io/ggeffects
Other
543 stars 35 forks source link

ggpredict with gamlss and re : unable to compute vcov matrix of predictions #224

Open ghost opened 3 years ago

ghost commented 3 years ago

Dear all

I am trying to plot estimates and CI from a mixed model fitted with gamlss (data attached):

synchro.sp5.txt

The model has random effects fitted with re, so unsurprisingly the computation of the vcov matrix of predictions becomes rather uneasy :

beinf=gamlss(sync ~re(fixed=~guilde2*(saison+nb),random=~1|espece),family=BEINF,data=synchro.sp5) pred2=ggpredict(beinf,terms=c("saison","guilde2")) This code returns the following :

new prediction 
Could not compute variance-covariance matrix of predictions. No confidence intervals are returned.

Is there any meaningful workaround to get meaningful CI in this case, perhaps working through bootstraping or changing the vcov arguments, or any kind of code trick? I do not feel confident enough with the underlying stats and with the way ggpredict generates its outputs to just dig and guess something myself.

Thanks!!

aja2182 commented 2 years ago

I am getting the same message when I pipe to plot() and, in turn, I am receiving a plot without confidence intervals. I figured I would share what I am trying to do. I've fit a multilevel model and I am trying to plot the cross-level interaction term of a lower-level binary variable and upper-level continuous variable in a model that, in addition to individuals, includes two random effects (state-year and state). Additionally, I let the slope of my lower-level predictor vary across state-year and state. I've tried to reproduce what I am doing and it seems like the issue - at least for me - occurs anytime I include more than one random effect, i.e., it also occurs when I have (1| state) + (1| year). I'm a novice so I can't really tell if what I am doing is related to modeling or using the program (but I do know, analytically, it makes sense to include a random effect for state and year and ideally have a nested term for year/state). Thanks so much for this amazing package :)

aja2182 commented 2 years ago

Update: This now seems to work! I'm not sure how or why though :)

olvic commented 2 years ago

Any luck on this? Having the same error code and can't figure out how to get around it.

aja2182 commented 2 years ago

did you figure this out? It is likely a result of issues w/ convergence.

what does your model look like? any way for me to reproduce this? lmk

olvic commented 2 years ago

Hi, thanks! I should have updated here when I found the issue. I think the problem was that I have a multiple predictor variables as well as a control. whenever I had a control, all predictors had to have a value of "control". I therefore had redundancy in the model. Fixed it by merging the predictors into a single parameter and doing emmeans / contrasts. Works now! See this stackexchange: https://stats.stackexchange.com/questions/562761/using-mixed-models-is-there-a-way-to-explicitly-ignore-one-pair-of-crossed-fixe

aja2182 commented 2 years ago

That's great, and great to know too!