Do I need to transform my response variable to fit a lognormal GLM in brms?

Hi. I am trying to fit a lognormal generalized linear model (GLM) in R using the brms package.

My response variable is fish biomass which is continuous and strictly positive, and I suspect that it may follow a lognormal distribution.

I’m wondering if I need to transform my response variable before fitting the model?
Which of the three models below is correct?

# Load brms package
library(brms)

# Generate example data
set.seed(123)
n <- 100
predictor1 <- rnorm(n)
predictor2 <- rnorm(n)
response <- exp(1 + 0.5*predictor1 + 0.8*predictor2 + rnorm(n, 0, 0.5)) + 1
mydata <- data.frame(predictor1, predictor2, response)

# Fit lognormal GLM using brms
model1 <- brm(log(response) ~ predictor1 + predictor2, 
              data = mydata)

model2 <- brm(log(response) ~ predictor1 + predictor2, 
              data = mydata, family = lognormal())

model3 <- brm(response ~ predictor1 + predictor2, 
              data = mydata, family = lognormal())


summary(model1)
summary(model2)
summary(model3)

Thanks!

If you want to run a log-normal GLM with brms (or another package for that matter), you can either:

  1. log-transform your data and run a regular LM (link function = identity), or
  2. Directly analyse the data with a GLM with log as link function and a log-normal likelihood (the “family” in R lingo).

Both methods should yield the same parameter estimates (provided there aren’t subtle aspects you did not describe, like clustering of data, for which a regular LM would not be appropriate).

2 Likes