# \#state-space

**URL:** https://discourse.mc-stan.org/tag/state-space/26.md

[Latest](https://discourse.mc-stan.org/latest.md) · [Categories](https://discourse.mc-stan.org/categories.md) · [Tags](https://discourse.mc-stan.org/tags.md)

---

## [Updating State Space Model after receiving new data?](https://discourse.mc-stan.org/t/updating-state-space-model-after-receiving-new-data/36593)

<div class="topic-metadata">

**Author:** [@Stanimal](https://discourse.mc-stan.org/u/Stanimal)\
**Replies:** 1\
**Last updated:** [September 13, 2024, 10:23pm UTC](https://discourse.mc-stan.org/t/updating-state-space-model-after-receiving-new-data/36593 "2024-09-13T22:23:25Z")

</div>

Let’s say I have a state space model, whose parameter/model posteriors are relative to the current time step T. Now, let’s say I receive a new observation at T+1. How do I update the model/posteriors relative to this ne…

---

## [Stochastic Volatility for Latent Factor Models](https://discourse.mc-stan.org/t/stochastic-volatility-for-latent-factor-models/34140)

<div class="topic-metadata">

**Author:** [@Adam\_Dieck](https://discourse.mc-stan.org/u/Adam_Dieck)\
**Replies:** 1\
**Last updated:** [February 21, 2024, 8:44pm UTC](https://discourse.mc-stan.org/t/stochastic-volatility-for-latent-factor-models/34140 "2024-02-21T20:44:16Z")

</div>

Hi all! I’m currently working on a STAN implementation of the Dynamic Nelson-Siegel model for my economics thesis and am hitting some roadblocks when it comes to including stochastic volatility on the latent factors. My…

---

## [Help Wanted: Custom Multivariate pdf For State Space Model](https://discourse.mc-stan.org/t/help-wanted-custom-multivariate-pdf-for-state-space-model/32020)

<div class="topic-metadata">

**Author:** [@PatrickStar](https://discourse.mc-stan.org/u/PatrickStar)\
**Replies:** 2\
**Last updated:** [July 9, 2023, 12:47am UTC](https://discourse.mc-stan.org/t/help-wanted-custom-multivariate-pdf-for-state-space-model/32020 "2023-07-09T00:47:58Z")

</div>

Hello, I’m trying to fit a state space model of the form; x\_t = Gx\_{t-1} + \\epsilon\_s y\_t = Fx\_t + \\epsilon\_o I would like to specify a user-defined PDF (multivariate) on the errors, \\epsilon\_s, \\epsilon\_o. Current…

---

## [Modeling observed sums of \*positive\* latent random variables](https://discourse.mc-stan.org/t/modeling-observed-sums-of-positive-latent-random-variables/31728)

<div class="topic-metadata">

**Author:** [@potash](https://discourse.mc-stan.org/u/potash)\
**Replies:** 0\
**Last updated:** [June 13, 2023, 6:06pm UTC](https://discourse.mc-stan.org/t/modeling-observed-sums-of-positive-latent-random-variables/31728 "2023-06-13T18:06:51Z")

</div>

The short question is: Does anyone have experience modeling sums of positive latent random variables? What are the tried and true techniques? I am having trouble. The long question is: I have some positive latent functi…

---

## [Structural Time Series negative binomial model some chains don't sample](https://discourse.mc-stan.org/t/structural-time-series-negative-binomial-model-some-chains-dont-sample/31684)

<div class="topic-metadata">

**Author:** [@jd\_c](https://discourse.mc-stan.org/u/jd_c)\
**Replies:** 1\
**Last updated:** [June 8, 2023, 7:16pm UTC](https://discourse.mc-stan.org/t/structural-time-series-negative-binomial-model-some-chains-dont-sample/31684 "2023-06-08T19:16:27Z")

</div>

Howdy! I’ve been trying to code up a basic structural time series (state-space) model following the code in this tutorial but modifying it for a negative binomial likelihood. Unfortunately, when I run the model it alway…

---

## [Help improving a fisheries state space model with biased estimation](https://discourse.mc-stan.org/t/help-improving-a-fisheries-state-space-model-with-biased-estimation/31197)

<div class="topic-metadata">

**Author:** [@Challen\_Hyman](https://discourse.mc-stan.org/u/Challen_Hyman)\
**Replies:** 12\
**Last updated:** [April 28, 2023, 6:26am UTC](https://discourse.mc-stan.org/t/help-improving-a-fisheries-state-space-model-with-biased-estimation/31197 "2023-04-28T06:26:38Z")

</div>

Hi everyone, I’m a huge fan of Stan and have used it to fit relatively simple statistical models, but I’m still relatively new to the world of state-space modeling. I’ve been trying to build a three-stage fisheries stat…

---

## [Help with unsual state space model](https://discourse.mc-stan.org/t/help-with-unsual-state-space-model/20116)

<div class="topic-metadata">

**Author:** [@Fred](https://discourse.mc-stan.org/u/Fred)\
**Replies:** 9\
**Last updated:** [April 26, 2023, 4:45pm UTC](https://discourse.mc-stan.org/t/help-with-unsual-state-space-model/20116 "2023-04-26T16:45:00Z")

</div>

Hello, I am new to stan and state space models and have a conceptual and Stan modelling question. Model Setting I am trying to measure the decline of immature shrimp individuals in growth tanks so no reproduction jus…

---

## [State space mixed models for discrete longitudinal responses](https://discourse.mc-stan.org/t/state-space-mixed-models-for-discrete-longitudinal-responses/29342)

<div class="topic-metadata">

**Author:** [@sonicking](https://discourse.mc-stan.org/u/sonicking)\
**Replies:** 1\
**Last updated:** [November 5, 2022, 2:50pm UTC](https://discourse.mc-stan.org/t/state-space-mixed-models-for-discrete-longitudinal-responses/29342 "2022-11-05T14:50:43Z")

</div>

Hello, I am trying my luck. Is there any example on state-space mixed models for discrete (Poisson or Binomal) longitudinal responses?

---

## [Difficulties with Hierarchical State Space Model](https://discourse.mc-stan.org/t/difficulties-with-hierarchical-state-space-model/28018)

<div class="topic-metadata">

**Author:** [@rewb](https://discourse.mc-stan.org/u/rewb)\
**Replies:** 5\
**Last updated:** [July 15, 2022, 6:48pm UTC](https://discourse.mc-stan.org/t/difficulties-with-hierarchical-state-space-model/28018 "2022-07-15T18:48:01Z")

</div>

Hello community, I’ve been having some trouble with this model, so I’m hoping someone can point out where I’ve gone wrong. I’ve suspected it has something to do with how I’ve set the priors, as in some cases (using prin…

---

## [Single source of error seasonal local level model: is this correct?](https://discourse.mc-stan.org/t/single-source-of-error-seasonal-local-level-model-is-this-correct/21928)

<div class="topic-metadata">

**Author:** [@JMalnight](https://discourse.mc-stan.org/u/JMalnight)\
**Replies:** 3\
**Last updated:** [June 23, 2022, 2:57pm UTC](https://discourse.mc-stan.org/t/single-source-of-error-seasonal-local-level-model-is-this-correct/21928 "2022-06-23T14:57:48Z")

</div>

I am trying to gradually build up some single source of error state space models for revenue forecasting. I’m a relative newbie to STAN and want to ensure that my code is correct. I think it is, but I need feedback. I’m…

---

## [Generated quantities block conflicting with model constraints](https://discourse.mc-stan.org/t/generated-quantities-block-conflicting-with-model-constraints/27853)

<div class="topic-metadata">

**Author:** [@hannahvwatkins](https://discourse.mc-stan.org/u/hannahvwatkins)\
**Replies:** 4\
**Last updated:** [June 16, 2022, 10:00pm UTC](https://discourse.mc-stan.org/t/generated-quantities-block-conflicting-with-model-constraints/27853 "2022-06-16T22:00:37Z")

</div>

Hi all, I’ve been working on a multivariate state-space model in RStan and have been running into a strange problem when trying to generate predictions from the model in the generated quantities section. On more than ha…

---

## [Smoother for gaussian\_dlm\_obs\_lpdf](https://discourse.mc-stan.org/t/smoother-for-gaussian-dlm-obs-lpdf/23879)

<div class="topic-metadata">

**Author:** [@betascoo8](https://discourse.mc-stan.org/u/betascoo8)\
**Replies:** 5\
**Last updated:** [March 7, 2022, 7:15am UTC](https://discourse.mc-stan.org/t/smoother-for-gaussian-dlm-obs-lpdf/23879 "2022-03-07T07:15:19Z")

</div>

Quick question Has anyone written a smoother for extracting smoothed states when using gaussian\_dlm\_obs\_lpdf? I see in the math library there is gaussian\_dlm\_obs\_rng but It’s not in the documentation. Many Thanks

---

## [How to specify a stochastic state space model with discrete (HMM-like) output](https://discourse.mc-stan.org/t/how-to-specify-a-stochastic-state-space-model-with-discrete-hmm-like-output/22446)

<div class="topic-metadata">

**Author:** [@caesoma](https://discourse.mc-stan.org/u/caesoma)\
**Replies:** 6\
**Last updated:** [May 21, 2021, 12:06am UTC](https://discourse.mc-stan.org/t/how-to-specify-a-stochastic-state-space-model-with-discrete-hmm-like-output/22446 "2021-05-21T00:06:58Z")

</div>

I am looking into a (deterministic) state-space model where the state is a function of two continuous processes and a discrete one - this last one is either “on” or “off”. For two continuous processes, the first is a si…

---

## [Local linear trend model](https://discourse.mc-stan.org/t/local-linear-trend-model/21659)

<div class="topic-metadata">

**Author:** [@blackrabite](https://discourse.mc-stan.org/u/blackrabite)\
**Replies:** 7\
**Last updated:** [April 3, 2021, 12:18am UTC](https://discourse.mc-stan.org/t/local-linear-trend-model/21659 "2021-04-03T00:18:37Z")

</div>

Hello, I was trying to implement a simple local linear trend model, defined as follow: y\_t = x\_t + \\epsilon\_t \\mu\_{t+1} = \\mu\_t + v\_t + \\xi\_t v\_{t+1} = v\_t + \\zeta\_t I used the same code provided by (RPubs - 状態空間時系列分…

---

## [Help using new ode interface, getting incompatable types](https://discourse.mc-stan.org/t/help-using-new-ode-interface-getting-incompatable-types/21567)

<div class="topic-metadata">

**Author:** [@betascoo8](https://discourse.mc-stan.org/u/betascoo8)\
**Replies:** 3\
**Last updated:** [March 29, 2021, 4:25pm UTC](https://discourse.mc-stan.org/t/help-using-new-ode-interface-getting-incompatable-types/21567 "2021-03-29T16:25:48Z")

</div>

Hi, Hopefully this is obvous to someone more familiar with the new ode interface. I’ve worked through the examples provided by Upgrading to the new ODE interface but i’m still struggling to quite figure out what i’m do…

---

## [Help needed please with State Space based regression model for balanced Panel Data](https://discourse.mc-stan.org/t/help-needed-please-with-state-space-based-regression-model-for-balanced-panel-data/19193)

<div class="topic-metadata">

**Author:** [@ants007](https://discourse.mc-stan.org/u/ants007)\
**Replies:** 3\
**Last updated:** [November 11, 2020, 1:04pm UTC](https://discourse.mc-stan.org/t/help-needed-please-with-state-space-based-regression-model-for-balanced-panel-data/19193 "2020-11-11T13:04:29Z")

</div>

hello all, I am trying to fit a stochastic frontier model (not much different from linear regression) for a balanced panel data. I am allowing the inefficiency (u) to be correlated with the previous lag. I have tried th…

---

## [Gaussian DLM example with gaussian\_dlm\_obs()](https://discourse.mc-stan.org/t/gaussian-dlm-example-with-gaussian-dlm-obs/17145)

<div class="topic-metadata">

**Author:** [@morganbale](https://discourse.mc-stan.org/u/morganbale)\
**Replies:** 1\
**Last updated:** [August 5, 2020, 1:51pm UTC](https://discourse.mc-stan.org/t/gaussian-dlm-example-with-gaussian-dlm-obs/17145 "2020-08-05T13:51:39Z")

</div>

I’m a relatively new Stan user and I’m interested in estimating a dynamic linear model (as a component of a larger model) in Stan. I found the documentation for gaussian\_dlm\_obs() in the function reference, but I haven’t…

---

## [Combining spline and state space model](https://discourse.mc-stan.org/t/combining-spline-and-state-space-model/15459)

<div class="topic-metadata">

**Author:** [@dstauffer11](https://discourse.mc-stan.org/u/dstauffer11)\
**Replies:** 5\
**Last updated:** [May 29, 2020, 3:59pm UTC](https://discourse.mc-stan.org/t/combining-spline-and-state-space-model/15459 "2020-05-29T15:59:12Z")

</div>

I have a bunch of time series with interventions in some, whose impact I want to model. First, I replicated the CausalImpact package in Stan to fit a state space model (thanks to another post on this forum). Basically wh…

---

## [Using posterior samples as data for next model](https://discourse.mc-stan.org/t/using-posterior-samples-as-data-for-next-model/15429)

<div class="topic-metadata">

**Author:** [@dstauffer11](https://discourse.mc-stan.org/u/dstauffer11)\
**Replies:** 5\
**Last updated:** [May 27, 2020, 2:17pm UTC](https://discourse.mc-stan.org/t/using-posterior-samples-as-data-for-next-model/15429 "2020-05-27T14:17:36Z")

</div>

Hi! I started by trying to replicate the CausalImpact bayesian state-space modeling package in Stan. I think I got it working pretty well, the model code is here (thanks mostly to another post on this board). Also attac…

---

## [Chronikis: a language for Bayesian time-series models that compiles to Stan](https://discourse.mc-stan.org/t/chronikis-a-language-for-bayesian-time-series-models-that-compiles-to-stan/8410)

<div class="topic-metadata">

**Author:** [@Kevin\_Van\_Horn](https://discourse.mc-stan.org/u/Kevin_Van_Horn)\
**Replies:** 2\
**Last updated:** [April 29, 2019, 7:20pm UTC](https://discourse.mc-stan.org/t/chronikis-a-language-for-bayesian-time-series-models-that-compiles-to-stan/8410 "2019-04-29T19:20:24Z")

</div>

I’d like to announce the open-source release of Chronikis (kroh-NEE-kees), a special-purpose language for creating Bayesian time-series models, available here: \[http://opensource.adobe.com/Chronikis/\](http://opensource.…

---

## [State-space models of poll aggregation](https://discourse.mc-stan.org/t/state-space-models-of-poll-aggregation/1035)

<div class="topic-metadata">

**Author:** [@Bob\_Carpenter](https://discourse.mc-stan.org/u/Bob_Carpenter)\
**Replies:** 0\
**Last updated:** [June 24, 2017, 4:55pm UTC](https://discourse.mc-stan.org/t/state-space-models-of-poll-aggregation/1035 "2017-06-24T16:55:47Z")

</div>

Here's a really nice case study by Peter Ellis, using Stan to replicate the results of Simon Jackman's R package implementing his model for poll aggregation: This is a really great example of how to validate your wo…
