Dear Wim,
Many thanks for sharing your code, which I tested and here is what I found.
What I noticed are three things in your code: 1. you did not explicitly model phi, zoi and coi, which makes it difficult to understand what brms is doing and 2. therefore, you did not model these parameters conditional on x. and 3. Resulting from 2., you have a misconception (in my opinion) how to interpret zoi and coi.
Therefore, my first step was to explicitly model the parameters:
bf(y ~ x,
phi ~ 1,
zoi ~ 1,
coi ~ 1)
If you do it this way, your initial model and this model should be exactly the same, but the results looked different at first glance. But, what I missed at first and you probably, too, is that brms estimated phi, zoi and coi with an identity link and NOT with a log or logit link respectively. These links are only used, if you model it as I did above (and then you get the information as āInterceptā). Therefore, to plot the results, there is no need to use the plogis function to backtransform it into probabilities, since they are already on that scale.
Of course, this is necessary, if you parametrize it as I did. But here I noticed your misconception about zoi and coi. If they are not dependent on the covariates (here x), they are simply scalars and describe the properties of the sample, namely zoi ā how many 0 and 1 are in the sample, and coi ā how many are 1s from these proportion. In your simulated data, you hat 10% 0s, 10% 1s, i.e. a total of 20% with a ratio of 0.5. And brms does exactly reproduce this result, zoi = 0.2 and coi = 0.5. Perfect! If you transform the results from my model you will get zoi = plogis(zoi_Intercept) = plogis(-1.37) = 0.2026198 and get coi = plogis(coi_Intercept) = plogis(0.001447584) = 0.5003619. Great!!!
Now, since they are not dependent on x, there is no need to multiply these scalars with x values, to get a āpredictionā. Therefore, you just have to put them into your formula: yl ā zoicoi+y_mu(1-zoi). If you do this, your results perfectly resemble the conditional_effects either for mu or without parameter specification. The same is true for my model, if I use the plogis function first.
Lastly, as stated above, it does make sense to model phi, zoi and coi dependent on the covariate x. You will find my code in the script. You can see that the posterior predictive check and the loo indicate that this fits much better (and also that model 1 and 2 are identical). Now, since the parameters ARE dependent on x, it makes sense to plot them accordingly. Again, the manual model as well as the brms prediction fit perfectly.
I hope this helps!