I'm trying to backtest a sports betting model that calculates probabilities based on last 5 games.
Here I have all the games from last season, but I'm having problems wrapping my mind around how I should approach this.
Each team is given a predetermined ranking id (1,2,3) that'll reflect whether the team is worse, even, or better than the current opponent :
1 Team is Worse 2 Team is Even 3 Team is Better
The model itself calculates:
Wins Losses Goals For Goals Against
These categories will give out points based on what category their opponent was that they won/lost to.
Example: Team A vs. Team B
- Team A is categorized worse than team B
- Team A gets 1,3 points for scoring a goal (1*1,3)
Example: Team A vs. Team B
- Team A is categorized better than Team B
- Team A gets 1 point for scoring a goal
Pseudo:
I can do this team by team basis, but I would need to iterate through their match history in 5 indexed rows at a time, and then counting the probabilities for the 6th match. Here's an example what indexed rows I'd need to calculate the probabilities for Team A's match number 6 and 7
To calculate match number 6, I need rows: 0,1,2,3,4
To calculate match number 7, I need rows: 1,2,3,4,5
....So basically last 5 matches needs to be accounted.