Is there any way to replace the Y observation in regression?

Suppose i have a simple linear regression like this:

y_t \sim{\mathcal{N}}(x_t\beta, \sigma_y)
\beta \sim{\mathcal{N}}(0,5)
\sigma_y \sim{\mathcal{C}^+}(0,1)

For some reason we assume that y_t is assumed to also follow the random walk as followed:

y_t \sim{\mathcal{N}}(\alpha + y_{t-1}, \sigma_{yy})

every draw of in NUTS algorithm we replace y_t generated from state space model and replace y_t in first equation.

Is it possible to replace y_t in any blocks rather than in generated quantities?

It is not possible to change the data during sampling in this manner in Stan.

1 Like