I have a similar problem. I have recently had my computer upgraded and some of my rstan models cause Rstudio to crash. Rstudio says “R session Aborted R encountered a fata error and the session was terminated”, however the model is able to run in RGui. In the event log it says the error is caused by the .dll file.

I am able to run some other rstan models in Rstudio, although I have a few that cause this error. I have asked colleagues at work to run the scripts that generate the problems and not one person, out of 7, was able to recreate the error I received. One person had exactly the same operating system, versions of Rstudio, Rstan and Rtools as me and was able to run the scripts fine.

I have tried uninstalling everything and reinstalling several times, often with different versions and this problem still occurs.

Does anybody have any ideas as to what is causing this problem?

I am using

Operating system: Windows 10

R : 3.5.1

rstan: rstan_2.18.2

Rtools: 3.4

Rstudio: Version:1.0 1.1.463

The following model is one of the models that causes Rstudio to break:

```
data{
int N_obs; // number of obs
int N_obsG; // number of obs
int N; // number of species
int Time; // years
int nGear; // number of gears
// observartions
int spec[N_obs]; //species number
int year[N_obs]; // year of catch
vector [N_obs] obs_y; // number of obs there
vector [N_obs] freq; // number of obs there
// Gaussian only
int specG[N_obsG]; //species number
int yearG[N_obsG]; // year of catch
vector [N_obsG] obs_yG; // number of obs there
vector [N_obsG] freqG; // number of obs there
vector [N_obsG] s_yG; // number of obs there
// gears
vector [nGear] obs_g;
vector [nGear] freq_g;
vector [nGear] s_g;
// priors
vector [N] initial_m;
vector [N] initial_sd;
vector [N] mu_0;
vector [N] mu_0_v;
}
parameters{
vector [N] mu_raw[Time-1];
vector <lower=0> [N] sigma_mu_sq;
vector <lower=0> [N] sigma_dyn_sq;
vector [nGear] mu_g;
vector <lower=0> [nGear] sigma_g_sq;
vector <lower=0,upper=1> [N] p_a1;
ordered [2] mu_l[N];
vector <lower=0> [N] sigma_mu_l_sq;
//
}
transformed parameters{
vector [N] mu[Time];
vector <lower=0> [N] sigma_mu = sqrt(sigma_mu_sq);
vector <lower=0> [N] sigma_dyn = sqrt(sigma_dyn_sq);
vector <lower=0> [N] sigma_mu_l = sqrt(sigma_mu_l_sq);
vector <lower=0> [nGear] sigma_g = sqrt(sigma_g_sq);
mu[1] = to_vector(mu_l[,2]);
for(t in 2:Time)
{
mu[t] = mu[t-1] + sigma_dyn .* mu_raw[t-1];
}
}
model{
//priors
sigma_mu_sq ~ inv_gamma(2,2);
sigma_g_sq ~ cauchy(0,1);
sigma_dyn_sq ~ inv_gamma(10,0.01);
mu_g ~ normal(0,10);
// the prior for the size
for (i in 1:N)
{
mu_l[i] ~ normal(0,10);
}
//mu_l[1] ~ normal(mu_0,mu_0_v);
sigma_mu_l_sq ~ inv_gamma(10,0.1);
// the dynamics for the median length
for (t in 1:(Time-1))
{
mu_raw[t] ~ normal(0,1);
}
for (i in 1:N_obsG)
{
{
obs_yG[i] ~ normal(mu[year[i],specG[i]],sigma_mu[specG[i]] / sqrt(freqG[i])); // for each sepecies for each year
if (s_yG[i] > 0)
{
(s_yG[i] * (freqG[i] - 1.0) / sigma_mu_sq[specG[i]]) ~ chi_square(freqG[i] - 1.0); // variance for each species, for each year
}
}
}
for (i in 1:nGear)
{
obs_g[i] ~ normal(mu_g[i],sigma_g[i] / sqrt(freq_g[i])); // for each gear
if (freq_g[i] > 1)
{
(s_g[i] * (freq_g[i]-1.0) / sigma_g_sq[i]) ~ chi_square(freq_g[i] - 1.0);
}
}
}
```