library(tidymodels) library(multilevelmod) library(poissonreg) # current required for poisson_reg() # The lme4 package is required for this model. tidymodels_prefer() # Split out two subjects to show how prediction works data_train <- longitudinal_counts %>% filter(!(subject %in% c("1", "2"))) data_new <- longitudinal_counts %>% filter(subject %in% c("1", "2")) # Fit the model count_mod <- poisson_reg() %>% set_engine("glmer") %>% fit(y ~ time + x + (1 | subject), data = data_train)
count_mod
When making predictions, the basic predict()
method does the trick:
count_mod %>% predict(data_new)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.