# Probability of account win/loss using Bayesian Statistics

I am trying to estimate the probability of winning or losing an account, and I'd like to do this using Bayesian Methods. I'm not really that familiar with these methods, but I think I understand the general idea.

I know some information about losses and wins. Wins are usually characterized by some combination of activities; losses are usually characters by a different combination of activities. I'd like to be able to get some posterior probability of whether or not a new observation will be won or lost based on the current number of activities that are associated with that account.

Here is an example of my data: (This is just a sample for simplicity)

 Email  Call    Callback    Outcome
14     9           2          1
3     2           4          0
16    14           2          0
15     1           3          1
5     2           2          0
1     1           0          0
10     3           5          0
2     0           1          0
17     8           4          1
3    15           2          0
17     1           3          0
10     7           5          0
10     2           3          0
8     0           0          1
14    10           3          0
1     9           3          1
5    10           3          1
13     5           1          0
9     4           4          0


So from here I know that 30% of the observations have an outcome of 1 (win) and 70% have an outcome of 0 (loss). Let's say that I want to use the other columns to get a probability of win/loss for a new observation which may have a small number of events (emails, calls, and callbacks) associated with it.

Now let's say that I want to use the counts/proportions of the different events as priors for a new observation. This is where I start getting tripped up. My thinking is to create a dirichlet distribution for wins and losses, so two separate distributions, one for wins and one for losses. Using the counts/proportions of events for each outcome as the priors. I guess I'm not sure how to do this in R. I think my course of action would be estimate a dirichlet distribution (since I have 3 variables) for each outcome using maximum likelihood. I've been trying to use the dirichlet.simul and dirichlet.mle functions from the sirt package in R. I'm not sure if I need to simulate one first?

Another issue is once I have this distribution, it's unclear to me how to get a posterior distribution of a new observation. I've read several papers and can't seem to find a straightforward process on how to do this. (Or maybe there's some holes in my understanding). Any pushes in the right direction would be greatly appreciated.

This is the code I've tried so far:

### FOR WON ACCOUNTS
set.seed(789)
N <- 6
probs <- c(0.535714286, 0.330357143, 0.133928571 )
alpha <- probs
alpha <- matrix( alpha , nrow=N , ncol=length(alpha) , byrow=TRUE  )
x <- dirichlet.simul( alpha )
dirichlet.mle(x)
$alpha  0.3385607 0.2617939 0.1972898$alpha0
 0.7976444

$xsi  0.4244507 0.3282088 0.2473405 ### FOR LOST ACCOUNTS set.seed(789) N2 <- 14 probs2 <- c(0.528037383,0.308411215,0.163551402 ) alpha2 <- probs2 alpha2 <- matrix( alpha2 , nrow=N , ncol=length(alpha2) , byrow=TRUE ) x2 <- dirichlet.simul( alpha2 ) dirichlet.mle(x2)$alpha
 0.3388486 0.2488771 0.2358043

$alpha0  0.8235301$xsi
 0.4114587 0.3022077 0.2863336


Not sure if this is a correct approach or how to get posteriors from here. I realize all the outputs look similar across won/lost accounts. I just used some simulated data to represent what I'm working with.