0

I'm working on a project where we need to fit data into some model. I've just started so I'm playing around with different models, but already experiencing "subscript out of bounds" error that I can't seem to fix. I know that it suggests that I'm trying to "access" data that is out of range, but I don't know where this issue originates from.

The code I'm trying to run:

listdata <- list(
  B = d$Brooklyn.Bridge,
  M = d$Manhattan.Bridge,
  W = d$Williamsburg.Bridge,
  Q = d$Queensboro.Bridge, 
  Temp = as.integer(d$High_Temp)
)

m.1 <- ulam(
       alist( total ~ dpois(lambda),
           lambda = exp(beta_B*B + beta_M*M + beta_W*W + beta_Q*Q + beta_temp*Temp + eps),
           beta_B ~ dnorm(0,10),
           beta_M ~ dnorm(0,10),
           beta_W ~ dnorm(0,10),
           beta_Q ~ dnorm(0,10),
           beta_temp ~ dnorm(0,10),
           eps ~ dnorm(0,10)), 
  data = listdata,
  chain = 2,
  iter = 2000,
  warmup = 1000
   )

output:

Error in flist[[symbol_lines[[i]]]][[3]] : subscript out of bounds

The error occurs when running m.1

Note: I'm a beginner in R and Bayesian statistics, but I want to improve on these skills. All feedback is helpful :)

  • 1
    It's hard to know without a [reproducible example](https://stackoverflow.com/q/5963269/5325862): we can't run any of your code without having a sample of data or knowing what packages you're using – camille Dec 27 '21 at 17:42
  • @camille I'm using rstan and rethinking. Is there any general path to a solution, I've gotten similar errors before when I'm trying to fit models to data. – rstudent Dec 28 '21 at 08:22
  • Without any data, not really. Maybe go through tutorials for rstan and see if you're still having issues. But right now you're saying you don't know where the issue comes from, and neither will anyone else if we can't run your code – camille Dec 28 '21 at 16:02
  • Please provide enough code so others can better understand or reproduce the problem. – Community Jan 03 '22 at 21:21

0 Answers0