I’ve been struggling to implement a particular model in Stan. It could just be because of my lack of sophistication with statistics. It’s worth noting that while trying to decipher my question.

I have two sets of answers to a survey. Each set represents a group. There is a single survey question with only two possible answers. I know how to use Stan to determine the likely parameters of the two groups using a binomial distribution. And I can use those to determine the likelihood that the two groups have the same probability of answering the survey question in the same way.

However, there’s reason to believe that the responses to the survey questions are not an accurate representation of what is being measured (in this case a particular mental state). There is some research that suggests how accurate these types of surveys are likely to be and I’d like to include that in my model. For example, suppose that if a person answers ‘yes’ in the survey, there’s a 0.8 probability that the ‘yes’ accurately represents their belief. This is what I’m referring to as measurement error.

How can I model this? I tried to build custom function, but I was unsuccessful. I also read through a bit of the manual and was able to get a few things compiling, but nothing like what I was after. I think part of the problem is I’m not quite sure what the return value of the function is meant to represent, but also because I’m not even sure the best way to model this (maybe it’s as simple as using an out of the box distribution with a higher sd?).

It seems like this is probably trivial. Any help is greatly appreciated!