2
$\begingroup$

I want to predict the relationship between the number of groups a person belongs to and their overall well-being (totalwell). However, I would like to consider the possibility that a person could belong to numerous groups of low quality. To address this, I intend to use participant MapID and group_quality as random effects, while using the number of groups a person belongs to as the predictor and total well-being as the outcome variable.

I have this dataset:

 MapID CircleID TotalNumberofCircles totalwell group_quality
   <dbl>    <int>                <dbl>     <dbl>         <dbl>
 1  1381        1                    5      4.93          8.67
 2  1381        2                    5      4.93          2.67
 3  1381        3                    5      4.93         10   
 4  1381        4                    5      4.93          7.67
 5  1381        5                    5      4.93          5.33
 6  1391        1                    7      4.53          9   
 7  1391        2                    7      4.53          7   
 8  1391        3                    7      4.53          5   
 9  1391        4                    7      4.53          8   
10  1391        6                    7      4.53          7   
# ... with 190 more rows
> 

And this is the model I'd like to run:

ctrl <- lmerControl(optimizer = "Nelder_Mead", optCtrl = list(maxfun = 100))
MLM <- lmer(totalwell ~ CircleID + (1 | MapID:group_quality), data = df, control = ctrl)

And I'm getting the following convergence issues. Can anyone help me out here? Is there a problem with how my data is structured?

> ctrl <- lmerControl(optimizer = "Nelder_Mead", optCtrl = list(maxfun = 100))
> MLM <- lmer(totalwell ~ CircleID + (1 | MapID:group_quality), data = df, control = ctrl)
Warning messages:
1: In (function (fn, par, lower = rep.int(-Inf, n), upper = rep.int(Inf,  :
  failure to converge in 100 evaluations
2: In optwrap(optimizer, devfun, getStart(start, rho$pp), lower = rho$lower,  :
  convergence code 4 from Nelder_Mead: failure to converge in 100 evaluations
3: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
  Model failed to converge with max|grad| = 0.237603 (tol = 0.002, component 1)
4: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
  Model is nearly unidentifiable: very large eigenvalue
 - Rescale variables? 

EDIT!!

Okay so I have since restructured the model and this is what I'm trying to run:

MLM <- lmer(totalwell ~ CircleID + (1 + group_quality | MapID), 
            data = df)

and my fit is now singular

> MLM <- lmer(totalwell ~ CircleID + (1 + group_quality | MapID), 
+             data = df)
boundary (singular) fit: see help('isSingular')
> 

I've tried simplifying the model by taking out group_quality, and just holding Map ID as the only random effect. but this didn't work. In fact, it failed to converge when I took out group_quality

I'm wondering if perhaps I could run a bayesian analysis instead or if maybe I could use a different kind of model?

EDIT #2: I have since been trying this model instead, but still no luck with fixing the singular fit:

MLM <- lmer(totalwell ~ TotalNumberofCircles + (1 + group_quality | CircleID) + (1| MapID), 
        data = df)
$\endgroup$

1 Answer 1

0
$\begingroup$

The most obvious issue I can see here is that your random effects coding doesn't make a lot of sense. Remember that random effects are clusters which means they will be factors. Your group quality variable is numeric which is already a problem, but you have nested it as a random effect within MapID, which also doesn't make sense.

If group quality varies within subjects, it should be modeled like this:

MLM <- lmer(totalwell ~ CircleID + (1 + group_quality | MapID), 
            data = df)

Whether your include other controls into that model is up to how it converges, so I leave that up to you.

$\endgroup$
6
  • $\begingroup$ Great thank you! group quality does vary within ps so that makes a lot more sense. The model converges successfully but the fit is now singular - do you have any tips for getting around this? I've tried simplifying the model but that hasn't seemed to have worked. $\endgroup$
    – Tessa
    Commented Mar 26, 2023 at 4:28
  • $\begingroup$ If you can edit your question to show what steps you took, I can maybe provide some help. Generally speaking, singular fits often arise when the random effects structure is too complex, but it can also be due to some misspecification. You can also try those controls you already added to see if that helps any. $\endgroup$ Commented Mar 26, 2023 at 4:32
  • $\begingroup$ Hi Shawn- thank you for your assistance :) I've tried editing the question. Any help is greatly appreciated! $\endgroup$
    – Tessa
    Commented Mar 26, 2023 at 4:51
  • $\begingroup$ CircleID should be a factor right? It's coded as an integer in your data, but not sure if that will fix your issue. How many participants make up MapID? $\endgroup$ Commented Mar 26, 2023 at 5:15
  • $\begingroup$ I have 75 MapIDs (these are people in the experiment). Each person has a different number of groups which is Circle ID. I think I have made a mistake and my fixed effect should be "total number of circles" and this can differ between participants. I think Circle ID should be a random effect as it varies within ps, and each circle can have different level of group quality. So I have restructured my model (see edits ). However, I'm having the same issues with singular fit. But thankfully no more convergence issues. $\endgroup$
    – Tessa
    Commented Mar 27, 2023 at 4:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.