Error - No tidy method for objects of class lmerMod
Asked Answered
R

1

17

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)) 
Rebane answered 16/11, 2020 at 9:2 Comment(2)
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. This provides a tidy() function for lmer-fits.Selfeducated
That worked! Thank you so much!Rebane
N
23

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

Neilneila answered 14/5, 2021 at 14:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.