Hi everyone,
My Rstudio gets stuck once the Rstan is implemented, for example the “Check” button on the Rstan interface takes forever to run. The “rstan::” function takes forever too. Also, after I library(rstan), “::” function for all the packages get stuck. When I create a new project and avoid any steps related to rstan, everything goes fine. I have tried to update my R and Rstudio to the latest version but it didn’t help.
I believe the code is proper. paste it anyway:
data{
int obs; // number of observation in the long vector
int N; // number of individuals
vector [N] size_t0; // size of focal plants
vector [N] growth; // growth of focal plants, response
int n_nb[N];
vector [obs] size_vector; // leng vector of neighbor sizes
vector [obs] dist_vector; // long vector of pairwise distances
int pos[N];
}
transformed data{
}
parameters{
real alpha; // Intercept
real beta; // Effect of target plant size on response
real sigma; // global SD
real<lower=0> a1; // size dependent effect of the neighbor
real a3; // net crowding effect
real<lower=0> a2; // spatial scale
}
transformed parameters{
vector[N] kernel;
vector[N] mu;
vector[obs] size_vec;
vector[obs] dist_vec;
for (i in 1:obs){
dist_vec[i]=dist_vector[i]^2;
size_vec[i]=size_vector[i]^a1;
}
for(n in 1:N)
kernel[n]=sum(exp(log(segment(size_vec, pos[n], n_nb[n]))-
(segment(dist_vec, pos[n], n_nb[n])*a2)));
for(n in 1:N)
mu[n]=alpha+size_t0[n]*beta+a3*kernel[n];
}
model{
alpha~normal(0,5); // uninformed priors centered at zero;
beta~normal(0,5);
a1~normal(0,5);
a2~normal(0,5);
a3~normal(0,5);
sigma~exponential(1);
growth ~ normal(mu,sigma);
}
Operating System: MAC Catalina 10.15.6
RStan Version: 2.21.2
Session info:
setting value
version R version 4.0.3 (2020-10-10)
os macOS Catalina 10.15.6
system x86_64, darwin17.0
ui RStudio
language (EN)
collate zh_CN.UTF-8
ctype zh_CN.UTF-8
tz Asia/Shanghai
date 2020-12-27
Thanks!