Torvaney / regista

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

Non-list contrasts argument ignored while modeling #35

Open hmantovani opened 12 months ago

hmantovani commented 12 months ago

I'm trying to model the Brasileirão 2023 league with the results directly out of the FBRef site, but I can't create the model for some reason I do not understand. I'm getting this message: In model.matrix.default(~values - 1, model.frame(~values - 1), contrasts = FALSE) : non-list contrasts argument ignored What could be happening? df is a dataframe with the columns home, hgoal, away, agoal for all the Brasileirão matches

df <-
  worldfootballR::fb_match_results(
    country = "BRA",
    gender = "M",
    season_end_year = 2023,
    tier = "1st") %>%
  janitor::clean_names() %>%
  regista::factor_teams(c("home", "away")) %>%
  rename(hgoal = home_goals,
         agoal = away_goals) %>%
  select(10:11, 13:14)

unplayed_games <- df %>% filter(is.na(hgoal) & is.na(agoal))
played_games <- df %>% filter(!is.na(hgoal) & !is.na(agoal))
model <- dixoncoles(hgoal, agoal, home, away, data = played_games)

It's also happening to the default premier_league_2010 data. Could it be some package conflict?

Torvaney commented 11 months ago

Hello,

This is because the package calls the model.matrix function with the argument contrasts = FALSE. This is a mistake on my part - the contrasts argument (actually constrasts.arg) should be a list, not TRUE/FALSE. This results in a warning being shown in recent versions of R (3.6+, I think), but as far as I know, it shouldn't actually cause issues (please let me know if this is not correct).

I know it's not great to have confusing warnings thrown out like this, but you should be okay to ignore it.