0
$\begingroup$

I have the following dataset:

structure(list(value = c(5.879, 8.278, 7.531, 5.709, 6.028, 6.643, 
5.627, 5.961, 6.726, 5.565, 5.778, 6.282, 7.222, 6.565, 5.86, 
7.568, 6.667, 6.312, 6.47, 6.868, 8.262, 6.326, 5.93, 7.721, 
6.63, 6.055, 5.948, 8.076, 7.166, 5.769, 6.876, 5.76, 8.891, 
6.716, 5.757, 9.436, 8.578, 6.101, 5.607, 8.901, 7.88, 5.87, 
5.651, 8.06, 8.634, 6.365, 6.057, 5.679, 7.471, 6.721, 6.5, 7.836, 
9.583, 6.155, 6.542, 7.235, 8.316, 6.061, 6.236, 6.537, 5.678, 
6.471, 6.676, 5.938, 6.054, 8.224, 6.167, 6.517, 7.618, 8.721
), treatment = structure(c(1L, 2L, 2L, 1L, 1L, 2L, 1L, 1L, 2L, 
1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 
1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 
1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 
1L, 1L, 2L, 1L, 1L, 2L, 1L, 1L, 2L, 1L, 1L, 2L, 2L), .Label = c("control", 
"infected"), class = "factor"), ind = structure(c(29L, 23L, 29L, 
25L, 30L, 25L, 28L, 2L, 2L, 28L, 2L, 28L, 2L, 29L, 3L, 29L, 3L, 
30L, 4L, 30L, 4L, 1L, 25L, 1L, 25L, 12L, 26L, 12L, 26L, 23L, 
27L, 23L, 27L, 18L, 21L, 18L, 21L, 19L, 22L, 19L, 22L, 20L, 24L, 
20L, 24L, 5L, 8L, 5L, 8L, 6L, 9L, 6L, 9L, 7L, 10L, 7L, 10L, 6L, 
13L, 6L, 11L, 15L, 11L, 13L, 16L, 13L, 14L, 17L, 14L, 17L), .Label = c("C1", 
"C10", "C11", "C12", "C13", "C14", "C15", "C16", "C17", "C18", 
"C19", "C2", "C20", "C21", "C22", "C23", "C24", "C25", "C26", 
"C27", "C28", "C29", "C3", "C30", "C4", "C5", "C6", "C7", "C8", 
"C9"), class = "factor"), day = structure(c(2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L), .Label = c("0", "1"), class = "factor")), row.names = c(NA, 
-70L), class = "data.frame")

I'm interested in comparing the variability explained by the day(between days) and ind (between subjects). I'm not necessarily interested in the fixed effect for treatment at the moment.

What I hope to answer is: is the variation in the outcome more explained by different days or by different individuals?

I tried these models, but I'm not sure if comparing their standard deviations actually would answer my question:

Model 1

 fit1 <- lmer(value ~ treatment + (1|day/ind), data = df)

Linear mixed model fit by REML ['lmerMod']
Formula: value ~ treatment + (1 | day/ind)
   Data: df
REML criterion at convergence: 154.0476
Random effects:
 Groups   Name        Std.Dev.
 ind:day  (Intercept) 0.3662  
 day      (Intercept) 0.1645  
 Residual             0.6208  
Number of obs: 70, groups:  ind:day, 38; day, 2
Fixed Effects:
      (Intercept)  treatmentinfected  
            6.059              1.513  
convergence code 0; 1 optimizer warnings; 0 lme4 warnings

Model 2

fit2 <- lmer(value ~ -1 + (1|day) + (1|ind), data = df)

Linear mixed model fit by maximum likelihood  ['lmerMod']
Formula: value ~ -1 + (1 | day) + (1 | ind)
   Data: df
      AIC       BIC    logLik  deviance  df.resid 
 224.9056  231.6511 -109.4528  218.9056        67 
Random effects:
 Groups   Name        Std.Dev. 
 ind      (Intercept) 3.708e-05
 day      (Intercept) 6.668e+00
 Residual             1.046e+00
Number of obs: 70, groups:  ind, 30; day, 2
No fixed effect coefficients
convergence code 0; 1 optimizer warnings; 0 lme4 warnings 

Model 3

fit3 <- lmer(value ~ treatment + (1|day) + (1|ind), data = df)

Linear mixed model fit by maximum likelihood  ['lmerMod']
Formula: value ~ treatment + (1 | day) + (1 | ind)
   Data: df
     AIC      BIC   logLik deviance df.resid 
159.6379 170.8804 -74.8189 149.6379       65 
Random effects:
 Groups   Name        Std.Dev.
 ind      (Intercept) 0.3512  
 day      (Intercept) 0.0000  
 Residual             0.6278  
Number of obs: 70, groups:  ind, 30; day, 2
Fixed Effects:
      (Intercept)  treatmentinfected  
            6.134              1.524  
convergence code 0; 1 optimizer warnings; 0 lme4 warnings

Would any of these work?

$\endgroup$
5
  • 1
    $\begingroup$ It looks like you only have two days of data, that is, day is a variable with two levels. Surely not enough levels to treat day as a random effect. I'd have low confidence in any of the above models. You are calculating the standard deviation based on two points! $\endgroup$ – JTH May 4 at 17:35
  • 1
    $\begingroup$ Take those optimizer warnings from lme4 seriously. $\endgroup$ – JTH May 4 at 17:38
  • $\begingroup$ Yes, I'm aware. Do you think I can parametrize this model modeling days as fixed in order to answer the same question? I only need to know which has more influence, the between-individuals or the two levels in days. Thank you. $\endgroup$ – BioLeal May 4 at 17:59
  • 1
    $\begingroup$ Yes, you'll have to treat day as a fixed factor. You can then compare the models v ~ t + d + (1|i), v ~ t + d and v ~ t + (1|i) using anova. $\endgroup$ – JTH May 4 at 18:12
  • $\begingroup$ Thanks. Does it make sense to include treatment, e.g, v ~ t + d + (-1 + t | i) to have random slopes? It greatly reduces deviance. $\endgroup$ – BioLeal May 4 at 19:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.