I am interested in fitting a “robust” logistic regression model from Doing Bayesian Data Analysis (2nd Edition). This model treats data as a mixture of two sources: (1) guessing and (2) a logistic function of predictors. For guessing, the y values are thought to come from `y ~ Bernoulli(m=1/2)`

.

Using some data I found in this vignette, I think I’ve been able to implement the model in a simple case using rstan:

```
library("rstan")
# Prepare data
url <- "http://stat.columbia.edu/~gelman/arm/examples/arsenic/wells.dat"
wells <- read.table(url)
X <- model.matrix(~ arsenic, wells)
standata <- list(y = wells$switch, arsenic = wells$arsenic, N = nrow(wells))
# Model
guess.model <- '
data {
int<lower=0> N;
int<lower=0,upper=1> y[N];
vector[N] arsenic;
}
parameters {
real alpha;
real b_arsenic;
real<lower=0,upper=1> guess;
}
transformed parameters {
vector[N] mu;
for ( i in 1:N) {
mu[i] = .5*guess + (1-guess)*inv_logit(alpha + b_arsenic * arsenic[i]);
}
}
model {
y ~ bernoulli(mu);
alpha ~ normal(0,1);
b_arsenic ~ normal(0,1);
guess ~ beta(1,9);
}
'
# Fit model
fit <- stan(model_code = guess.model, data = standata)
print(fit, pars = c("alpha","b_arsenic","guess"))
```

However, I’m unsure how to implement the guessing parameter in brms. Could anyone point me in the right direction?

Operating System: Windows 10

Interface Version: 3.2.1