Hi all,
Table tennis can be seen as a succession of identical and independent random experiments (the rallies).
The rally-outcomes are mutually independent and are, conditionally upon the server, identically distributed. We will call this the server-model.
Denoting by pa (resp., pb) the probability that player A (resp., player B) wins a rally he/she initiates,
the game is then entirely governed by the bivariate parameter:
(pa, pb) ∈ (0, 1) × (0, 1)
A simpler model is the no-server-model, in which it is assumed that rallies are won with probabilities that do not depend on the server:
pa = 1 − pb = p ∈ (0, 1)
Based on this blog post I wrote the following Stan code that represents the no-server-model:
data {
int<lower=0> n_sets; // number of sets
int a[n_sets]; // number of points won by A
int b[n_sets]; // number of points won by B
int x[n_sets]; // number of points won by winner on own service
}
parameters {
real<lower=0> alpha; // skill of A
real<lower=0> beta; // skill of B
}
transformed parameters {
real<lower=0,upper=1> p_a; // probability that A wins point while being the server
real<lower=0,upper=1> p_b; // probability that B wins point while being the server
p_a = alpha - beta;
p_b = 1 - p_a;
}
model {
for (set in n_sets) {
// check who is the winner
if (a[set] > b[set]) {
p_a_wins = 0;
for (point in b[set]) {
p_a_wins += some_funtion_that_includes_pa_and_pb()
}
p_b_wins = 1 - p_a_wins;
1 ~ bernoulli_logit(p_a_wins);
0 ~ bernoulli_logit((p_b_wins);
} else {
p_b_wins = 0;
for (point in a[set]) {
p_b_wins += some_funtion_that_includes_pa_and_pb()
}
p_a_wins = 1 - p_b_wins;
0 ~ bernoulli_logit(p_a_wins);
1 ~ bernoulli_logit(p_b_wins);
}
}
}
I read here that it’s better to use bernoulli_logit(...)
than bernoulli(inv_logit(...))
but I am wondering if my implication is correct? Where did the 10 of the below formula go?
In addition, how would the server-model look like in Stan? Thank you