0

I have fit an ordinal regression model thorugh brms on a large dataset.

When adding the draws thorugh add_epred_draws() R will crash. There are 850,000 observations in the dataframe after group_by() and data_grid() functions ready for the draws to be fit.

men_pos_model2 %>%
  group_by(athlete_id) %>% 
  data_grid(pos_swim, pos_bike, program_id) %>%
  filter(pos_swim %in% c(1:20) & pos_bike %in% c(1:20)) %>% 
  add_epred_draws(fit_pos_performance, ndraws = 10)
  group_by(pos_swim, pos_bike, .category) %>% 
  summarise(mu = mean(.epred)) %>% 
  mutate(.category = recode_factor(.category,
                                   '1' = '1-3',
                                   '2' = '4-10th',
                                   '3' = '11-20th')) %>%
  ggplot()+
  geom_raster(aes(x = pos_swim, y = pos_bike, fill = mu))

I have tried using data.table() to improve the handling of the large observations but to no avail. Was originally plotting with geom_tile() but found the geom_raster() which is a high performance version of geom_tile for my needs.

scigibbo
  • 1
  • 1

0 Answers0