Rstudio displayed an error message as follows with a bomb picture, and sampling failed.
Original data is not permitted to share.
error message
"R Session Aborted
R encountered a fatal error.
The session was terminated".
stan code
data {
int N;
int P;
real A[N];
int<lower=0, upper=10> HA[N];
int<lower=1, upper=P> PREF[N];
}
parameters {
real b0;
real ba0;
real a00;
real b[P];
real ba[P];
real a0[P];
real<lower=0> s_b;
real<lower=0> s_ba;
real<lower=0> s_a0;
real<lower=0> s_H;
}
model {
for (p in 1:P) {
b[p] ~ normal(b0, s_b);
ba[p] ~ normal(ba0, s_ba);
a0[p] ~ normal(a00, s_a0);
}
for (n in 1:N)
HA[n] ~ normal(b[PREF[n]] + ba[PREF[n]] * (A[n] - a0[PREF[n]]) ^ 2, s_H);
}
generated quantities {
real h_pred[N];
for (n in 1:N)
h_pred[n] = normal_rng(b[PREF[n]] + ba[PREF[n]] * (A[n] - a0[PREF[n]]) ^ 2, s_H);
}
r code
library(rstan)
d <- read.csv(file=‘output/ch2/lall3.csv’, header = TRUE)
d <- subset(d, subset = year == 2013)
d$age_std <-(d$age-mean(d$age))/sd(d$age)
data <- list(N=nrow(d),P=length(levels(d$pref)),A=d$age_std,
PREF=as.numeric(d$pref),HA=as.numeric(d$hap))
stanmodel <- stan_model(file=‘model/ch2/model_ind_hreghap_simp2.stan’)
fit <- sampling(
stanmodel,
data = data,
seed =243,
chains=4, iter=1000, warmup=500, thin=1
)
I tried again with the following codes
rstan_options(auto_write = TRUE)
options(mc.cores = parallel::detectCores())
but, it displayed the following error message
Error in unserialize(socklist[[n]]) : error reading from connection
Error in serialize(data, node$con, xdr = FALSE) :
error writing to connection
I would appreciate it if someone would help me.