I ran this following code from the excellent book “Regression and Other Stories” which available online.

However, I get an error message when running it and I do not know why.

```
install.packages("cmdstanr", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))
library("rprojroot")
root<-has_file(".ROS-Examples-root")$make_fix_file()
library("cmdstanr")
check_cmdstan_toolchain()
install_cmdstan(overwrite = TRUE)
cmdstan_path()
cmdstan_version()
options(mc.cores = 1)
library("ggdist")
logit <- qlogis
invlogit <- plogis
set.seed(1234)
N <- 50
x <- runif(N, -9, 9)
a <- 0
b <- 0.8
p <- invlogit(a + b*x)
y <- rbinom(N, 1, p)
df <- 4
data_1 <- list(N=N, x=x, y=y, df=df)
writeLines(readLines(root("Robit","logit.stan")))
writeLines(readLines(root("Robit","robit.stan")))
logit_model <- cmdstan_model("logit.stan")
robit_model <- cmdstan_model("robit.stan")
**fit_logit_1 <- logit_model$sample(data=data_1, refresh=0)**
print(fit_logit_1)
a_hat_logit_1 <- median(fit_logit_1$draws("a"))
b_hat_logit_1 <- median(fit_logit_1$draws("b"))
**fit_robit_1 <- robit_model$sample(data=data_1, adapt_delta = 0.95)**
print(fit_robit_1)
a_hat_robit_1 <- median(fit_robit_1$draws("a"))
b_hat_robit_1 <- median(fit_robit_1$draws("b"))
```

The error message is:

Running MCMC with 4 parallel chains…

Warning: Chain 1 finished unexpectedly!

Warning: Chain 2 finished unexpectedly!

Warning: Chain 3 finished unexpectedly!

Warning: Chain 4 finished unexpectedly!

Warning: Use read_cmdstan_csv() to read the results of the failed chains.

Warning messages:

1: All chains finished unexpectedly! Use the $output(chain_id) method for more information.

2: No chains finished successfully. Unable to retrieve the fit