So, apparently, despite everything working fine late last night, I am now back to square one regarding the C++ exception error above
Error in mod$fit_ptr() : c++ exception (unknown reason)
failed to create the sampler; sampling not done
I have tried several things to fix the issue
- updating rstan;
- updating Rcpp;
- checking that everything on the “RStan Getting Started” stan-dev GitHub page is adhered to.
To reiterate, I work from
- macOS High Sierra 10.13.6,
- R 3.6.3
- RStudio Version 1.3.959
- rstan 2.21.2
I have reservations on updating to a new mac version.
The error happens when I run the golf putting data (which worked as expected before)
options(mc.cores = parallel::detectCores())
rstan_options(auto_write = TRUE)
J <- 19
x <- 1:J
n <- c(1443, 694, 455, 353, 272, 256, 240, 217, 200, 237, 202, 192, 174, 167, 201, 195, 191, 147, 152)
y <- c(1346, 577, 337, 208, 149, 136, 111, 69, 67, 75, 52, 46, 54, 28, 27, 31, 33, 20, 24)
r <- (1.68/2)/12
R <- (4.25/2)/12
overshot <- 3
distance_tolerance <- 1
golf_data <- list(J=J, x=x, n=n, y=y, r=r, R=R, overshot=overshot, distance_tolerance=distance_tolerance)
fit_trig <- stan("golf.stan", data=golf_data)
and the Stan program (golf.stan)
data {
int J;
int n[J];
vector[J] x;
int y[J];
real r;
real R;
real overshot;
real distance_tolerance;
}
transformed data {
vector[J] threshold_angle = asin((R-r) ./ x);
vector[J] raw_proportions = to_vector(y) ./ to_vector(n);
}
parameters {
real<lower=0> sigma_angle;
real<lower=0> sigma_distance;
real<lower=0> sigma_y;
}
model {
vector[J] p_angle = 2*Phi(threshold_angle / sigma_angle) - 1;
vector[J] p_distance = Phi((distance_tolerance - overshot) ./ ((x + overshot)*sigma_distance)) -
Phi((- overshot) ./ ((x + overshot)*sigma_distance));
vector[J] p = p_angle .* p_distance;
raw_proportions ~ normal(p, sqrt(p .* (1-p) ./ to_vector(n) + sigma_y^2));
[sigma_angle, sigma_distance, sigma_y] ~ normal(0, 1);
}
generated quantities {
real sigma_degrees = sigma_angle * 180 / pi();
}
Any thoughts here??