Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] handle different number of teams in elo.run.multiteam #63

Closed
BenoitLondon opened this issue Feb 19, 2024 · 1 comment
Closed

Comments

@BenoitLondon
Copy link

BenoitLondon commented Feb 19, 2024

[EDIT] Actually it handles NA sorry please close... [EDIT]

Hi, currently when number of participants varies in each game, I have to pad the missing players with some artificial player "loser" with a very low initial rating to mimick the fact this fake player doesn't play and does not change the ratings of other players.

It could be possible to allow NA ( or use a special player name like "loser") and then remove the NA / loser in the 1v1 generated matchups

e.g. ( a quick way I think but it's probably easy to optimize further)

elo.run.multiteam2 <- function (formula, data, na.action, subset, k = NULL, initial.elos = NULL,
          ...)
{
    Call <- match.call()
    Call[[1L]] <- quote(elo::elo.model.frame)
    Call$required.vars <- c("elos", "k", "group", "regress")
    Call$ncol.k <- 2
    Call$ncol.elos <- 1
    mf <- eval(Call, parent.frame())
    if (nrow(mf) == 0)
        stop("No (non-missing) observations")
    Terms <- stats::terms(mf)
    if (any(mf$adjust.A != 0))
        warning("Any adjustments using 'adjust()' are being ignored.")
    mf2 <- elo:::multiteam_model_frame(mf)
    mf2 <- mf2[mf2$elo.B != "__loser__" & mf2$elo.A != "__loser__",]
    er <- elo.run(wins.A ~ elo.A + elo.B + k(k) + group(group) +
                      regress(regress, to = attr(mf$regress, "to"), by = attr(mf$regress,
                                                                              "by")), data = mf2,
                  initial.elos = initial.elos,...)
    er$Call <- Call
    er$terms <- Terms
    er$na.action <- stats::na.action(mf)
    er$n.matches <- nrow(mf)
    class(er) <- c("elo.run.multiteam", class(er))
    er
}
@BenoitLondon BenoitLondon changed the title [FEATURE] handle different number fo teams in elo.run.multiteam [FEATURE] handle different number of teams in elo.run.multiteam Feb 19, 2024
@BenoitLondon
Copy link
Author

Oh actually I just realised it handles NA teams? ignore me :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant