我正在寻找对曲棍球目标倾向数据运行分层泊松模型。这是在错误中设置的模型:
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
关于我哪里出错的任何想法......?