Strange new errors when running basic linear regression:' Error in sims[1:floor(half), ] : subscript out of bounds ' and 'Error in FUN(newX[, i], ...) : is.atomic(x) is not TRUE '

I am trying to run the following basic linear regression program:

     data {
          int<lower=0> N;
         vector[N] X;
          vector[N] y;
    }

    parameters {
          real alpha;
          real beta;
          real<lower=0> sigma;
 } 

    model {
    y ~ normal(alpha + beta * X, sigma); 
    }

using rstan in RStudio with this code:

    lrfit0 <- stan(
      file = "basic_lr.stan",  # Stan program
      data = lr_test_data,    # named list of data
      chains = 2,             # number of Markov chains
      warmup = 1000 ,          # number of warmup iterations per chain
      iter = 1000,            # total number of iterations per chain
      cores = 4              # number of cores (could use one per chain)  
 )

My data are:

    N = 10
    X = seq(0, 1, length.out = 10)
    y = c(-12.468, -11.470, -12.419 ,-14.559, -14.412, -14.302, -14.310,  -14.256, -13.220, -12.872)

If I run the code with one chain I get this error message:
"Error in sims[1:floor(half), ] : subscript out of bounds "

But if I use 2 chains the error is:
" Error in FUN(newX[, i], …) : is.atomic(x) is not TRUE "

In both cases no stanfit object is produced.

I am using a Mac running Catalina. Could that be the cause? I can run some Stan programs eg I have just run the dogs demo successfully.

Maybe this thread has some information you can use. If not, let us know and we’ll try and help you out.

Sorry. I should have said that I have been reading that thread - with alarm but also, regrettably, without seeing how the problems there relate to my case. The two error messages are incomprehensible to me.

Unfortunately, I can’t personally help you. But maybe @bgoodri or @jonah have an idea of how to resolve your particular problem.

1 Like

You have zero post-warmup iterations

The case of setting warmup == iter will be reported as an error in the next version of rstan (the fix is already in the github repository), and will avoid the strange error messages that are printed out now.

1 Like

Thanks, Ben. I have been using another MCMC program that counts iter after warmup.