# Build a regression model with multiple small time series

For a personal project, I've built a dataset of hockey players' statistics over the time. I am looking for insights as to how I should model my predictive model (lol). The model would be used to predict how much points a player would be expected to produce with regards to his previous performances.

To keep it simple, let's keep only the three most "important" columns for my dataset (there is a little more features than that but I don't think they are necessary for the problem) :

PlayerId | Points | Year

Now, I have tried to use the machine learning algorithms I know but :

• The data behaves kind of like a time series. Let's say I have 10k players, well those players have stats over the years (sometimes from season 2005 to 2017, others from 2009-2010, well you get the point). Considering this relation between rows (For example playerId 1, Year 2005 and playerId 1, Year 2006), I can't use most of the algorithms I know because this logic would be thrown out the window and I think it's an important one.

• Considering the data is related over time for some rows, I don't think I can really model it as an unique time series. There are small time series into the dataset, per players, but I certainly don't have enough data to treat it like such (With one row per player per year, at max I'd have 15 rows maybe for a player, which isn't enough to build a good prediction).

Considering these two points, I'm pretty much stuck without a solution.

I've thought about merging all the rows in one, so I'd have :

PlayerId | Points2005 | Points2006 | etc.. but it doesn't make much sense since we loose the notion of time.

I also considered that I could make a predictive model for all the players individually then use the weights I'd find to make another predictive model, but I'm very unsure as to how this would turn out.

I'm just looking for a small tip to push me in the right direction, whether it's pure statistics related or a machine learning algorithm.

• Not quite what you asked for, but David Robinson has an excellent series of blog posts on using Bayesian techniques for baseball statistics. You can find all the blog posts through here: varianceexplained.org/r/simulation-bayes-baseball Some of these may point you toward a useful way to analyze your own data. Good luck! – Maurits M Jun 26 '18 at 12:46
• why dont you ignore the exact year? Dont apply for example points in year "2015" or year "2016". Just use "Player x's points in his first year" and "Player x's points in his second year" and so on. No matter when a player y started his career, he surely has a "first" and "second" year in his career as well. Hope this helps. – flobrr Jun 26 '18 at 15:37
• Could you post some (subset of) data, so people can experiment? – kjetil b halvorsen Jun 26 '18 at 20:24

I'd consider a mixed model with an effect of time-in-career (maybe an additive/smooth term to allow for nonlinear effects) and a random effect of (time-in-career|player), which allows for variation in the pattern for different players. That doesn't explicitly consider number of points in the previous year, but it seems like a reasonable start, and handles the temporal aspect and the grouping of data within players.

this example model of rat growth curves is somewhat different from your example (focus on inference about treatments rather than prediction of individuals; small number of subjects, large number of points per subject relative to your data) but suggests that

mgcv::gam(points~careertime+s(careertime)+
s(careertime,player,bs='fs'),
data=dd, method="REML")


would be a plausible first model. You might want to add s(year,bs="re") to include a random effect of calendar year, and I'd encourage you to use any other covariate/grouping information you have (team, age, ...)

• I'm sorry, but I'm probably too much of a beginner in the field to fully understand your answer. Obviously nothing stops me from doing my own researches based on this, but if you feel like expanding your answer a little bit it would be tremendously helpful. – IEatBagels Jun 26 '18 at 18:24
• @TopinFrassi I'd recommend browsing some of the other content on mixed models here at stats.SE, in particular other answers by Ben Bolker, to get some background. – Bryan Krause Jun 28 '18 at 19:45