# Fitting lognormal GLMM correctly?

Hi, I would like to fit a lognormal GLMM but wasn’t sure how to specify it in `greta` code. There isn’t an example in the tutorial, so I simulated some fake data and fitted the model to see if the parameters are correct.

Here’s a minimal code:

``````# simulate a lognormally distributed Y var linearly dependent on X
n <- 1000
x <- rnorm(n)
a <- 1
b <- 1
mulog <- a + b * x
sdlog <- 0.1
y <- rlnorm(n, mulog, sdlog)
# plot(x, y)

library(greta)

int <- normal(0, 10)
coef <- normal(0, 10)
sigma_log <- student(10, 0, 3, truncation = c(0, Inf))

mean_log <- int + coef * x
distribution(y) <- lognormal(mean_log, sigma_log)

m <- model(int, coef, sigma_log)
draws <- mcmc(m, n_samples = 1000, chains = 8)
summary(draws)
``````

The estimated parameters (below) seem to match what I specified quite well, does that mean my model specification is correct? Thank you in advance.

``````1. Empirical mean and standard deviation for each variable,
plus standard error of the mean:

Mean       SD  Naive SE Time-series SE
int       1.00012 0.003013 3.369e-05      6.004e-05
coef      0.99513 0.002929 3.274e-05      6.967e-05
sigma_log 0.09336 0.002008 2.244e-05      2.759e-05

2. Quantiles for each variable:

2.5%     25%     50%     75%   97.5%
int       0.99414 0.99811 1.00014 1.00216 1.00600
coef      0.98939 0.99317 0.99513 0.99708 1.00096
sigma_log 0.08956 0.09195 0.09334 0.09474 0.09733
``````