# Timeseries binary-decision problem

**URL:** <https://discourse.pymc.io/t/timeseries-binary-decision-problem/17441>\
**Category:** version agnostic\
**Tags:** development, time\_series, modeling\
**Created:** [November 17, 2025, 8:39am UTC](https://discourse.pymc.io/t/timeseries-binary-decision-problem/17441 "2025-11-17T08:39:15Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tester](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/tester/32/9513_2.png) [@Tester](https://discourse.pymc.io/u/Tester)\
**Post date:** [November 17, 2025, 8:39am UTC](https://discourse.pymc.io/t/timeseries-binary-decision-problem/17441/1 "2025-11-17T08:39:15Z")

</div>

I have data from an experiment in which subjects repeatedly completed a specific task that required a forced binary decision (option A vs. B). I only observe this decision at the end of each recording. As predictors/IVs, I collect sensor data at ~100 Hz, which is usually changing rather slowly over time.

I would like to take the sensor data as predictors and develop a model of the decision-making process: the binary decision and its uncertainty. The model should then be able to predict the decision/probability and its uncertainty given new sensor data. I suppose what I need to use in PyMC is some sort of Bernoulli/Beta regression, but I am unsure how to best incorporate/address the time-dependency. Any thoughts/advice would be greatly appreciated. 🙂

---

<div class="post-metadata">

**Author:** ![ricardoV94](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/ricardov94/32/5775_2.png) [@ricardoV94](https://discourse.pymc.io/u/ricardoV94)\
**Post date:** [November 17, 2025, 11:39am UTC](https://discourse.pymc.io/t/timeseries-binary-decision-problem/17441/2 "2025-11-17T11:39:08Z")

</div>

Perhaps @jessegrabowski has some idea

---

<div class="post-metadata">

**Author:** ![jessegrabowski](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/jessegrabowski/32/5010_2.png) [@jessegrabowski](https://discourse.pymc.io/u/jessegrabowski)\
**Post date:** [November 17, 2025, 1:49pm UTC](https://discourse.pymc.io/t/timeseries-binary-decision-problem/17441/3 "2025-11-17T13:49:46Z")

</div>

If you could directly observe the “intent to choose A”, what function would you use to connect the sensor readings to that intent? The answer to that question will guide how to build a latent timeseries model.

---

<div class="post-metadata">

**Author:** ![Tester](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/tester/32/9513_2.png) [@Tester](https://discourse.pymc.io/u/Tester)\
**Post date:** [November 17, 2025, 3:23pm UTC](https://discourse.pymc.io/t/timeseries-binary-decision-problem/17441/4 "2025-11-17T15:23:28Z")

</div>

Thanks for the prompt response. And good question. One option could be that the sensor readings directly map to the decision/probability, e.g., through some linear/logistic function. But I could also imagine that the sensor readings resemble pieces of evidence that, when accumulating them over time, drive the decision towards either A or B.

---

<div class="post-metadata">

**Author:** ![jessegrabowski](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/jessegrabowski/32/5010_2.png) [@jessegrabowski](https://discourse.pymc.io/u/jessegrabowski)\
**Post date:** [November 17, 2025, 3:51pm UTC](https://discourse.pymc.io/t/timeseries-binary-decision-problem/17441/5 "2025-11-17T15:51:54Z")

</div>

If there’s no accumulation process, there’s no time series model (since only the sensor reading at the time of the decision would matter). So I think it would be good to think about how that accumulation should look, then you can take the last value of the latent process and use it as a logit for the bernoulli probability.

---

<div class="post-metadata">

**Author:** ![Tester](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/tester/32/9513_2.png) [@Tester](https://discourse.pymc.io/u/Tester)\
**Post date:** [November 17, 2025, 6:41pm UTC](https://discourse.pymc.io/t/timeseries-binary-decision-problem/17441/6 "2025-11-17T18:41:09Z")

</div>

Sorry, I missed one possibly important detail: I don’t know when exactly subjects made the decision, I can only observe it towards the end of each recording, but the subject likely decided already seconds earlier.

---

<div class="post-metadata">

**Author:** ![bob-carpenter](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/bob-carpenter/32/8124_2.png) [@bob-carpenter](https://discourse.pymc.io/u/bob-carpenter)\
**Post date:** [November 21, 2025, 3:43pm UTC](https://discourse.pymc.io/t/timeseries-binary-decision-problem/17441/7 "2025-11-21T15:43:24Z")

</div>

One approach to use here is to do what Don Rubin does and ask yourself what you’d do if you were able to observe all the data. Here, what you have is a sequence of covariates x\_1, \ldots, x\_N and you know a decision of y was made at some step n \leq N. You have the problem that you don’t observe n, which isn’t a problem in either Bayesian or frequentist inference because you can marginalize the likelihood.

A simple way to do all of this conceptually is to let \phi = f(x, \theta) \in \Delta^{N-1} be a simplex (i.e., N non-negative values that sum to 1) defined as a function of the covariates x\_{1, \ldots, N} and the model parameters \theta (presumably in a regression that only depends on the past at each point, perhaps as a sequential Bernoulli decision process), so that your unknown decision time is generated

- n \sim \textrm{categorical}(\phi)

Then if you have the outcome generated conditional on the choice time as

- Y \sim p(x, n, \theta),

presumably also only depending on the values of x\_{1, \ldots, n}, then you can marginalize out the unobserved n to get

- p(Y | x, \theta) = \sum\_{n=1}^N p(Y, n \mid x, \theta).

You can define a simplex sequentially through a sequential decision process, for example, letting

\Pr[n = n' \mid n \geq n'] = g(x\_{1, \ldots, n'}, \theta),

and then multiplying out to get

- \Pr[n = 0] = 0
- \Pr[n = n'] = \Pr[n = n' \mid n \geq n'] \cdot \prod\_{n'' \< n'} (1 - \Pr[n = n'']).

---

<div class="post-metadata">

**Author:** ![Tester](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/tester/32/9513_2.png) [@Tester](https://discourse.pymc.io/u/Tester)\
**Post date:** [April 9, 2026, 5:51pm UTC](https://discourse.pymc.io/t/timeseries-binary-decision-problem/17441/8 "2026-04-09T17:51:32Z")

</div>

Thanks for these detailed thoughts, and sorry for the late follow-up. It’s taken me some time to digest this, too. Are you aware of any related examples already implemented, or do you have some ideas on how to implement this in PyMC?

I also wonder if this would work well with my 100 Hz frequency data or if I need to downsample the data first.

---

<div class="post-metadata">

**Author:** ![bob-carpenter](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/bob-carpenter/32/8124_2.png) [@bob-carpenter](https://discourse.pymc.io/u/bob-carpenter)\
**Post date:** [April 9, 2026, 6:17pm UTC](https://discourse.pymc.io/t/timeseries-binary-decision-problem/17441/9 "2026-04-09T18:17:48Z")

</div>

Here’s a PyMC tutorial that does the coal mining example by discrete sampling:

> **[Introductory Overview of PyMC — PyMC 0 documentation](https://www.pymc.io/projects/docs/en/stable/learn/core_notebooks/pymc_overview.html)**

I believe that’s what I based my Stan case studies on here:

> **[Latent Discrete Parameters](https://mc-stan.org/docs/stan-users-guide/latent-discrete.html)**

Then there’s another PyMC tutorial about marginalizing discrete parameters and goes over the coal mining change point example again:

> **[Automatic marginalization of discrete variables](https://www.pymc.io/projects/examples/en/latest/howto/marginalizing-models.html)**
>
> PyMC is very amendable to sampling models with discrete latent variables. But if you insist on using the NUTS sampler exclusively, you will need to get rid of your discrete variables somehow. The b...

---

<div class="post-metadata">

**Author:** ![Tester](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/tester/32/9513_2.png) [@Tester](https://discourse.pymc.io/u/Tester)\
**Post date:** [April 9, 2026, 7:19pm UTC](https://discourse.pymc.io/t/timeseries-binary-decision-problem/17441/10 "2026-04-09T19:19:30Z")

</div>

Excellent, thanks so much for the prompt help. I will go through these and see if there is sth. reusable for my problem.
