1

Running lmer results in additional quadratic fixed terms.

I don't think this is correct and I don't have a reason to include quadratic terms in the formula.

I was expecting only linear main effects and all interaction terms.

library(lmerTest)
library(sjPlot)

D <- read.csv(file = "data.csv")

D$Participant <- factor(D$Participant,order=FALSE)
D$Treatment   <- factor(D$Treatment,order=TRUE,levels = c("L0","L2","L4"))
D$Timepoint   <- as.numeric(D$Timepoint)

str(D)

'data.frame':   666 obs. of  6 variables:
Participant: Factor w/ 37 levels "O1","O10","O12",..: 19 21 30 4 7 13 21 21 36 36 ...
Treatment  : Ord.factor w/ 3 levels "L0"<"L2"<"L4": 2 1 2 1 3 2 2 3 1 3 ...
Timepoint  : num  1 1 1 1 1 1 1 1 1 1 ...
Rating     : num  6 4 3 NaN 4 4 NaN 2 NaN 4 ...
Wellbeing  : int  8 6 6 7 6 5 5 7 10 8 ...


mdl <- lmer(Rating ~ Treatment * Timepoint * Wellbeing + (Wellbeing | Participant), data = d,REML=F)

summary(mdl)

Here's the output of summary(mdl):

Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's method [
lmerModLmerTest]
Formula: Rating ~ Treatment * Timepoint * Wellbeing + (Wellbeing | Participant)
   Data: d

     AIC      BIC   logLik deviance df.resid 
  1723.3   1793.5   -845.6   1691.3      580 

Scaled residuals: 
    Min      1Q  Median      3Q     Max 
-3.6038 -0.6125 -0.0316  0.6088  3.6012 

Random effects:
 Groups      Name        Variance Std.Dev. Corr 
 Participant (Intercept) 1.30174  1.1409        
             Wellbeing   0.05398  0.2323   -0.83
 Residual                0.82435  0.9079        
Number of obs: 596, groups:  Participant, 37

Fixed effects:
                                  Estimate Std. Error         df t value Pr(>|t|)    
(Intercept)                      5.424e-01  3.118e-01  6.055e+01   1.739  0.08706 .  
Treatment.L                      4.784e-02  3.705e-01  5.490e+02   0.129  0.89729    
Treatment.Q                     -2.209e-01  3.702e-01  5.617e+02  -0.597  0.55097    
Timepoint                        4.683e-02  5.515e-02  5.156e+02   0.849  0.39627    
Wellbeing                        2.214e-01  6.669e-02  5.828e+01   3.320  0.00156 ** 
Treatment.L:Timepoint           -4.926e-02  9.418e-02  5.085e+02  -0.523  0.60118    
Treatment.Q:Timepoint           -2.663e-02  9.500e-02  5.190e+02  -0.280  0.77932    
Treatment.L:Wellbeing            4.982e-02  7.670e-02  5.509e+02   0.650  0.51623    
Treatment.Q:Wellbeing           -1.197e-03  8.360e-02  5.684e+02  -0.014  0.98858    
Timepoint:Wellbeing              9.874e-02  1.262e-02  5.273e+02   7.827 2.75e-14 ***
Treatment.L:Timepoint:Wellbeing -1.319e-02  2.019e-02  5.139e+02  -0.653  0.51390    
Treatment.Q:Timepoint:Wellbeing  5.632e-04  2.256e-02  5.331e+02   0.025  0.98009    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Correlation of Fixed Effects:
            (Intr) Trtm.L Trtm.Q Timpnt Wllbng Tr.L:T Tr.Q:T Tr.L:W Tr.Q:W Tmpn:W T.L:T:
Treatment.L -0.118                                                                      
Treatment.Q  0.012 -0.098                                                               
Timepoint   -0.600  0.139 -0.007                                                        
Wellbeing   -0.889  0.078  0.022  0.570                                                 
Trtmnt.L:Tm  0.091 -0.873  0.095 -0.152 -0.053                                          
Trtmnt.Q:Tm -0.006  0.092 -0.865 -0.010 -0.030 -0.110                                   
Trtmnt.L:Wl  0.049 -0.908  0.048 -0.079 -0.004  0.804 -0.053                            
Trtmnt.Q:Wl  0.024  0.047 -0.908 -0.046 -0.061 -0.052  0.803  0.003                     
Tmpnt:Wllbn  0.532 -0.077 -0.044 -0.905 -0.615  0.082  0.070  0.016  0.106              
Trtmn.L:T:W -0.046  0.775 -0.056  0.085  0.006 -0.906  0.065 -0.869  0.015 -0.014       
Trtmn.Q:T:W -0.025 -0.045  0.764  0.069  0.067  0.059 -0.906  0.008 -0.864 -0.141 -0.018

The Treatment.L and Treatment.Q terms are Linear and Quadratic. Why is Quadratic added here?

Thank you.

  • 1
    That's the default behaviour for ordered factors (not just in `lmer()`, but in all models). If you do `contrasts(D$Timepoint)` you will see how those variables will be represented in the model. If you treat the factors as unordered instead, you will get the usual treatment contrasts (i.e., dummy variables representing all but the first level of the factor). – DaveArmstrong Dec 08 '22 at 15:55
  • Great! Thank you for clearing this up for me. – user8189397 Dec 08 '22 at 16:20

0 Answers0