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!