One weakness I can think of with the model is that it only consider the winner. I would guess there is information in who comes in second and third place and so on. If one horse haven’t won any race, what rating would this be given?

]]>How can I interpret the plots?

]]>How do I set initial parameters? I mean, how can I set a reasonable initial parameters?

]]>data {

int N; // number of runs.

int nhorses; // number of horses

// Each horse is referred to by an integer that acts as an index for the ratings vector.

int field_sizes[N]; // field size of run n

int idhorse[N]; // horse id of run n

int idrunner[N]; // runner id in a race

int win[N]; // 1 if runner n won, 0 if runner n lost.

real prior_mean; // sets the (arbitrary) location of the ratings.

real prior_sd; // sets the (arbitrary) scale of the ratings.

}

parameters {

real ratings[nhorses];

}

model {

real p_win[N]; // Win probability for horse n

// soft centering (see stan manual 8.7)

ratings ~ normal(prior_mean, prior_sd);

for (i in 1:N){

p_win[i] = ratings[idhorse[i]] / sum(ratings[segment(idhorse, i – idrunner[i] + 1, field_sizes[i])]);

win[i] ~ bernoulli(p_win[i]);

}

}

generated quantities{

real rat_rep[N];

real win_rep[N];

for (i in 1:N){

rat_rep[i] = ratings[idhorse[i]];

win_rep[i] = bernoulli_rng(ratings[idhorse[i]] / sum(ratings[segment(idhorse, i – idrunner[i] + 1, field_sizes[i])]));

}

}

I have one question.

Which data are you using? I mean, which columns of the data that football-data.co.uk provides?

Thank you very much!

]]>For example in order to get the predicted value for the 80th game I do (I have 80 games which I need to predict):

mean(as.matrix(samples[,120,])

Is this correct or am I doing something wrong, since all the results I am getting are close to 2?

]]>