rtidybroom

Error - No tidy method for objects of class lmerMod


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)) 

Solution

  • 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 should install, and load, the broom.mixed package (i.e. install.packages("broom.mixed"); library("broom.mixed")).