@alexhallam, curious if you ever solved this to use adstock with brms? It is the same exact issue I am struggling with…
I don’t think it’s possible without pure STAN. Creating AdStock function for panel data is a pretty complicated task (as it should loop over factors and observations).
I believe you can determine AdStock while optimizing the sales ~ adstocked media var function (with nlsLM for example - on demeaned panel data or with dummies, of course) and then transfer the adstock transformed variables into brms to optimize the parameters of the curvature (like Hill) function. Though, you have to remember, that it will provide you with Hill (S-Shaped) transformed adstocked values.
This solution has one major drawback - it assumes that adstock of each media channel is the same accros units as you define it before modeling in brms. It is a strong assumption, but as brms seems to be the most user-friendly R library for HB modelling I believe it’s the right way to go.
Maybe @paul.buerkner will correct me if I’m wrong. Best!
I have no experience with that kind of models so I don’t think I am of much help here.