1

I want to test fixed and random effects with the lmerTest R-package. After defining the model with lmer(), I use summary() to get the results. For my results report, I would like to display more decimals of AIC and BIC, of Variance and Std.Dev in Random Effects, of the Estimate and Std.Error (see picture: my output summary(lmer) with missing/few decimals ).

Things I have already tried out that do not help:

  1. changing general R options
options(digits=3)
  1. changing options within summary() or coef(summary())
summary(lmer, digits=3)
coef(summary(lmer), digits=3)
  1. using round() for summary() or coef(summary())
round(summary(lmer), digits=3)
round(coef(summary(lmer)), digits=3)
  1. searching the terms "digit" and "decimal" in the lmerTest R-package manual
desertnaut
  • 57,590
  • 26
  • 140
  • 166
LillyZoe
  • 11
  • 2
  • 1
    Can you please post your results as text rather than as a link to an image? (You can cut-and-paste text into a code block delimited by triple-backticks ``` ) – Ben Bolker Apr 19 '23 at 13:18
  • One other way to approach this is to inspect the object/ list `lmer`, you can do so by `str(lmer)`. It should be a list with lists containing the underlying data, model parameters, and various fit statistics. – TheN Apr 19 '23 at 13:19

3 Answers3

1

One way to accomplish this is to load the jtools package and use options( "jtools-digits" = 3 ). When calling your model results, use the summ function to view them.

david
  • 100
  • 1
  • 4
  • Thanks, but this does not work (even when adding the " that were missing in your code). The output still only has two decimals for each value. – LillyZoe Apr 20 '23 at 09:01
1

At present it's not possible to adjust the digit setting for the printing of AIC etc.. You can hack this a bit by using the internal function:

lme4:::.prt.aictab(summary(model)$AICtab, digits = 10)
         AIC          BIC       logLik     deviance     df.resid 
1763.9393445 1783.0970856 -875.9696722 1751.9393445          174 

The global digits option should affect the printing of coef(summary(.)):

options(digits = 10)
coef(summary(model))
                Estimate  Std. Error          df      t value        Pr(>|t|)
(Intercept) 251.40510485 6.632122742 18.00113477 37.907185169 1.263751938e-18

and of the random effects variances:

VarCorr(model)
Groups   Name        Std.Dev.   Corr    
 Subject  (Intercept) 23.7797596         
          Days         5.7167985 0.081321
 Residual             25.5919070   

For extracting components of a mixed model, also see this question and the glance() and tidy() functions from the broom.mixed package.

Ben Bolker
  • 211,554
  • 25
  • 370
  • 453
  • For the decimals of AIC and BIC, `lme4:::.prt.aictab(ss$AICtab, digits = 10)` does not work, it says the $ operator not defined for this S4 class. I found `extractAIC(ss)` for AIC, but still do not know how to get more decimals for the BIC. `options(digits = 10); coef(summary(mm))` for Variance and `VarCorr(mm)` for Std.Dev in Random Effects and `of the Estimate and Std.Error worked, many thanks! – LillyZoe Apr 20 '23 at 09:05
  • Note that `ss` is not the original model, but a `summary()` of it. I've updated my answer to clarify that. – Ben Bolker Apr 20 '23 at 17:34
0
emm_options(opt.digits = FALSE)
toyota Supra
  • 3,181
  • 4
  • 15
  • 19
  • 2
    Welcome to Stack Overflow! While this code may solve the question, [including an explanation](//meta.stackexchange.com/q/114762) of how and why this solves the problem would really help to improve the quality of your post, and probably result in more up-votes. Remember that you are answering the question for readers in the future, not just the person asking now. Please [edit] your answer to add explanations and give an indication of what limitations and assumptions apply. – Yunnosch Aug 11 '23 at 09:33