0

我正在寻找对曲棍球目标倾向数据运行分层泊松模型。这是在错误中设置的模型:

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)

}"

然后我编译并加载数据:

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 )

此时我收到一个错误:handleRes(res) 中的错误:NA

关于我哪里出错的任何想法......?

4

1 回答 1

0

我希望我可以发表评论,但我没有足够的声誉。无论如何,我制作了一些数据并运行了您模型的简化版本(即只有年龄和上场时间)。我在 OpenBUGS 的 GUI 版本中运行它,但它不起作用。然后我将您的系数的先验更改为dnorm(0,0.01) 并更新。所以我建议改变先验。你所拥有的非常非常模糊。按照建议更改它们不会影响您的推理,并且您可以让模型运行。

于 2017-05-09T21:03:40.560 回答