I want to determine the likelihood someone purchases my product, given three binary inputs: whether the prospective buyer is female, has an income above $75k, and owns a cat. However, I only have aggregated data on my sample, so data like this, in a sample of 1,000 individuals:

Rate of females (females who purchased): 53% (75%)
Rate of income above $75k (income above $75k who purchased): 24% (50%)
Rate of cat ownership (cat owners who purchased): 10% (5%)

The overall event rate (purchasing my product) is 10%. I want to use these priors to estimate at an individual level whether someone will buy my product. If I had independent and dependent variables at an individual level, I would just use a logistic regression (or some other classification model). However, since these data are aggregated, I'm thinking I'll have to use something like Bayes' Theorem to "back into" a logit model.

I want to model this simple example and extend the approach to all possible combinations of these binary inputs in my "dataset": P(purchase | female & income above $75k). I don't think the solution to this problem is as simple as P(purchase | female) * P(purchase | income above $75k) = 0.75 * 0.5 = 0.375, is it?


1 Answer 1


First of all, if you only have aggregated data, there's no meaningful way of deaggregating it. However with the data you have, you are not totally doomed.

What you have is the marginal probability of making a purchase $P(purchase) = 0.1$, the conditional probabilities $P(purchase|female) = 0.75$, and accompanying marginal probabilities $P(female)$, etc. First of all, you could use Bayes theorem to reverse the conditionals, since you have all the data needed

$$ P(female|purchase) = \frac{P(purchase|female)\,P(female)}{P(purchase)} $$

What you would like to calculate is probabilities of a purchase in a specific scenarios, e.g. $P(purchase|female,income >\$75k, cat\, owner)$, the problem is that you don't know the joint distribution, only the individual conditional probabilities. You can't get the exact joint distribution from the individual probabilities, however recall that if the variables were independent, then $P(A,B)= P(A)\,P(B)$, and this property is used by naive Bayes algorithm. In naive Bayes, we make the naive assumption of independence (naive, since it would almost always be wrong) to approximate the distribution. We do this by applying Bayes theorem

$$ P(y|x_1,x_2,...,x_k) \propto P(y) \prod_{i=1}^k P(x_i|y) $$

You have all the pieces needed to use naive Bayes algorithm with your data. It won't give you precise estimates of the probabilities, but in many cases, it would be enough for making classifications. To classify, you just need to pick the class that has highest a posteriori probability, i.e. you classify $y=1$ if $P(y=1|x_1,x_2,...,x_k) > P(y=0|x_1,x_2,...,x_k)$. You don't even need specialized software in here, this can be calculated by pen and paper, or in Excel.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.