epinowcast / epinowcast

Tools to enable flexible and efficient hierarchical nowcasting of epidemiological time-series using a semi-mechanistic Bayesian model with support for a range of reporting and generative processes.
https://package.epinowcast.org/
Other
56 stars 21 forks source link

Support for splines #196

Open seabbs opened 1 year ago

seabbs commented 1 year ago

Feature request

Splines are often useful for fitting non-linear relationships and can be more efficient than AR processes etc. It would be nice if epinowcast was able to support them.

Potential solution

There are many tools that support splines in R. The most obvious are the splines package, mgcv, and brms. brms offers this support using functionality from mgcv which indicates that also depending on mgcv may be the way to go (potentially via brms). This would preferred to implementing from scratch as mgcv has wide adoption, a flexible formula interface for its splines, and the functionality in brms works well.

A potential approach that may pay off is to transform the s(..) splines as defined by mgcv into a random effect formulation using this. I think this is also what brms does but this would need to be checked (and again if we can make use of brms to do this we really should.

seabbs commented 1 year ago

Flagging the existence of smooth2randon which is from mgcv and used by many packages to construct splines.

See: https://twitter.com/ucfagls/status/1657397308521160704?s=20