rjags Index expression evaluates to non-integer value

I have a model that I am trying to add covariates into. The model runs when I don’t add “gamma”. When I add “gamma”, I get the following error:

Error in checkForRemoteErrors(val) : 
  3 nodes produced errors; first error: Error in node -1.8306
Index expression evaluates to non-integer value

I have tried to make all of the parts of the data list into numeric, I still have the same error. I am not sure how else to resolve this and I don’t understand how a node could be negative. The augtemp data are normally distributed, I have z-scored the data. I have tried different prior distributions and that has not resolved the problem. If you are able to help, what does this error mean, where is a negative node, and how could I resolve this?

Thank you. The model and code are below. (cross-posted on: https://sourceforge.net/p/mcmc-jags/discussion/610037/thread/3634179a0d/?limit=25#85db)

# compile data into a list for JAGS
jags.data.augtemp <- list(Ndata = nrow(dat),
                  SS=dat$Redds.10000m2,
                  lRR=log(dat$EST.1.10000m2),
                  RR=dat$EST.1.10000m2,
                  stream = dat$StreamNum, 
                  Nstream = max(dat$StreamNum),
                  augtemp = c(as.numeric(dat$Z_stream_augtemp_yr)),
                  #drainage=DrainageHeirarchy$DrainageNum, 
                  #Ndrainage=max(DrainageHeirarchy$DrainageNum),
                  Year=as.numeric(as.factor(dat$Year)), 
                  Nyear = max(as.numeric(as.factor(dat$Year)))
                  #MSF = BLT_SR$Z_MSF
                  )
 str(jags.data.augtemp)
List of 9
 $ Ndata  : int 246
 $ SS     : num [1:246] 3.444 3.587 4.592 2.296 0.287 ...
 $ lRR    : num [1:246] 6.08 5.56 5.23 5.03 4.56 ...
 $ RR     : num [1:246] 437.6 259.4 186.6 153.6 95.4 ...
 $ stream : num [1:246] 1 1 1 1 1 1 1 1 1 1 ...
 $ Nstream: num 11
 $ augtemp: num [1:246] -1.831 -0.074 0.694 -0.626 -2.066 ...
 $ Year   : num [1:246] 5 6 7 8 9 10 11 12 13 14 ...
 $ Nyear  : num 38


 ##### STEP 2: SPECIFY JAGS MODEL CODE #####
modelScript.name <- "ricker_augtemp.txt"
jagsscript <- cat("
model {

###priors####

    alpha.m ~ dunif(1,100);
    beta.m ~ dunif(0,1);
    gamma ~ dunif(-5,5); # Prior for the coefficient of the august temp covariate
    #FlowEff ~ dnorm(0,3);

    s.a.sd ~ dunif(0,3);
    s.b.sd ~ dunif(0,3);
    #d.a.sd ~ dunif(0,3);
    #y.a.sd ~ dunif(0,3);

    sigmaObs ~ dunif(0,2);

####
####
####define ricker model###
####
####
    for(i in 1:Ndata){
    ##alpha = recruits per stock unit at small stock size
    ##SS= stock, in this case the Redds/km2
    ##beta =  b to density dependence

    lRR[i] ~ dnorm(log(pRR[i]) -
    (pow(sigmaObs,2)/2),pow(sigmaObs,-2)); #log recruits        defined as a normal distribution where the mean is the      log of the output from the ricker model and the sd is       made into a precision parameter by taking the SD to the     power of -2

    pRR[i] <- alpha[i] * SS[i] * exp(-1*beta[i]*SS[i]);         ##ricker model



      lalpha[i] <- log(alpha.m) + s.a[stream[i]];# + y.a[Year[i]]; #taking into account the random effect of stream on alpha
      lbeta[i] <- log(beta.m) + s.b[stream[i]] + gamma[augtemp[i]];#taking into account the random effect of stream on beta & covariate effect of mean august temp


      alpha[i] <- exp(lalpha[i]); #exp() so no longer on log scale
      beta[i] <- exp(lbeta[i]);

    }

####
####
######this is defining things for drainage, but I don't have drainage in the data as of 8/11/23####
####
####
    #for(DD in 1:Ndrainage){
      #d.a[DD] ~ dnorm(0,pow(d.a.sd,-2));
      #s.a.sd[DD] ~ dunif(0,3);
    #}

####
####
####defining the distributions for the random effects of stream####
####
####
    for(SS in 1:Nstream){
      #s.a[SS] ~ dnorm(d.a[drainage[SS]],pow(s.a.sd[drainage[SS]],-2));
      s.a[SS] ~ dnorm(0,pow(s.a.sd,-2));
      s.b[SS] ~ dnorm(0,pow(s.b.sd,-2));
    }

####
####
####defining the distributions for the random effects of year####
####
####   
     #for(YY in 1:Nyear){
       #y.a[YY] ~ dnorm(0,pow(y.a.sd,-2));
     #}

####
####
####defining management quantities####
####
####
    for(SS in 1:Nstream){
      Smsy[SS] <- ((log(alpha.m) + s.a[stream[SS]]) * (0.5 - 0.07*(log(alpha.m) + s.a[stream[SS]]))) / exp(log(beta.m) + s.b[stream[SS]])
    }


}  
", 
file = here(modelScript.name))


##### SET NODES TO MONITOR #####
jags.params.temp <- c('beta.m','alpha.m','gamma','s.a','s.b','sigmaObs','Smsy')



mod_lm_augtemp <- R2jags::jags.parallel(jags.data.augtemp, 
                                parameters.to.save = jags.params.temp,
                                model.file = here(modelScript.name), 
                                n.chains = 3, 
                                n.burnin = 30000/2, # number of post-burn-in samples per chain
                                n.thin = 10, # thinning rate
                                n.iter = 30000)


Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật