# Forecasting binary time series

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?

• see if this helps math.bme.hu/~morvai/publications/papers/… good day – Mithun Ashok Sep 2 '11 at 3:22
• Have you considered a hidden markov model? – Ram Ahluwalia Sep 2 '11 at 3: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 – user6145 Sep 2 '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 2 '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 2 '11 at 19:13

## 4 Answers

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)

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).

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?

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).