15

I have a binary time series with 1 when the car is not moving, and 0 when the car is moving. I want to make a forecast for a time horizon up to 36 hours ahead and for each hour.

My first approach was to use a Naive Bayes using the following inputs: t-24 (daily seasonal), t-48 (weekly seasonal), hour of the day. However, the results are not very good.

Which articles or software do you recommend for this problem?

whuber
  • 281,159
  • 54
  • 637
  • 1,101
Ricardo Bessa
  • 151
  • 1
  • 3
  • Have you considered a hidden markov model? – Ram Ahluwalia Sep 02 '11 at 03:25
  • Thanks for the answers. But there is any software package already available with some implementations? I have searched in R, but I only found the VLMC package. Thanks, Ricardo Bessa –  Sep 02 '11 at 18:17
  • Ricardo, you should edit your question with this additional information instead of adding it as an answer. Thanks, and welcome to the site! – Aaron left Stack Overflow Sep 02 '11 at 18:26
  • Are there really two types of 1's in your data? That is, 1 meaning the car could be moving but is not versus 1 meaning that your car really could not be moving at this time. That would be called one-inflation (it's usually zero-inflation). If so, you need to model when the car can be moving or not versus when it might be moving but is not. – Wayne Sep 02 '11 at 19:13
  • In this case there is only 1, meaning that the car is not moving. Perhaps hidden markov models can be a good option. – Ricardo Bessa Sep 03 '11 at 00:13
  • see if this helps http://www.math.bme.hu/~morvai/publications/papers/MorvaiWeissActApplMath2003ARX.pdf good day – Mithun Ashok Sep 02 '11 at 03:22
  • https://towardsdatascience.com/arima-for-classification-with-soft-labels-29f3109d9840 – Marco Cerliani Mar 16 '21 at 13:24

4 Answers4

7

You can use generalized ARMA (GLARMA) models. See, for example, Kedem and Fokianos (2002), Regression Models for Time Series Analysis.

See also R package glarma (on CRAN)

kjetil b halvorsen
  • 63,378
  • 26
  • 142
  • 467
hbaghishani
  • 121
  • 2
4

The R package bsts allows you to estimate Bayesian structural time series models with binary targets by setting family = 'logit'. Note, though, that these models often require longer runs than Gaussian data (e.g., niter = 10000).

ulfelder
  • 485
  • 3
  • 12
3

The Hidden markov model is the sequential version of Naive Bayes. In naive bayes, you have a label with several possible values (in your case 0/1) and a set of features. The value for y is selected by modeling p(features | label) * p(label).

In a hidden markov model, a sequence of labels is predicted by modeling p(label | previous label) and P(features | label).

Alex Lamb
  • 131
  • 1
  • 5
2

How about using logistic regression with some time lags (daily, weekly) as predictors? (most statistical software packages have logistic regression). It's a bit of shooting in the dark -- can you share the data or a plot?

Galit Shmueli
  • 1,090
  • 8
  • 10