I am trying to model long term and short term trends of stock prices simultaneously in stan with a state space model.
I am not using a pre-moving average, but rather an internal stan
Weekly trend

Hi, @biones. I’m sorry nobody’s responded to your post, but it’s very hard to diagnose part of a model without data. Do you have a Stan program that compiles? I couldn’t quite follow the hints you’re leaving here as I’m having trouble turning them into code.

If there’s a way you can just write the model out in mathematical notation, that would also help.

The model you have is odd for a generative model in that it doesn’t seem to be modeling the data, but only the trends and its modeling trends based on other trends. Have you tried reformulating to generate a single value at a time?

In general, the answer to problems like these is to simulate data from the model and see if you can recover the true parameters in their posterior intervals.

Thank you for your answer, sorry for the delay in replying. The code is as follows.

I feel that modeling latent variables with even deeper variables is not a Bayesian problem, but am I wrong in my perception of hierarchical Bayesianism? If anything, I feel like I am rattled by the act of taking averages.

Hi @biones, I wonder if you can achieve this using a dynamic Generalized Additive Model. I maintain the {mvgam} R package (Multivariate (Dynamic) Generalized Additive Models • mvgam), which is designed for setting up complex regression models that include dynamic processes in Stan. For your problem, you could smooth over weeks using a penalized spline or GP, and you could also include an AR process to capture short-term variation. Both of these components could contribute to evolution of the hidden state process, while other components could go into the observation model. Let me know if this is something you might consider, I’d be happy to help set up the data and model so you could give it a shot.