Simultaneous modeling of long-term and short-term trends in a state-space model

Hello.

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

trend_movingaverageby[t]:=mean(trend_w[t:t-rnk])
trend_movingaverageby[t]-trend_moveave[t-1]=trend_moveave[t-1]-trend_moveave[t-2]+eps

and assuming a first-order linear trend, transforming

rnk=7;.
trend_w[(rnk+2):N]~normal(trend_w[(rnk+1):(N-1)]+trend_w[2:(N-rnk)]-)
      trend_w[1:(N-rnk-1)],s_trend_w);

For stock prices, we have

y~normal(trend_w,sigma);

but the estimated trend oscillates and sigma is estimated abnormally low.
Please advise!

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.