Philippe Massicotte
Philippe Massicotte

Reputation: 1529

Why this simple mixed model fail to converge?

I have this following data on which I would like to compare the mean of the value variable between day 28 and day 83:

library(lme4)
#> Loading required package: Matrix
library(lmerTest)
#> 
#> Attaching package: 'lmerTest'
#> The following object is masked from 'package:lme4':
#> 
#>     lmer
#> The following object is masked from 'package:stats':
#> 
#>     step

df <- structure(list(experience_sep = c(
  "DM", "DA", "DM", "DA", "DM",
  "DA"
), day = c(55, 110, 55, 110, 55, 110), day_factor = c(
  55,
  110, 55, 110, 55, 110
), day_julian = c(
  55, 110, 55, 110, 55,
  110
), day_true = c(28, 83, 28, 83, 28, 83), culture = c(
  1L, 1L,
  2L, 2L, 3L, 3L
), value = c(
  758453.333333333, 575133.333333333,
  684160, 656933.333333333, 816840, 734700
)), row.names = c(
  NA,
  -6L
), class = c("data.frame"))


df  
#>   experience_sep day day_factor day_julian day_true culture    value
#> 1             DM  55         55         55       28       1 758453.3
#> 2             DA 110        110        110       83       1 575133.3
#> 3             DM  55         55         55       28       2 684160.0
#> 4             DA 110        110        110       83       2 656933.3
#> 5             DM  55         55         55       28       3 816840.0
#> 6             DA 110        110        110       83       3 734700.0

Because the experience involve pseudo-replication (culture), I was thinking to use a mixed model as follows:

lmerTest::lmer(value ~ factor(day_true) + (1|culture), data = df)
#> Warning in as_lmerModLT(model, devfun): Model may not have converged with 1
#> eigenvalue close to zero: 2.6e-09
#> Linear mixed model fit by REML ['lmerModLmerTest']
#> Formula: value ~ factor(day_true) + (1 | culture)
#>    Data: df
#> REML criterion at convergence: 102.7974
#> Random effects:
#>  Groups   Name        Std.Dev.
#>  culture  (Intercept) 47535   
#>  Residual             55990   
#> Number of obs: 6, groups:  culture, 3
#> Fixed Effects:
#>        (Intercept)  factor(day_true)83  
#>             753151              -97562

However, I am getting this error for which I can’t find the problem. Is it because I have very few points (n = 3 per group)?

Created on 2019-02-05 by the reprex package (v0.2.1)

Upvotes: 0

Views: 1349

Answers (1)

Janelle Badger
Janelle Badger

Reputation: 94

I know I'm a little late to this party, but I have run this model after standardizing the response variable (value) and it works just great. When you have variables in your models that are orders of magnitude larger than other variables, it can cause numerical problems. Here's the code.

df$value.st<-(df$value-mean(df$value))/(sd(df$value))

mod<-lmer(value.st ~ factor(day_true) + (1|culture), data=df)

mod
Linear mixed model fit by REML ['lmerMod']
Formula: value.st ~ factor(day_true) + (1 | culture)
   Data: df
REML criterion at convergence: 12.0241
Random effects:
 Groups   Name        Std.Dev.
 culture  (Intercept) 0.5613  
 Residual             0.6612  
Number of obs: 6, groups:  culture, 3
Fixed Effects:
       (Intercept)  factor(day_true)83  
            0.5761             -1.1521 

Good luck!

Upvotes: 1

Related Questions