Hi everyone,

As a bit of context, I am fitting a non-linear model aiming to account for misclassification errors with a binary outcome using brms (R, 4.2.2).

In a nutshell, the true probability of occurrence of the outcome is specified as p^* = 1/(1+exp(-\mu)), with

With \alpha an individual-specific varying slope and f_{.} splines.

From what I have seen, because the model involves interactions, the correct approach to explore the relation between the explanatory variables and p^* is to use conditional effects.

However, I am a bit worried that reviewers/readers (general readers in clinical epi/public health) would be bothered by the absence of unconditional measures of effect and suggest dropping the interaction, which seems quite relevant to the context, although routinely avoided in published papers. Besides, there is no natural value to condition on for the time or age.

I implemented the following approach to avoid conditioning on variables that are not of direct interest:

- Generate a grid over sex x age x time (with 1 year gap between age and 1 day for time)
- Perform X draws from the posterior conditional effect for each cell of the grid (
`posterior_epred(brmsfit,newdata = grid,nlpar = 'p', re_formula = NA)`

), possibly computing the marginal effect of sex or age - Summarise the distribution of all draws by sex/age/time/age and sex/sex and time and report them as ‘marginalised conditional effect of X’ (for conditional effects) and ‘marginalised marginal effect of X’ (for marginal effects)

The whole process is very computationally demanding but still manageable because I only have 3 variables in total, a moderate number of time periods, and access to a HPC.

I’d like to have feedback on the approach (is it completely wrong ?) and maybe a redirection towards a package or function that would do this in a more efficient way (although doable, the procedure I described is still very long).

I went across the brmsmargins package for marginal effects and still have to make sure it can handle non-linear models but I welcome any other ideas.

Thank you for your time !