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.