# Predict Basketball Games with Log5 formula

**R – Predictive Hacks**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

We have provided an example of how to get started with predictive models for NBA Games. In this post, we will show how you can get a rough estimate of the final outcome of the game by using the Log5 formula and the Beta Distribution. For this example, we will consider the game, Dallas Mavericks (away) vs Portland Trail Blazers (home).

## Predictions with the Log5 Formula

The Log5 formula returns the probability that **Team A** will win the game against **Team B** based on teams’ win rate. The Log5 formula is:

\(P_{A>B}=\frac{P_A-P_A \times P_B}{P_A+P_B-2 \times P_A \times P_B}\)

A few notable properties exist:

- If PA=1, Log5 will always give A a 100% chance of victory.
- If PA=0, Log5 will always give A a 0% chance of victory.
- If PA=PB, Log5 will always return a 50% chance of victory for either team.
- If PA=0.5, Log5 will give A a 1-PB probability of victory.

In order to calculate the probabilities using the Log5 formula, we need to take into consideration the home and the away. A good approach is to take the following weights:

- 60% by taking into account the Home and Away Win Rate
- 30% by taking into account the Overall Win Rate
- 10% by taking into account the Last 10 Games Win Rate

Let’s get these Win Rates:

- Portland Home = 14-7 (66.6%); Dallas Away = 10-10 (50%)
- Portland Total = 25-21 (61%); Dallas Total = 21-19(52.5%)
- Portland Streak = 7-3 (70%); Dallas Streak = 6-4 (40%)

Now we are ready to calculate the Probability of Portland defeating Dallas

Por_Home=14/21 Dal_Away=10/20 Por_Total=25/41 Dal_Total=21/40 Por_Streak=7/10 Dal_Streak=6/10 log5<-function(home, away) { prob<-(home-home*away)/(home+away-2*home*away) prob } prob<-0.6*log5(Por_Home,Dal_Away) + 0.3*log5(Por_Total,Dal_Total) + 0.1*log5(Por_Streak,Dal_Streak) prob

**Output:**

[1] 0.6365786

So, according to our logic the weighted Log5 the probability of **Portland to Win the game is 63.65%**.

**leave a comment**for the author, please follow the link and comment on their blog:

**R – Predictive Hacks**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.