Hi,
I have the following working Bradley-Terry model for single players
data {
int<lower=1> n_games;
int<lower=2> n_players;
int<lower=1, upper=n_players> player_id[n_games];
int<lower=1, upper=n_players> opponent_id[n_games];
int<lower=0> n_points_won[n_games];
int<lower=11> n_points[n_games];
}
parameters {
vector[n_players - 1] raw_lambda;
}
transformed parameters {
vector[n_players] lambda = append_row(0, raw_lambda);
vector<lower=0, upper=1>[n_games] phi = inv_logit(lambda[player_id] - lambda[opponent_id]);
}
model {
raw_lambda ~ normal(0, 2);
n_points_won ~ binomial(n_points, phi);
}
Inspired by this paper I want to create a team-version of the above code. Each team consists of 2 players.
The paper assumes that the lambda
of a team is simply the sum of the lambda
of the players in that particular team. If I am not mistaken, Algorithm 2 in the paper is nothing special that can’t be reproduced using Stan.
If so, would the team-version look like below?
data {
int<lower=1> n_games;
int<lower=4> n_players;
int<lower=1, upper=n_players> player_id_1[n_games];
int<lower=1, upper=n_players> player_id_2[n_games];
int<lower=1, upper=n_players> opponent_id_1[n_games];
int<lower=1, upper=n_players> opponent_id_2[n_games];
int<lower=0> n_points_won[n_games];
int<lower=11> n_points[n_games];
}
parameters {
vector[n_players - 1] raw_lambda;
}
transformed parameters {
vector[n_players] lambda = append_row(0, raw_lambda);
vector<lower=0, upper=1>[n_games] phi = inv_logit(
lambda[player_id_1] + lambda[player_id_2] - lambda[opponent_id_1] - lambda[opponent_id_2]
);
}
model {
raw_lambda ~ normal(0, 2);
n_points_won ~ binomial(n_points, phi);
}