Torvaney / regista

An R package for soccer modelling
https://torvaney.github.io/regista/
GNU General Public License v3.0
85 stars 8 forks source link

Informative error message when predicting with different factor levels #22

Closed Torvaney closed 5 years ago

Torvaney commented 6 years ago

A more informative error message when you try to predict.dixoncoles with new (team) factor levels would be nice:

library(tidyverse)
library(regista)

fit <- suppressWarnings(
  dixoncoles(hgoal, agoal, home, away, data = premier_league_2010)
)

newdata <- 
  premier_league_2010 %>% 
  filter(home != "Arsenal", away != "Arsenal") %>% 
  factor_teams(c("home", "away"))

predict(fit, newdata = newdata)
#> Error in rate_params %*% t(modeldata$mat1): non-conformable arguments