0

I´m tring to fit the Bivariate Poisson distribution to a set of sports results for my masters thesis.

But using the model given in Bayesian Modeling Using WinBUGS (Ch. 8, Section 3.4, pgs 292-294), I can't seem to get the model to work.

The model code is given below:

m1_string <- "model {
    C <- 0
    for(i in 1:n_games) {

        minscore[i] <- min( HomeGoals[i],AwayGoals[i]) + 1
        # Generate minscore latent variable
        u[i] ~ dunif(0,minscore[i])
        z3[i] <- trunc( u[i] )

        HomeGoals[i] <- z1[i] + z3[i]
        AwayGoals[i] <- z2[i] + z3[i]
        Zeros[i] <- 0
        Zeros[i] ~ dpois( zeros.mean[i] )
        zeros.mean[i] <- -l[i] + C
        l[i] <- -lambda_home[HomeTeam[i],AwayTeam[i]] + z1[i]*log( lambda_home[HomeTeam[i],AwayTeam[i]] ) - loggam( z1[i]+1 )
        -lambda_away[HomeTeam[i],AwayTeam[i]] + z2[i]*log( lambda_away[HomeTeam[i],AwayTeam[i]] ) - loggam( z2[i]+1 )
        -lambda_3[HomeTeam[i],AwayTeam[i]] + z3[i]*log( lambda_3[HomeTeam[i],AwayTeam[i]] ) - loggam( z3[i]+1 )
    }
    for(home_i in 1:n_teams) {
        for(away_i in 1:n_teams) {
            log( lambda_home[home_i, away_i] ) <- mu + skill[home_i] - skill[away_i]
            log( lambda_away[home_i, away_i] ) <- mu + skill[away_i] - skill[home_i]
            log( lambda[home_i, away_i] ) <- beta
        }
    }  
    skill[1] <- 0
    for(j in 2:n_teams) {
        skill[j] ~ dnorm(group_skill, group_tau)
    }
    group_skill ~ dnorm(0, 0.0625)
    group_tau <- 1 / pow(group_sigma, 2)
    group_sigma ~ dunif(0, 3)
    mu ~ dnorm(0, 0.0625)
    beta ~ dnorm(0, 0.0625)
}"

As data supplied to JAGS through the jags.model() function in R, I am providing the following list:

HomeTeam/AwayTeam -the home and away teams
HomeGoals/AwayGoals - the observed scores
n_games - the number of games in the dataset
n_teams - the number of teams in the dataset

When I try to compile:

# Compiling model 1
m1 <- jags.model(textConnection(m1_string), data = data_list, n.chains = 3,
n.adapt = 5000)

message ERROR: RUNTIME ERROR

Any help would be greatly appreciated.

Unheilig
  • 16,196
  • 193
  • 68
  • 98
Luis
  • 1
  • 1

0 Answers0