Set up the GAM component for the observation model as usual, using dynamic factors for the trends (number of factors specified by the user when supplying the loading matrix)
Set up a second model using dynamic factors with simple observation model that can be easily stripped from the code
Replace names for trend model penalty matrices and Xp so they can be added to the data in the original observation model
Replace b with b_trend in model code so they can be separated; same for lambda etc....
Pull the trend GAM component Stan code into the observation model Stan code and make final changes to the trend models
Possibly the best way to do this would be:
b
withb_trend
in model code so they can be separated; same forlambda
etc....Stan
code into the observation modelStan
code and make final changes to the trend modelsmgcv
model for easier prediction