# Lognormal model: how to properly backtransform interaction estimates?

I hope this is on topic, if not please let me know I’ll delete the post.
Also a disclaimer: I already posted the same question on stats.stackexchange but did not get any answers (if this is not ok to cross-post also please let me know I’ll delete it)

I fit a model in brms like this:

brm(rt ~ c * d +
(1 + c * d | subj) +
(1 + c * d | item),
family = lognormal(),
prior = priors,
iter = 4000)


So the model is really:

\begin{align} y & \sim logNormal(\mu, \sigma)\\ \mu_n & = \alpha + \beta_0 c_n + \beta_1 d_n + \beta_2 c_n d_n \end{align}

where:

• y is a variable measured in ms
• c is a sum-contrast coded variable equal to 1 or -1.
• d is a scaled and centered continuous variable

I have trouble with backtransforming the estimates into the ms scale.
I think I know how to do this for c:

\mu|_{c=1} - \mu|_{c=-1} = \exp (\alpha + \beta_0 + \beta_1 d_n + \beta_2 d_n ) - \exp (\alpha - \beta_0 + \beta_1 d_n - \beta_2 d_n )

For interaction this is slightly more complicated. Let the interaction effect be:
IE = \frac{\partial \mu}{\partial d}|_{c = 1} - \frac{\partial \mu}{\partial d}|_{c = -1}. I remove the log by exponentiation and then I take the derivative which results in:

\frac{\partial \mu}{\partial d} = \exp (\alpha + \beta_0 c_n + \beta_1 d_n + \beta_2 c_n d_n ) (\beta_1 + \beta_2 c_n)

So the interaction effect is the difference of these two terms:

\begin{align} \frac{\partial \mu}{\partial d}|_{c = 1} = & \exp (\alpha + \beta_0 + \beta_1 d_n + \beta_2 d_n ) (\beta_1 + \beta_2) \\ \frac{\partial \mu}{\partial d}|_{c = -1} = & \exp (\alpha - \beta_0 + \beta_1 d_n - \beta_2 d_n ) (\beta_1 - \beta_2) \\ \end{align}

Are these derivations correct?
If yes, this means that these effects are functions of d, but fitting the model returns the effects (on the log scale) as constants. Could someone explain or point me to a resource to understand where does this difference come from?

Another question I have is how to derive and interpret the effect for d? Ie. what are the meaningful points at which to evaluate the function \mu? Or maybe is there a better way of doing this?

If you think it’s easier to do in rstan (maybe in the generated quantities?) I’m fine with converting this to stan.

1 Like

Hi, this could be of help perhaps?

3 Likes