I’m looking to build an ARIMA model in R to help me predict the number of shots a football player is going to take in a game.

I have last season's data to analyse to determine the optimal lags for my AR and MA parameters. I have a data frame in R, with the columns for the player name, date of match and the number of shots.

Unfortunately, I only have a maximum 38 data points for each player which isn’t enough to build a statistically confident model. I suspect I need a way to analyse the data holistically/all-at-once to help me determine the optimal lags.

I don’t, however, know how to do that or even if this is a statistically sound technique.

At the moment I am just analysing my residuals (which have come from a linear regression with independent variables such as Home/Away and Team Possession) with code such as the following:

arima(residuals, order=c(3,0,0))

Is there a way to instruct R to perform this ARIMA analysis whilst looking at lots of mini-groups (where the groups are categorised by player name)?

Any help would be much appreciated.


  • $\begingroup$ Are you asking how to write a loop to perform the same operation on multiple objects? Or something else? $\endgroup$ – Richard Hardy Aug 3 '15 at 17:10
  • $\begingroup$ @RichardHardy Hi Richard, almost but not quite. Yes I want it to loop over each group, but I also want the optimal lags to be based on all of the mini groups (a one size fits all approach) and not separate lags for each mini group. I'm not sure if this possible and/or mathematically sound though. $\endgroup$ – Will T-E Aug 4 '15 at 11:17
  • $\begingroup$ If you have a subject-matter argument for why each group should have the same ARIMA order, then OK. If not, then it does not sound too convincing. But before you proceed, what is the distribution of the data? If it is discrete with few possible values, then ARIMA may not be a suitable model. $\endgroup$ – Richard Hardy Aug 4 '15 at 13:38
  • $\begingroup$ @RichardHardy. The dataset is discrete with about 20 possible values, I am happy with a continuous result though.So it's possible for a footballer to take up to about 20 shots a game but I don't mind if the time series gives me a prediction of, say, 6.8 crosses in the next game. $\endgroup$ – Will T-E Aug 5 '15 at 20:12
  • $\begingroup$ OK, I suppose 20 different values is enough for ARIMA. $\endgroup$ – Richard Hardy Aug 6 '15 at 9:30

If you really want the same model order to fit all the players, you could do the following.

  1. Decide the order or integration, I suppose it is I(0).
  2. Define the pool of candidate models, e.g. { ARIMA(0,0,0), ARIMA(0,0,1), ARIMA(1,0,0), ARIMA(1,0,1) }.
  3. Estimate each model on each player's data (it will take two for loops nested in each other, one across models and the other across players), obtain AIC of each model.
  4. See which model order gives the lowest average AIC when averaged over all players. This will be the model order you will choose.

But I would also consider allowing for different model orders for different players. Why not try function auto.arima from "forecast" package for each player separately; auto.arima usually works quite well.

You could compare both methods (1. the same order for all players, 2. different orders for different players) by splitting your data into a pseudo "in-sample" (e.g. first 33 values for each player) and pseudo "out-of-sample" (e.g. last 5 values for each player) and see which method applied on the "in-sample" data produces better forecasts of the "out-of-sample" data.

  • $\begingroup$ Do you think I should let the coefficients be automatically determined for each player or pre-determine the coefficients and then apply these, as well as the model order (e.g. 1,0,1 with a ar1 coefficient of 0.6 and ma1 coeff of -0.3) My observations for each player are currently quite small, about 11 observations (but about 280 players), so it feels very dangerous to let the coefficients be determined on such small amounts of observations. $\endgroup$ – Will T-E Aug 23 '15 at 11:27
  • $\begingroup$ Sorry, I am travelling and very busy these days. If I find a minute, I will try to answer, but I cannot promise. $\endgroup$ – Richard Hardy Aug 24 '15 at 8:51
  • $\begingroup$ No problem, safe travels. $\endgroup$ – Will T-E Aug 24 '15 at 20:32
  • $\begingroup$ Sorry for such a long delay! There were too many things happening at once. The question you have is rather empirical, and ideally you would test and see which of the candidate techniques works best. E.g. try forecasting the last value based on the first 10 values using the two methods, and see which works better. My first guess is that if you only have 11 observations per player, then it may be reasonable not to allow for different coefficient values for each player (so your gut feeling coincides with my gut feeling). $\endgroup$ – Richard Hardy Sep 1 '15 at 19:51
  • $\begingroup$ Many thanks for your thoughts on this, makes sense and great to get another opinion. I'm now struggling to find a way to pre-specify the coefficients for ARIMA in R. I have had a look through the help section for the arima() {stats package} and the Arima() {forecast package} but can't see a way to do it. Any ideas on this? $\endgroup$ – Will T-E Sep 2 '15 at 20:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.