# Predicting amount of purchases

I have a problem that requires the prediction of the number of customers who will buy a product every month segmented on the date they came into the site. For example, my data looks like:

Customer | Start Date | Purchase Date | Predictors ...
A       2010-01-11     2010-02-01
B       2010-01-11        NULL
C       2010-01-11        NULL
D       2010-01-11     2010-01-15
E       2010-01-12     2010-01-18
F       2010-01-12        NULL
G       2010-01-12     2010-03-02
H       2010-01-13        NULL
I       2010-01-13        NULL
...


In the example, 2 customers converted from 2010-01-11 segment whereas, no customers in the 2010-01-13 segment bought the product.

I think there are multiple ways to approach this problem but cannot decide on a method. My question is three-fold.

1) Survival Analysis/Poisson Regression: I could use survival analysis to predict purchase but this would not help solve the time to purchase problem for customers who did purchase. Instead, I could try Poisson regression but I'm not sure how this would answer the purchase/non-purchase problem. Would a nested logistic model be appropriate in this case?

2) Improving prediction: I would like my predictor to keep getting more accurate as every month passes because the cumulative number of customers predicted should never decrease month-on-month. Would any model be more suitable to this assumption?

3) Time-Series for date segment: Instead of predicting for a customer, could I predict the number of customers who do purchase by date segment by month? Similar to obtaining multiple time-series and bootstrapping.

Update: It seems that a hurdle model approach is suited well to this problem. However, I have a problem.

1. My data does not have any 0 purchase dates but NULL which represents not purchasing. This means that the time to purchase for a nonpurchasing user is NULL. How can I transform my data so that there is a 0 hurdle?

• You need to clarify what your goal is. Is it to predict sales for next month (so the company can have adequate stock), or to predict conversion rates, or to look for the effects of special deals or other A/B kind of issues? Commented Sep 3, 2016 at 16:12
• @Wayne my goal is to predict the sales every month after a batch of customers first come to our site. Commented Sep 4, 2016 at 0:56

It sounds like you would like to make a "two-stage" prediction about each customer:

1. Does the customer buy the product at least once after signing up?
2. If so, in how many months does the customer buy the product?

This is a perfect use case for a "hurdle model", which has a two-stage specification that mirrors your problem statement. Let $Y$ denote the number of months in which a user buys the product after signing up. Then a hurdle model has the following general specification: \begin{align} Y &\sim \operatorname{Bernoulli}\left(1 - \pi\right) \\ Y=y\ \vert\ Y \neq 0 &\sim D\left(\theta\right) \end{align}

for some distribution $D$ parameterized by $\theta$. In your case, it makes sense to use a Poisson hurdle model, in which $D$ is a Poisson distribution with parameter $\lambda$.

McDowell (2003) provides an excellent introduction to hurdle models, and specifically Poisson hurdle models, so I won't go into more detail here. There is also a lot of useful information in What is the difference between zero-inflated and hurdle distributions (models)? and its answers. Among some of the gems you'll find in there are a link to an R package called pscl which contains functions for fitting hurdle models.

Reference: McDowell, Allen. (2003). "From the help desk: hurdle models." The Stata Journal, 3(2), 178-184. Available online at http://ageconsearch.umn.edu/bitstream/116071/2/sjart_st0040.pdf

• Thank you for your suggestion. This is really interesting and fits exactly what I'm interested in. However, I have somewhat non-poisson distributed time to purchases e.g. bumps every 7 days. Is it possible to take this into account in hurdle models? Also, how do I take into account the NA as these cannot eb set to 0. Commented Sep 6, 2016 at 11:38
• @Black in principle you can use any distribution as $D$, not just Poisson. I also think I misunderstood your problem. It looked like you were asking for purchase counts, not time to purchase. You wouldn't use a hurdle model for time to purchase, you would use a survival model. Commented Sep 8, 2016 at 19:00