Sunday, November 4, 2012

Finishing football postings

For now this is the last post about these football data. It started in August, by now it is November. But just to finish up; the model as it should have been last week.

Model

As most of what I did is described last week, only the model as it went in Jags is shown.

Explanation: Each team has a total strength (TStr) and an attack/defense strength (AD). These combine to two numbers, Defense strength (DStr) and Attack strength (AStr). The attack strength against defense strength together determine the number of goals. Logically each team has one TStr, AD, DStr and Astr. In the model this is not so, Astr and Dstr are calculated for each game.

The intention was to build in strategy. If a team plays a much stronger/weaker team, it might be possible to shift in attack/defense strength. Unfortunately, that did not work. Either because it does not happen or because my formulation did not work out so good.

A second possibility possible in this framework is to incorporate statements like; team X never wins when they play at time Y. That could translate to a change in TStr depending on day and time. Maybe later.

fbmodel1 <- function() {

for (i in 1:N) {

HomeMadeGoals[i] ~ dpois(HS[i])

OutMadeGoals[i] ~ dpois(OS[i])

log(HS[i]) <- Home + DstrO[i] + AstrH[i]

log(OS[i]) <- DstrH[i] + AstrO[i]

AstrH[i] <- TStr[HomeClub[i]]+AD[HomeClub[i]]

DstrH[i] <- TStr[HomeClub[i]]-AD[HomeClub[i]]

AstrO[i] <- TStr[OutClub[i]] +AD[OutClub[i]]

DstrO[i] <- TStr[OutClub[i]] -AD[OutClub[i]]

}

TStr[1] <- 0

AD[1] <- 0

for (i in 2:nclub) {

TStr[i] ~ dnormmix(MT,tauT1,EtaT)

AD[i] ~ dnormmix(MAD ,tauAD1, EtaAD)

}

for (i in 1:3) {

MT[i] ~ dnorm(0,.01)

MAD [i] ~ dnorm(0,.01)

tauT1[i] <- tauT

tauAD1[i] <- tauAD

eee[i] <- 3

}

EtaT[1:3] ~ ddirch(eee[1:3])

EtaAD[1:3] ~ ddirch(eee[1:3])

sigmaT <- 1/sqrt(tauT)

tauT ~ dgamma(.001,.001)

sigmaAD <- 1/sqrt(tauAD)

tauAD ~ dgamma(.001,.001)

Home ~ dnorm(0,.0001)

}

Results

As estimates for ADO Den Haag are now fixed, I am not sure any of the estimates can be interpreted as such. So, this is just to show the model runs through JAGS.

Inference for Bugs model at "C:/Users/.../Rtmp4uyOHL/model1be0596d2d4b.txt", fit using jags,

No comments:

Post a Comment

Wiekvoet

Wiekvoet is about R, JAGS, STAN, and any data I have interest in. Topics range from sensometrics, statistics, chemometrics and biostatistics. For comments or suggestions please email me at wiekvoet at xs4all dot nl.