In this recipe, we will attempt to predict FC Barcelona's goals throughout the 2017/18 season, using some covariates and the club's previous goals. This will expose the many difficulties that exist when working with sports; even after using several important covariates, we won't be doing any better than just using the average for FC Barcelona's goals for that season (2.60):
- First, we load the dataset and create a dummy variable for home/away. We transform the dates, so we can compute the time difference between two games (we suspect that the number of days has a positive effect on the number of goals):
library("tscount") library(dummy) library(dplyr) data = read.table("./E1.txt",sep="\t",head=T) data$home_away = ifelse(data$ha ...