Menu

diagonal inflated Bivariate Poisson model

runjags
Luis
2016-08-25
2016-08-31
  • Luis

    Luis - 2016-08-25

    hi, I am trying to fit the Bivariate Poisson distribution to a set of sports results to serve as a comparison model to a new model I am developing/developed with my masters thesis.My model is as follow:

    model{
      C <- 0
        for( i in 1:nGames ){
        # Min score
        minscore[i] <- min( Score1[i],Score2[i]) + 1
        # Generate minscore latent variable
        u[i] ~ dunif(0,minscore[i])
        z3[i] <- trunc( u[i] )
        # Calculate z1 and z1 latent variables
        z1[i] <- Score1[i] - z3[i]
        z2[i] <- Score2[i] - z3[i]
        Zeros[i] ~ dpois( zeros.mean[i] )
        zeros.mean[i] <- -l[i] + C
        l[i] <- -lambda[i,1] + z1[i]*log( lambda[i,1] ) - loggam( z1[i]+1 )
                -lambda[i,2] + z2[i]*log( lambda[i,2] ) - loggam( z2[i]+1 )
                -lambda[i,3] + z3[i]*log( lambda[i,3] ) - loggam( z3[i]+1 )
    
        log( lambda[i,1] ) <- mu + offense[Team1[i]] + defense[Team2[i]]
        log( lambda[i,2] ) <- mu + offense[Team2[i]] + defense[Team1[i]]
        log( lambda[i,3] ) <- beta
      }
    
      for( j in 2:nTeams ){
        offense[j] ~ dnorm(0,.0001)
        defense[j] ~ dnorm(0,.0001)
      }
      offense[1] <- -sum( offense[2:nTeams] )
      defense[1] <- -sum( defense[2:nTeams] )
      mu~dnorm(0,0.001)
      beta~dnorm(0,.001)
    }
    

    Now, I am trying to fix a diagonal inflated Bivariate Poisson.
    My question is, what shoud I change from the above code to implement a diagonal inflated Bivariate Poisson?

    My data set:
    Team1/Team2 - the home and away teams
    Score1/Score2 - the observed scores
    nGames - the number of games in the dataset
    nTeams - the number of teams in the dataset

    Any help would be greatly appreciated.

     
  • Matt Denwood

    Matt Denwood - 2016-08-31

    I see this question has been answered by Martyn on the JAGS forum, which is probably a better place for this question as it doesn't have anything to do with runjags in particular. Hope you got what you needed.

    Matt

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.