0

I am looking to run a hierarchical poisson model to hockey goal tending data. here is the model as set up in bugs:

modelString <- "model {

  for(i in 1:n_obs){

    hockey_goals[i] ~ dpois(p[i])


    log(p[i]) <- p_inter + p_age * age[i] + p_sv_pct * sv_pct[i] + p_team * team[i] + p_win_pct * win_pct[i] + log(n_mins[i])

  }
  p_inter ~ dnorm(0,0.00001)
  p_age ~ dnorm(0, 0.00001)
  p_sv_pct ~ dnorm(0, 0.00001)
  p_team ~ dnorm(0, 0.00001)
  p_win_pct ~ dnorm(0, 0.00001)

}"

I then compile and load the data:

season_goals <- data$GA
n_mins <- data$MIN
age <- data$Age
sv_pct <- data$SV.
team <- data$Tm
win_pct <- data$W/data$GP
data <- list(n_obs=length(season_goals),n_mins=n_mins,hockey_goals=season_goals,age=age,
sv_pct=sv_pct,team=team,win_pct=win_pct)

# Get the data into BUGS:
modelData( bugsData( data ) )
#------------------------------------------------------------------------------
# INTIALIZE THE CHAINS.

nchain = 1
modelCompile( numChains=nchain )
modelGenInits()

#------------------------------------------------------------------------------
# RUN THE CHAINS.
samplesSet( c("p_age","p_sv_pct","p_team","p_win_pct") )
# R command defines a new variable that specifies an arbitrary chain length:
chainLength = 10000
# BRugs tells BUGS to generate a MCMC chain:
modelUpdate( chainLength )

At this point I get an error: Error in handleRes(res) : NA

Any ideas on where I went wrong...?

jmy
  • 1

1 Answers1

0

I wish I could just comment but I don't have enough reputation. Anyway, I made up some data and ran a simplified version of your model (i.e. with only age and minutes played). I ran it in the GUI version of OpenBUGS and it didn't work. I then changed the priors on you coefficients to dnorm(0,0.01) and it updated. So I would suggest changing the priors. The ones you have are very, very vague. Changing them as suggested will not effect your inference and you may get the model to run.

amg
  • 194
  • 2
  • 11