Hello forum. I have a question about **explicit** implementation of MLE in Stan.

I have a simple detection task where subjects either detect or do not detect a change. Since there is no generic likelihood function that I use here, I calculate the probability of (detection | change) in every trial:

```
model {
for (t in 1:Tr) {
real p;
if (choice[t] == 1 && change[t] > 0) {
p = 1 - theta;
}
if (choice[t] == 0 && change[t] > 0) {
p = theta;
}
if (choice[t] == 1 && change[t] == 0) {
p = 1 - pow(theta,2);
}
if (choice[t] == 0 && change[t] == 0) {
p = pow(theta,2);
}
target += p;
}
}
```

Is this the right way of thinking about it in Stan? I get completely different `theta`

from matlab and from Stan, so obviously something in my model is wrong.