Hey Gwynn

There’s a few problems that you’re gonna hit. I’ll just edit your model and leave comments inside it.

```
functions {
// The "data" (there might be a special name for this but I dunno) argument for the _lpmf/_lpdf functions comes first.
// I think TDX is the data in your case?
// Also, TDX is an integer, so it's probably a pmf, not a pdf that you want
real like0_lpmf(int TDX, real beta, vector gamma, vector phi) {
...
return log(probability); // The lpmf/lpdf return logs of the probabilities they compute
}
data {
int N;
int TDX[3]; // Should TDX be 3 dimensional? I ask because later you have a loop over
// TDX that goes all the way to N. Is it N, 3 dimensional things by chance?
}
parameters {
vector [4] gamma;
real beta;
}
model {
for(i in 1:N) {
TDX[i] ~ like0(beta, gamma, 0.9); // This is the same as
target += like_lpmf(TDX[i] | beta, gamma, 0.9); // This, which is the same as
target += like_notlpmf(TDX[i], beta, gamma, 0.9); // This if the _lpmf syntax isn't used
// You'd only use one of the above
}
beta ~ normal(0,10);
gamma ~ normal(0,10);
}
```

What I typed isn’t gonna produce a working model, but hopefully it’ll get you closer to what you want.

Btw, what is the custom probability function you’re trying to use? Stan has quite a few.