# \#time-series

**URL:** https://discourse.mc-stan.org/tag/time-series/178.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)

---

## [How to debug "Gradient evaluated at the initial value is not finite."](https://discourse.mc-stan.org/t/how-to-debug-gradient-evaluated-at-the-initial-value-is-not-finite/39708)

<div class="topic-metadata">

**Author:** [@tek](https://discourse.mc-stan.org/u/tek)\
**Replies:** 5\
**Last updated:** [June 14, 2025, 11:36am UTC](https://discourse.mc-stan.org/t/how-to-debug-gradient-evaluated-at-the-initial-value-is-not-finite/39708 "2025-06-14T11:36:15Z")

</div>

Hi, I’m attempting to adapt a colleagues JAGS model to Stan that estimates an infection time series across multiple sites. The Stan version has made it to the stage where it compiles, but fails with an infinite gradient…

---

## [Count Time Series | INGARCH(1,1) Fits | INGARCH(2,2) Does Not](https://discourse.mc-stan.org/t/count-time-series-ingarch-1-1-fits-ingarch-2-2-does-not/39044)

<div class="topic-metadata">

**Author:** [@JaredWinslow](https://discourse.mc-stan.org/u/JaredWinslow)\
**Replies:** 4\
**Last updated:** [March 13, 2025, 11:21pm UTC](https://discourse.mc-stan.org/t/count-time-series-ingarch-1-1-fits-ingarch-2-2-does-not/39044 "2025-03-13T23:21:45Z")

</div>

Hi all, I’m working with count time series models (specifically, INGARCH). I’ve tried a lot of things to no avail, but maybe you all can help! Mathematically, the very simplest version of INGARCH is a time-dependent Po…

---

## [ARR2: A new prior for autoregressions](https://discourse.mc-stan.org/t/arr2-a-new-prior-for-autoregressions/35363)

<div class="topic-metadata">

**Author:** [@n-kall](https://discourse.mc-stan.org/u/n-kall)\
**Replies:** 5\
**Last updated:** [February 7, 2025, 1:40pm UTC](https://discourse.mc-stan.org/t/arr2-a-new-prior-for-autoregressions/35363 "2025-02-07T13:40:23Z")

</div>

Hi all, We (@davkoh, @n-kall, @yannmclatchie, @avehtari) have a new preprint on arXiv presenting the ARR2 prior (a prior on R2 for autoregressive models). An explicit prior on R2 controls the tendency for the prior on …

---

## [Parameter Estimation issue](https://discourse.mc-stan.org/t/parameter-estimation-issue/37405)

<div class="topic-metadata">

**Author:** [@Andrew\_fg](https://discourse.mc-stan.org/u/Andrew_fg)\
**Replies:** 4\
**Last updated:** [January 13, 2025, 10:44am UTC](https://discourse.mc-stan.org/t/parameter-estimation-issue/37405 "2025-01-13T10:44:15Z")

</div>

Please share your Stan program and accompanying data if possible. Good morning everyone, I have a question, and I hope you can help me. Based on the BayesHMM package (An Introduction to BayesHMM • BayesHMM), I develo…

---

## [How exactly is ar\[1\] correlation reported?](https://discourse.mc-stan.org/t/how-exactly-is-ar-1-correlation-reported/37376)

<div class="topic-metadata">

**Author:** [@Tomas\_T](https://discourse.mc-stan.org/u/Tomas_T)\
**Replies:** 1\
**Last updated:** [December 21, 2024, 12:14am UTC](https://discourse.mc-stan.org/t/how-exactly-is-ar-1-correlation-reported/37376 "2024-12-21T00:14:26Z")

</div>

Using the ar(1) correlation structure, : library(brms) data("LakeHuron") LakeHuron \<- as.data.frame(LakeHuron) fit \<- brm(x ~ ar(p = 1), data = LakeHuron) summary(fit) the brms model reports it this way: Correlation …

---

## [Is it just very hard to estimate ARMA models?](https://discourse.mc-stan.org/t/is-it-just-very-hard-to-estimate-arma-models/21034)

<div class="topic-metadata">

**Author:** [@stevebronder](https://discourse.mc-stan.org/u/stevebronder)\
**Replies:** 6\
**Last updated:** [October 23, 2024, 6:33pm UTC](https://discourse.mc-stan.org/t/is-it-just-very-hard-to-estimate-arma-models/21034 "2024-10-23T18:33:40Z")

</div>

I mostly want a sanity check here that I’m not doing something stupid. The tl;dr is that I’m suprised when doing simulation for ARMA style models that you need a pretty large N to recover parameters in a meaningful way (…

---

## [Piecewise linear regression with horizontal shifts](https://discourse.mc-stan.org/t/piecewise-linear-regression-with-horizontal-shifts/36809)

<div class="topic-metadata">

**Author:** [@Loni92](https://discourse.mc-stan.org/u/Loni92)\
**Replies:** 5\
**Last updated:** [October 11, 2024, 10:15pm UTC](https://discourse.mc-stan.org/t/piecewise-linear-regression-with-horizontal-shifts/36809 "2024-10-11T22:15:00Z")

</div>

Hi all, I’ve been trying to simplify and modify the model described here, see section “2.4 Viral load and infectiousness time course”. From what I understand, this is a piecewise linear model with time series data from…

---

## [Incorrect number of categories with categorical\_lpmf for a mixture model](https://discourse.mc-stan.org/t/incorrect-number-of-categories-with-categorical-lpmf-for-a-mixture-model/35101)

<div class="topic-metadata">

**Author:** [@psyguy](https://discourse.mc-stan.org/u/psyguy)\
**Replies:** 3\
**Last updated:** [September 23, 2024, 1:27pm UTC](https://discourse.mc-stan.org/t/incorrect-number-of-categories-with-categorical-lpmf-for-a-mixture-model/35101 "2024-09-23T13:27:15Z")

</div>

Hi there, I am trying to specify a mixture time series model that involves a mixing discrete variables. I get the following error for all chains while fitting the model, which I cannot figure out how to deal with: SAMP…

---

## [Comparing brms models with unstr() covariance versus cosy() and ar() with loo](https://discourse.mc-stan.org/t/comparing-brms-models-with-unstr-covariance-versus-cosy-and-ar-with-loo/36342)

<div class="topic-metadata">

**Author:** [@qdread](https://discourse.mc-stan.org/u/qdread)\
**Replies:** 6\
**Last updated:** [August 24, 2024, 12:01am UTC](https://discourse.mc-stan.org/t/comparing-brms-models-with-unstr-covariance-versus-cosy-and-ar-with-loo/36342 "2024-08-24T00:01:37Z")

</div>

I am trying out residual covariance structures in brms. I have fit unstr(), cosy(), and ar(p=1) models to a bunch of example datasets in the agridat package. I uniformly find that the unstr() models perform best in LOO c…

---

## [Mvgam: an R package for time series modeling and forecasting](https://discourse.mc-stan.org/t/mvgam-an-r-package-for-time-series-modeling-and-forecasting/35065)

<div class="topic-metadata">

**Author:** [@nicholasjclark](https://discourse.mc-stan.org/u/nicholasjclark)\
**Replies:** 2\
**Last updated:** [June 26, 2024, 5:39am UTC](https://discourse.mc-stan.org/t/mvgam-an-r-package-for-time-series-modeling-and-forecasting/35065 "2024-06-26T05:39:51Z")

</div>

Happy to announce that I have released a new package to CRAN called mvgam. The goal of mvgam is to estimate parameters of Dynamic Generalized Additive Models (DGAMs) for time series with dynamic trend components. It…

---

## [Cross-conditional dependence in random walk models](https://discourse.mc-stan.org/t/cross-conditional-dependence-in-random-walk-models/34980)

<div class="topic-metadata">

**Author:** [@MigueBeneito](https://discourse.mc-stan.org/u/MigueBeneito)\
**Replies:** 1\
**Last updated:** [May 1, 2024, 6:45pm UTC](https://discourse.mc-stan.org/t/cross-conditional-dependence-in-random-walk-models/34980 "2024-05-01T18:45:18Z")

</div>

Hi, I have programmed two 1st-order random walk models that, in principle, should be equivalent but I obtain different results. The first model corresponds to a full-conditional formulation of a Poisson time series wher…

---

## [First order autoregressive model + noise, estimation fails with Stan](https://discourse.mc-stan.org/t/first-order-autoregressive-model-noise-estimation-fails-with-stan/34415)

<div class="topic-metadata">

**Author:** [@helske](https://discourse.mc-stan.org/u/helske)\
**Replies:** 1\
**Last updated:** [March 13, 2024, 12:41pm UTC](https://discourse.mc-stan.org/t/first-order-autoregressive-model-noise-estimation-fails-with-stan/34415 "2024-03-13T12:41:28Z")

</div>

I’m having trouble with estimating a simple AR(1) + noise model with Stan: set.seed(1) x \<- arima.sim(model = list(ar = 0.5), n = 500) y \<- 1 + rnorm(500, x, 0.5) model \<- " data { int\<lower=0\> T; vector\[T\] y; } …

---

## [Covariance issues with Dynamic Factor Model with large N](https://discourse.mc-stan.org/t/covariance-issues-with-dynamic-factor-model-with-large-n/33675)

<div class="topic-metadata">

**Author:** [@ceschi](https://discourse.mc-stan.org/u/ceschi)\
**Replies:** 7\
**Last updated:** [January 17, 2024, 11:52am UTC](https://discourse.mc-stan.org/t/covariance-issues-with-dynamic-factor-model-with-large-n/33675 "2024-01-17T11:52:17Z")

</div>

Hello, I am fairly new to Stan and I am experimenting with a Bayesian Dynamic Factor Model. The model has a large number of time series, N\>75, and I want to estimate K~5 factors that capture most of the variation of the…

---

## [How to model a lag function?](https://discourse.mc-stan.org/t/how-to-model-a-lag-function/33775)

<div class="topic-metadata">

**Author:** [@gregoryp](https://discourse.mc-stan.org/u/gregoryp)\
**Replies:** 0\
**Last updated:** [January 10, 2024, 12:45am UTC](https://discourse.mc-stan.org/t/how-to-model-a-lag-function/33775 "2024-01-10T00:45:53Z")

</div>

I am attempting to model the effects of drought on an ecological response variable. This is somewhat complicated, because the effect is believed to be an aggregate (smooth) function of predictors over an unknown time win…

---

## [Any work on (or pointers to) Bayesian updating with "forgetting"?](https://discourse.mc-stan.org/t/any-work-on-or-pointers-to-bayesian-updating-with-forgetting/26130)

<div class="topic-metadata">

**Author:** [@ssickels](https://discourse.mc-stan.org/u/ssickels)\
**Replies:** 14\
**Last updated:** [October 30, 2023, 7:25pm UTC](https://discourse.mc-stan.org/t/any-work-on-or-pointers-to-bayesian-updating-with-forgetting/26130 "2023-10-30T19:25:19Z")

</div>

I’ve developed some code that does periodic Bayesian updating: fitting a beta distribution to \[0,1\]-bounded time series data. I implemented “forgetting” at each update by expanding the posterior’s (phi and lambda’s) SDs …

---

## [Latent AR processes and observed linear combinations](https://discourse.mc-stan.org/t/latent-ar-processes-and-observed-linear-combinations/33171)

<div class="topic-metadata">

**Author:** [@blackrabite](https://discourse.mc-stan.org/u/blackrabite)\
**Replies:** 1\
**Last updated:** [October 27, 2023, 7:45pm UTC](https://discourse.mc-stan.org/t/latent-ar-processes-and-observed-linear-combinations/33171 "2023-10-27T19:45:41Z")

</div>

I have a model where there several latent unbserved AR processes with normal errors: x1\[t\] = mu1 + \\theta\_1 \* x1\[t-1\] + error\_x1 x2\[t\] = mu2 + \\theta\_2 \* x2\[t-1\] + error\_x2 x3\[t\] = mu3 + \\theta\_3 \* x3\[t-1\] + error\_x3 …

---

## [Problem With Partial Sum Function](https://discourse.mc-stan.org/t/problem-with-partial-sum-function/32353)

<div class="topic-metadata">

**Author:** [@PatrickStar](https://discourse.mc-stan.org/u/PatrickStar)\
**Replies:** 3\
**Last updated:** [August 21, 2023, 3:21pm UTC](https://discourse.mc-stan.org/t/problem-with-partial-sum-function/32353 "2023-08-21T15:21:45Z")

</div>

Hi, This post is a continuation of a previous post: Reduce\_sum question - General - The Stan Forums (mc-stan.org). Following the advice of @wds15, I am trying to use partial\_sum to evaluate a density, which looks like …

---

## [Reduce\_sum question](https://discourse.mc-stan.org/t/reduce-sum-question/32260)

<div class="topic-metadata">

**Author:** [@PatrickStar](https://discourse.mc-stan.org/u/PatrickStar)\
**Replies:** 6\
**Last updated:** [August 2, 2023, 3:53pm UTC](https://discourse.mc-stan.org/t/reduce-sum-question/32260 "2023-08-02T15:53:52Z")

</div>

Hi, I have a time-series model that I’m hoping to implement reduce\_sum in. I’ve got two scripts that analyze the same exact data and perform the same analysis, with the only difference being that one uses reduce\_sum and…

---

## [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…

---

## [Modelling a jump component](https://discourse.mc-stan.org/t/modelling-a-jump-component/31520)

<div class="topic-metadata">

**Author:** [@bkoval95](https://discourse.mc-stan.org/u/bkoval95)\
**Replies:** 2\
**Last updated:** [June 28, 2023, 11:50am UTC](https://discourse.mc-stan.org/t/modelling-a-jump-component/31520 "2023-06-28T11:50:54Z")

</div>

Dear All! I would like to ask a question. How to implement the following model in Stan? I have a time-series: y\_t = \\mu\_t + \\xi\_t J\_t + \\epsilon\_t, \\qquad \\epsilon\_t \\sim \\mathcal{N}(0,\\exp(h\_t/2)). I have no problem …

---

## [Bayesforecast 0.0.1 for time series modeling](https://discourse.mc-stan.org/t/bayesforecast-0-0-1-for-time-series-modeling/20408)

<div class="topic-metadata">

**Author:** [@asael\_am](https://discourse.mc-stan.org/u/asael_am)\
**Replies:** 2\
**Last updated:** [April 26, 2023, 11:00pm UTC](https://discourse.mc-stan.org/t/bayesforecast-0-0-1-for-time-series-modeling/20408 "2023-04-26T23:00:32Z")

</div>

I am happy to announce that the beta version of bayesforecast 0.0.1 is already on CRAN. bayesforecast is a package for Bayesian time series modeling using Stan. Currently, it supports Basic models such as ARIMA, AR…

---

## [Vectorized use of neg\_binomial\_2\_lpmf](https://discourse.mc-stan.org/t/vectorized-use-of-neg-binomial-2-lpmf/30552)

<div class="topic-metadata">

**Author:** [@jamesvrt](https://discourse.mc-stan.org/u/jamesvrt)\
**Replies:** 1\
**Last updated:** [March 3, 2023, 1:46pm UTC](https://discourse.mc-stan.org/t/vectorized-use-of-neg-binomial-2-lpmf/30552 "2023-03-03T13:46:19Z")

</div>

I’m having some difficulty creating a media mix model with a negative binomial distribution used to distribute the effect of marking spend on a given day to subsequent days. The following code with a double loop in the f…

---

## [Divergent transitions in Dynamic Nelson Siegel Model](https://discourse.mc-stan.org/t/divergent-transitions-in-dynamic-nelson-siegel-model/28874)

<div class="topic-metadata">

**Author:** [@dgerth5](https://discourse.mc-stan.org/u/dgerth5)\
**Replies:** 0\
**Last updated:** [September 17, 2022, 2:57am UTC](https://discourse.mc-stan.org/t/divergent-transitions-in-dynamic-nelson-siegel-model/28874 "2022-09-17T02:57:23Z")

</div>

Hello, I am attempting to fit a time series model for yield curves called the Nelson Siegel model. It is defined on the fifth page of this paper Dynamic Nelson Siegel Paper. I’m wanting to update the betas based on t…

---

## [A tail ESS warning against a local level model with an ordered logistic function](https://discourse.mc-stan.org/t/a-tail-ess-warning-against-a-local-level-model-with-an-ordered-logistic-function/27453)

<div class="topic-metadata">

**Author:** [@ytan](https://discourse.mc-stan.org/u/ytan)\
**Replies:** 4\
**Last updated:** [June 28, 2022, 11:44pm UTC](https://discourse.mc-stan.org/t/a-tail-ess-warning-against-a-local-level-model-with-an-ordered-logistic-function/27453 "2022-06-28T23:44:06Z")

</div>

Hi, I’m encountering the following tail ESS warning. Other warnings disappeared after I had tried several changes in the codes (e.g. setting weakly informative priors), but still this warning remains. Does anyone know a…

---

## [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…

---

## [Spectral Density Analysis of Time-Series: Resulting Posterior is Independent of Data](https://discourse.mc-stan.org/t/spectral-density-analysis-of-time-series-resulting-posterior-is-independent-of-data/27401)

<div class="topic-metadata">

**Author:** [@San0ix](https://discourse.mc-stan.org/u/San0ix)\
**Replies:** 4\
**Last updated:** [May 12, 2022, 7:11am UTC](https://discourse.mc-stan.org/t/spectral-density-analysis-of-time-series-resulting-posterior-is-independent-of-data/27401 "2022-05-12T07:11:52Z")

</div>

Hello everyone, I hope this problem isn’t too specific – as a beginner in Stan, I really cannot tell how or why my issue arises, so I don’t know how to simplify it. I’m currently working on applying Variational Inferenc…

---

## [Is the effective sample size estimator using the variogram in BDA3 always valid?](https://discourse.mc-stan.org/t/is-the-effective-sample-size-estimator-using-the-variogram-in-bda3-always-valid/26940)

<div class="topic-metadata">

**Author:** [@Carlos\_Parada](https://discourse.mc-stan.org/u/Carlos_Parada)\
**Replies:** 4\
**Last updated:** [March 28, 2022, 7:13am UTC](https://discourse.mc-stan.org/t/is-the-effective-sample-size-estimator-using-the-variogram-in-bda3-always-valid/26940 "2022-03-28T07:13:10Z")

</div>

The does not seem to be guaranteed positive definite: (However, I do expect the estimator to be positive definite most of the time, because of the practice of cutting off the sum after running into a negative autocova…

---

## [Soft k-means model syntax error](https://discourse.mc-stan.org/t/soft-k-means-model-syntax-error/25955)

<div class="topic-metadata">

**Author:** [@datarichard](https://discourse.mc-stan.org/u/datarichard)\
**Replies:** 3\
**Last updated:** [January 13, 2022, 6:37am UTC](https://discourse.mc-stan.org/t/soft-k-means-model-syntax-error/25955 "2022-01-13T06:37:58Z")

</div>

hi, I’m trying to work out how to use Stan for time series clustering. I thought I would start with the soft k-means example in the User guide and github. However it seems that array is not a valid syntax to declare ar…

---

## [Partially-fixed Gaussian-process prior for varying slopes model: HMC not progressing](https://discourse.mc-stan.org/t/partially-fixed-gaussian-process-prior-for-varying-slopes-model-hmc-not-progressing/25789)

<div class="topic-metadata">

**Author:** [@Marty](https://discourse.mc-stan.org/u/Marty)\
**Replies:** 2\
**Last updated:** [December 30, 2021, 10:42pm UTC](https://discourse.mc-stan.org/t/partially-fixed-gaussian-process-prior-for-varying-slopes-model-hmc-not-progressing/25789 "2021-12-30T22:42:59Z")

</div>

Hi all, I am a complete beginner to Stan, so apologies in advance if I have made an obvious mistake or asking a silly question. Set up I am attempting to fit a “rolling” regression model in which the slope parameter v…

---

## [Relative contribution of time-varying regression coefficients to time-varying empirical trend?](https://discourse.mc-stan.org/t/relative-contribution-of-time-varying-regression-coefficients-to-time-varying-empirical-trend/24665)

<div class="topic-metadata">

**Author:** [@Ilan\_Strauss](https://discourse.mc-stan.org/u/Ilan_Strauss)\
**Replies:** 1\
**Last updated:** [October 28, 2021, 9:39am UTC](https://discourse.mc-stan.org/t/relative-contribution-of-time-varying-regression-coefficients-to-time-varying-empirical-trend/24665 "2021-10-28T09:39:56Z")

</div>

Hi, We are running a panel hierarchical model of firms/companies. The two groups (or ‘levels’) by which our coefficients \`vary’ are country and year. This means we have time-varying coefficients. We are trying to expla…

[Next page](https://discourse.mc-stan.org/tag/time-series/178.md?match_all_tags=true&page=1&tags%5B%5D=time-series)
