Lisa Grielens
Lisa Grielens

Reputation: 11

estimates and significance level of categorial variables are not shown in output of lmer function

I am trying to run a multilevel regression analysis with the following script.

M5 <- lmer(
  health_complaints ~ thinkbody_3cat_ref + IOTF3_ref + sex_ref + age_GMC + 
    fas_sum + thinkbody_3cat_ref*IOTF3_ref +(1|id2),
  data=HBSC2022_FlemishDataset_18_06_completecases,
  REML=FALSE
)
summary(M5)

all categories are dummy coded. variable IOTF3 and thinkbody_3cat_ref are both categorical variable with three categories. However in the output, envisioned below, I don't get to see the estimates between the different categories which makes it hard to interpret the interaction effect (that is significant).

Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
  method [lmerModLmerTest]
Formula: health_complaints ~ thinkbody_3cat_ref + IOTF3_ref + sex_ref +  
    age_GMC + fas_sum + thinkbody_3cat_ref * IOTF3_ref + (1 |     id2)
   Data: HBSC2022_FlemishDataset_18_06_completecases

     AIC      BIC   logLik deviance df.resid 
 36405.8  36474.3 -18193.9  36387.8    14981 

Scaled residuals: 
    Min      1Q  Median      3Q     Max 
-4.0264 -0.6266  0.1417  0.7446  2.5101 

Random effects:
 Groups   Name        Variance Std.Dev.
 id2      (Intercept) 0.01745  0.1321  
 Residual             0.65524  0.8095  
Number of obs: 14990, groups:  id2, 196

Fixed effects:
Estimate Std. Error         df t value
# (Intercept)                   3.968e+00  3.717e-02  5.185e+03 106.750
thinkbody_3cat_ref           -2.342e-01  9.115e-03  1.494e+04 -25.694
IOTF3_ref                    -2.491e-02  1.595e-02  1.493e+04  -1.562
sex_ref                      -4.731e-01  1.400e-02  1.442e+04 -33.780
age_GMC                      -3.744e-02  3.971e-03  6.149e+02  -9.429
fas_sum                       1.656e-02  3.544e-03  1.464e+04   4.674
thinkbody_3cat_ref:IOTF3_ref  2.926e-02  1.038e-02  1.491e+04   2.818
Pr(>|t|)    
# (Intercept)                   < 2e-16 ***
thinkbody_3cat_ref            < 2e-16 ***
IOTF3_ref                     0.11834    
sex_ref                       < 2e-16 ***
age_GMC                       < 2e-16 ***
fas_sum                      2.98e-06 ***
thinkbody_3cat_ref:IOTF3_ref  0.00484 ** 
# ---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Correlation of Fixed Effects:
            (Intr) thn_3_ IOTF3_ sex_rf ag_GMC fas_sm
thnkbdy_3c_ -0.161                                   
IOTF3_ref   -0.133  0.238                            
sex_ref     -0.196 -0.163 -0.016                     
age_GMC      0.015 -0.019  0.046  0.034              
fas_sum     -0.903  0.031  0.019  0.046  0.065       
t_3_:IOTF3_  0.069 -0.486 -0.792  0.051 -0.044  0.020

Does anyone have a idea what is wrong or experienced the same problem?

I tried updating lme4 package.

Upvotes: 1

Views: 84

Answers (1)

Ben Bolker
Ben Bolker

Reputation: 226637

As @Axeman comments, if by 'dummy coded' you mean that (for example) IOTF3_ref is coded as (0, 1, 2) or (1, 2, 3), that simply won't work/isn't the way it's done in R; if a variable is of type 'numeric', R will assume that you want to use it as a numeric covariate. To use a categorical predictor in a model in R, set it up as a factor, ideally keeping the original labels (e.g. 'male', 'female' or 'chocolate', 'strawberry', 'vanilla'). Then R will automatically set up the dummy variables needed for the model (a categorical variable with n levels will generate n-1 binary dummy variables). How the dummy variables are set up (contrast coding) depends on how options("contrast") is set; the default is treatment coding.

Especially when you have more than two levels per factor, it may be easiest to use a package like emmeans to get the model output/comparisons in a convenient form.

Upvotes: 0

Related Questions