# Bayesian approach to interval prediction?

I am working on a problem involving understanding/predicting customer frequency. The data I am working with is structured as a series of interval days between orders:

{
'customer_id: 'A',
'order_n' : [1,2,3,4,5,6],
'interval_days': [Null, 7, 10, 2, 30, 3],
}...


I would like to perform some analysis that covers the following aspects:

• Captures uncertainty/volatility for customers with thin order history. (when n=2, stdv is meaningless)
• Given order interval history $${I1, I2, I3, .. In}$$, what is the Probability Distribution of $$I_{n+1}$$?
• Can the PDF above be used to predict churn? e.g, $$Pr(I_{n+1}=NULL)$$ )
• Is there a method that takes into account periodicity, without requiring time series/date analysis?

I think this problem is a good candidate for the Bayesian framework, however I don't have much experience with application here. Looking forward to the community's feedback. Thanks!

Since your are measuring time between transactions as an integer, you can construct a hierarchical Poisson model. Let $$N$$ be the number of customers, each with $$n_i$$ observations, $$i = 1 \dots N$$. Then construct a model like

$$I_{n_i} \sim \operatorname{Poisson}(\lambda_i)$$

$$\lambda_i \sim P(\Lambda) \quad i = 1 \dots N$$

You will have to decide on an appropriate prior for the $$\lambda_i$$. If you choose a gamma distribution, then the model is like a negative binomial regression.

Anyway, so this model says that the times between transactions are Poisson distributed with parameter $$\lambda_i$$. The parameter $$\lambda_i$$ will be different for each customer, but will be conceived as coming from a population distribution $$P(\Lambda)$$. If customers have thin history, then their $$\lambda$$ will be regularized to the posterior mean of the population distribution.

Since this is a generative model, you can sample from the posterior to determine the probability of $$I_{n_i+1}$$.

Churn also follows naturally from this model. It is up to you to define what a "churn" means in non-contractual retail settings, but one definition I have used before is as follows:

• Determine the 90th percentile of each customer's between time transaction. For argument's sake, 'let's say it is 10 days. This means that 90% of the time, they will buy again within 10 days of their last purchase.
• If the customer has not purchased within this time, then they are considered churned.

If you want to account for periodicity, you'll need some more advanced modelling.