If what you show works for a
lmer formula for a random effects term then you should be able to use functions from the splines package that comes with R to set up the relevant basis functions.
lmer(counts ~ dependent_variable + (bs(t) | ID), family="poisson")
Depending on what you want to do, you should also look at the gamm4 package and the mgcv package. The former is essentially formalising the
bs() bit in the
lmer() call above and allows smoothness selection to be performed as part of the analysis. The latter with function
gam() allows for some degree of flexibility in fitting models like this (if I understand what you are trying to do). It looks like you want separate trends within
ID? A more fixed effects approach would be something like:
gam(counts ~ dependent_variable + ID + s(t, by = ID) , family="poisson")
Random effects can be included in
gam() models using the
s(foo, bs = "re") type terms where
foo would be
ID in your example. Whether it makes sense to combine the
by term idea with a random effect is something to think about and not something I am qualified to comment on.