# singular fit issue due to data structure in mixed regression?

I am trying to analyse the effect of agreement with various items and respective sentiment towards these items on election results. I have a probability describing how much the parties agree with the item (itemresponse_mean) and a continuous variable describing the sentiment towards this item ranging from -1 to 1 (itemsentiment_mean) at different points in time as this is a longitudinal dataset. However, I only have the election results from one election.

This is how the data is currently structured:

group party countrycode votesPercent item_name itemresponse_mean itemsentiment_mean yearmonth
4    17           1         8.90    Item15         0.2762430         -0.2425000   2014-11
7    39           1         7.60    Item15         0.4013767          0.8180000   2014-10
7    64           1         7.57    Item15         0.7110057          0.3647500   2014-05
7    64           1         7.57    Item15         0.3623462          0.0000000   2014-06
7    64           1         7.57    Item15         0.3845907         -0.0640000   2014-07
7    64           1         7.57    Item15         0.2293034          0.3776667   2014-09
7    64           1         7.57    Item15         0.4166525          0.1258000   2014-10
7    64           1         7.57    Item15         0.7923941          0.1780000   2014-12
8   112           1        13.73    Item15         0.2636054          0.4770000   2014-05
8   112           1        13.73    Item15         0.5130956          0.5933333   2014-08


I have 12 groups, around 190 parties and 15 different items. As you can see in the above example, the data is uneven across Items and month.

Basically I want to run a mixed regression to determine the effect of the adherence to the topics and their respective sentiments for the election results. I expect there to be a different effect for the groups and items. This is why I want to use a mixed regression model to account for this difference.

This is the code I have been using to model the regression:

regr_model = lme4::lmer(votesPercent ~ itemresponse_mean * itemsentiment_mean
+ (1|group) + (1|item_name) + (1|yearmonth)
, data=mydata)


This is the output of regr_model:

Linear mixed model fit by REML ['lmerMod']
Formula: votesPercent ~ itemresponse_mean * itemsentiment_mean + (1 |      group) + (1 | item_name) + (1 | yearmonth)
Data: mydata

REML criterion at convergence: 260703.5

Scaled residuals:
Min       1Q   Median       3Q      Max
-1.97013 -0.77667 -0.05288  0.57223  3.12540

Random effects:
Groups    Name        Variance Std.Dev.
yearmonth (Intercept)   0.0000  0.0000
item_name (Intercept)   0.2364  0.4862
group     (Intercept)  45.2484  6.7267
Residual              111.5149 10.5601
Number of obs: 34508, groups:  yearmonth, 61; item_name, 15; group, 12

Fixed effects:
Estimate Std. Error t value
(Intercept)                           13.8627     1.9552   7.090
itemresponse_mean                     -0.5639     0.4163  -1.355
itemsentiment_mean                    -0.1973     0.4178  -0.472
itemresponse_mean:itemsentiment_mean   0.8352     0.9478   0.881

Correlation of Fixed Effects:
(Intr) itmrs_ itmsn_
itmrspns_mn -0.087
itmsntmnt_m -0.024  0.239
itmrspns_:_  0.022 -0.255 -0.923
optimizer (nloptwrap) convergence code: 0 (OK)
boundary (singular) fit: see ?isSingular


With this code I get a singular fit. Now, I realize that the singular fit issue may stem from the complexity of the random effects structure. However, I am not sure how to address this, because the group and the item are central to answering my desired research question.

I am now wondering, if I can restructure my data in some way for the mixed model to achieve a better result? I have tried running a model with a wide format for the items i.e. itemresponse_mean_Item1, ... ,itemresponse_mean_Item15 but this has not resulted in better output.

Is this even the appropriate model for what I am trying to answer?

Any pointers would be appreciated, thanks

• Please include all the output of summary(regr_model) – Robert Long Feb 26 at 14:43

There is an estimated zero variance at the level of yearmonth, and that is causing the singular fit. I would suggest fitting the following model:
votesPercent ~ itemresponse_mean * itemsentiment_mean + yearmonth

If this converges without singularity then try removing yearmonth alltogether and comparing the two models with a likelihood ratio test.
It is also worth noting that there is very little variation at the item_name and you might consider doing the same with that.