bbolker / broom.mixed

tidy methods for mixed models in R
227 stars 23 forks source link

Random / varying effects are labelled incorrectly using tidy #86

Open richramsey opened 4 years ago

richramsey commented 4 years ago

I am new to broom.mixed, so this may be an elementary mistake on my part. I want to plot the random effects / varying effects as caterpillar plots following a model run in brms. However, when I get the output of tidy, the varying effects for intercepts are labelled correctly, but the varying effects for slopes are not. Specifically, the 'level' and 'term' columns are incorrect for the random slopes. The levels for participant should be the same for all varying effects of interest, but once it goes beyond the intercept things seem to get messed up. Model and table below. Item has 80 levels, participant has 11 levels. Any ideas on the problem/solution?

brms: 2.11.6 broom.mixed: 0.2.4

b4 <- brm(rating ~ 1 + painting_type_dev * motion_dev * load_dev +
          (1 + painting_type_dev * motion_dev * load_dev|participant) +
          (1|item),
        data = data_aes_dev, family = cumulative("probit"),
        prior = c(prior(normal(0, 5), class = Intercept),
                prior(cauchy(0, 2), class = b)),
        iter = 6000, warmup = 1000, cores = 4, chains = 4,
        control = list(adapt_delta = 0.99),
        inits = 0)

tidy(b4, effects = "ran_vals", robust=T, conf.method = "HPDinterval")
head(tidy_b4_ran_vals)

ran_vals.pdf

bbolker commented 4 years ago

Not sure yet, will look into it ... A reproducible example would help a lot.

richramsey commented 4 years ago

Hi, thanks for your response. I found the problem. It was the way I was labelling factors. Once I removed "_" from factor labels, everything seemed to work fine. Thanks again for repsonding. Rich

bbolker commented 4 years ago

thanks, you saved me a bunch of time. I should (a) document this limitation and (b) check names and give a warning if they contain "_" (if possible).

richramsey commented 4 years ago

Yes, that sounds good. Thanks. Fantastic package by the way.