Is it possible to model the response variable (reaction time) as lognormal in bambi?

Hello,

I have specified the following model (a varying intercepts model for a reaction time (see figure for the sample data distribution) as a function of condition = [baseline, treatment1, treatment2]) with the bambi package:

reaction_time

b_model = Model(data)

results = b_model.fit(‘reaction_time ~ 1 + condition’, random = [‘1|subject_id’],
samples = 3000, tune = 2000)

As the title says: is there a possibility to model the response variable (in my case a reaction time) as lognormal (or any other right skewed option)? I have seen the possibility to specify a family, but can’t understand how to do it.

Thanks

Not sure if lognormal likelihood is implemented in bambi, @aloctavodia ?

1 Like

Hi @tankenot

You can specify a family by passing the argument family to fit, the available families are “gaussian”, “bernoulli” and “poisson”.

If your variable y is lognormal distributed then log(y) is normal distributed, then you can transform your variable y and keep the bambi model the same. Even if your data is not really lognormal taking the log can help with right skewed data.

Thanks @aloctavodia,

I will give it a try! :slight_smile:

@aloctavodia

Hi,
I’ve fit my model using the log(y) which is fine.

  1. Since I’m interested in comparing the means for baseline, treatment 1 and treatment 2, is there any way I can back transform my model parameters to obtain posterior distributions on my original scale (in seconds since I’m working with reaction times)? Modelling reaction time as normally distributed, I would obtain the difference: baseline vs. treatment 1 as the slope1 coefficient and baseline vs. treatment 2 as the slope2 coefficient.

Thanks