12

I am using a dataset from an online practice tutorial and the code can be found at the bottom of Page 4 (https://tomhouslay.files.wordpress.com/2017/02/indivvar_mv_tutorial_asreml.pdf)

In the tutorial, they get the function to work using the code listed below, but in my R session, I get an error that says:

No tidy method for objects of class lmerMod.

I have tried using the package "parsnip" as well as restarting my R session and I have tried requiring broom as suggested in other answers to similar questions.

The haggis practice csv file can be downloaded from here: https://figshare.com/articles/Haggis_data_behavioural_syndromes/4702540

library(asreml)
library(nadiv)
library(tidytext)
library(tidyverse)
library(broom)
require(broom)
library(lme4)
library(data.table)
library(parsnip)

HData<- read_csv("haggis practice.csv")

lmer_b <- lmer(boldness ~ scale(assay_rep, scale=FALSE) + 
                 scale(body_size) + 
                 (1|ID), 
               data = HData) 
plot(lmer_b) 
qqnorm(residuals(lmer_b)) 
hist(residuals(lmer_b)) 
summary(lmer_b)


rep_bold <- tidy(lmer_b, effects = "ran_pars", scales = "vcov") %>% 
  select(group, estimate) %>% 
  spread(group, estimate) %>% 
  mutate(repeatability = ID/(ID + Residual)) 
M--
  • 25,431
  • 8
  • 61
  • 93
qsxsqsxs
  • 161
  • 1
  • 8
  • 4
    It may be that this worked only with older versions of `broom`. It seems like this functionality was moved to a separate package "broom.mixed" at some point, see here: [Link](https://cran.r-project.org/web/packages/broom.mixed/). This provides a `tidy()` function for lmer-fits. – AndreasM Nov 16 '20 at 10:46
  • That worked! Thank you so much! – qsxsqsxs Nov 16 '20 at 17:23

1 Answers1

14

Providing an answer (from the comments).

The tidy methods for multilevel/mixed-type models (e.g. from lme4, brms, MCMCglmm, ...) were moved to broom.mixed. You can either install/load the broom.mixed package, or use the broomExtra package, which is a "meta-package" that looks for methods in both broom and broom.mixed ...

Ben Bolker
  • 211,554
  • 25
  • 370
  • 453