# Estimating treatment effects and ICCs from (G)LMMs on the observed scale using Bayes, Part 1: lognormal models

When a **multilevel** model includes either a non-linear transformation (such as the log-transformation) of the response variable, or of the expectations via a GLM link-function, then the interpretation of the results will be different compared to a standard Gaussian multilevel model; specifically, the estimates will be on a transformed scale and not in the original units, and the effects will no longer refer to the average effect in the population, instead they are conditional/cluster-specific. In this post, I will deal with linear mixed-effects models (LMM) that use a log-transformed outcome variable. This will be the first part of a three-part tutorial on some of the finer details of (G)LMMs, and how Bayes can make your (frequentist) life easier. In each post I will focus on:

**log-transformation**of the dependent variable in a**multilevel**model- Calculating both
**multiplicative effects**(% change) and differences on the**untransformed scale**. **Subject-specific**/cluster-specific versus**population-average effects**(conditional versus marginal effects).**Intraclass correlations**on the transformed/link/latent scale or on the response/data/original scale.

In part 2 I will cover a GLMM with a binary outcome, and part 3 will focus on semicontinuous (hurdle/two-part) models when the outcome is a skewed continuous variable that include zeros.

The aim of this post is also to show:

- How simulation-based approaches like MCMC make it much easier to make inferences about transformed parameters.
- How the estimates from a multilevel model can be transformed to answer the same questions as population-average models or fixed effects models.

## Data-generating model: a lognormal LMM

As an example, we will use a simple hierarchical design with clusters nested within either a treatment or a control condition. This is a classic 2-level multilevel model.

$log(y_{ij}∣u_{i},TX_{i})∼N(β_{0}+β_{1}TX_{i}+u_{i},σ_{e})$$u_{i}∼N(0,σ_{u})$In this model, the natural logarithm of $y$ is normally distributed conditional on the cluster-specific effect $u_{i}$ and the treatment variable $TX$. Let’s assume $y$ is the average money (in USD) lost gambling per week (since I do research on gambling disorder). Gambling expenditure is sometimes quite well described by a lognormal distribution, or a (generalized) Gamma distribution. Importantly, the methods in this post can quite easily be tweaked to work with other response distributions. Each treatment arm has $n_{2}$ clusters, and each cluster has $n_{1}$ observations. In this example clusters refer to e.g. schools, centers, groups, and the first level are subjects. However, it would be easy to use the contents of this post for a longitudinal model where clusters refer to subjects, and the subjects have repeated observations.

## Simulate data

Let’s create a simple function that generates data from this model

The model parameters are

## Fit the model

We can fit this model using `brms`

(or rstanarm, lme4, etc).

Using the notation of our 2-level model, we get these results

Parameter | Estimate |
---|---|

$β^ _{0}$ | 6.21 |

$β^ _{1}$ | -0.70 |

$σ^_{u}$ | 0.64 |

$σ^_{e}$ | 0.51 |

## Interpreting the parameters

All of the estimates are on the log scale, and they do not have an immediate interpretation on the natural scale. To further complicate things we should also remind ourselves that the effects from (G)LMM have cluster-specific interpretations (“subject-specific” in a longitudinal model when clusters = subjects). Researchers who work mostly with LMMs sometimes tend to forget this, since for LMMs the cluster-specific effects are equal to the population-average (marginal) effects. The non-linear transformation of either the data (like the log-transformation) or via the link function in (G)LMMs both means that back-transformation of the model’s estimates from e.g. the log scale does not give the expected values on the natural scale (cf. Jensen’s inequality).

In the figure below I try to illustrate both the cluster-specific nature of the model, and the transformation between the log scale and the natural data scale, without being too technical.

### How to calculate marginal effects on the data scale

So how do we derive the numbers presented in the figure above? Well, for the lognormal distribution with the log mean $μ$ and the log SD $σ_{e}$ we have:

- mean: $exp(μ+2σ_{e} )$
- median: $exp(μ)$

If we want to get the marginal mean we need to average this back-transformation over the random effects distribution. Since, as noted earlier, simply back-transforming the log coefficient (the expected mean on the log scale) will not give the expected mean on the original scale (money lost).

$exp(β_{0}+2σ_{e} )=E(Y_{ij}∣TX=0)$The correct expectation is

$E(y_{ij}∣TX=0)=∫exp(x+σ_{e}/2)f_{N}(x,β_{0},σ_{u})dx$This integral is easily solved using numerical integration.

In this case, we can also derive an exact and simple solution using the moment-generating function of the lognormal distribution (see Proof 1: left as an exercise to the reader 🤓)

A third option is Monte Carlo integration. Were we simply simulate a large number of cluster outcomes on the log scale, back-transform to the natural scale, and then get the average. For multivariate integrals (e.g. models with correlated random effects) this is often the simplest solution that also works well in practice, although the package `cubature`

offers a fast solution using adaptive numerical integration.

We see that all three methods give the same result (within Monte Carlo error).

### Can we interpret the cluster-specific values?

So, if the expected value for the outcome group is 642 USD, and $exp(β_{0}+2σ_{e} )$ = 567 USD is there a meaningful interpretation of 567? As shown in the figure above, this is the expected value for the cluster at the center of the distribution of cluster means on the *log scale*. Since percentiles are invariant under a monotonic transformation (and the mean is equal to the median for the normal distribution), this cluster (with $u_{i}=0$) is also at the median on the natural scale.

So to summarize, the cluster-specific effects are,

$E(y_{ij}∣u_{i},TX_{i})=exp(β_{0}+β_{1}TX_{i}+u_{i}+2σ_{e} ),$and the expected marginal mean in each treatment group is,

$E(y_{ij}∣TX_{i})=exp(β_{0}+β_{1}TX_{i}+2σ_{u}+σ_{e} )$### Average treatment effects on the data scale

Using the results above, the cluster-specific average treatment effect on the original scale is,

$E(Y_{ij}∣u_{i},TX=1)−E(Y_{ij}∣u_{i},TX=0)=exp(β_{0}+β_{1}+u_{i}+2σ_{e} )−exp(β_{0}+u_{i}+2σ_{e} )$which is (for $u_{i}=0$),

And the marginal treatment effect on the original scale is,

$E(Y_{ij}∣TX=1)−E(Y_{ij}∣TX=0)=exp(β_{0}+β_{1}+2σ_{e}+σ_{u} )−exp(β_{0}+2σ_{e}+σ_{u} )$### Multiplicate effects (% change)

Most know that if we take the exponent of the log difference we get the % change. Generally, these multiplicative effects are also cluster-specific. However, for our simple model $exp(β_{1})$ gives both the cluster-specific and population-average effect. We can see this if we look at the ratio of the expected conditional outcome in the treatment and control group,

$E(Y_{ij}∣u_{i},TX=0)E(Y_{ij}∣u_{i},TX=1) =exp(β_{0}+u_{i}+2σ_{e} )exp(β_{0}+β_{1}+u_{i}+2σ_{e} ) =exp(β_{1}) $and similarly for the marginal outcomes

$E(Y_{ij}∣TX=0)E(Y_{ij}∣TX=1) =exp(β_{0}+2σ_{u}+σ_{e} )exp(β_{0}+β_{1}+2σ_{u}+σ_{e} ) =exp(β_{1}). $The cluster-specific and population-average effect is the same. However, this is not true in general for nonlinear transformation or GLMM link functions (which we shall see in part 2 on binary outcomes).

### 95 % CIs for the backtransformed marginal effects

Getting back to our fitted model, let’s see how we can transform the estimates into the posterior distribution of e.g. the marginal mean outcome in the control group. We do this by applying the back-transformation and marginalization using all the posterior samples of $β^ _{0}$, $σ^_{u}$, and $σ^_{e}$.

As one would expect, estimates of the population effect are less precise compared to condition on a specific cluster effect.

### Summarizing the model

Let’s summarize all the results from the model, both the conditional and marginal, absolute and multiplicative treatment effects.

Effect | Formula | posterior_median | l_95_CI | u_95_CI |
---|---|---|---|---|

Average outcome for a median cluster in the control group | $E(Y_{ij}∣u_{i}=0,TX=0)$ | 570.5 | 374.5 | 847.9 |

Average outcome for a median cluster in the treatment group | $E(Y_{ij}∣u_{i}=0,TX=1)$ | 281.8 | 186.7 | 435.2 |

Average outcome in the control group | $E(Y_{ij}∣TX=0)$ | 697.9 | 454.5 | 1123.4 |

Average outcome in the treatment group | $E(Y_{ij}∣TX=1)$ | 342.7 | 231.3 | 575.5 |

Difference between the average outcome in a median cluster in the treatment versus control group | $E(Y_{ij}∣u_{i}=0,TX=1)−E(Y_{ij}∣u_{i}=0,TX=0)$ | -286.1 | -580.2 | -37.9 |

Difference between the average outcome in the treatment versus control group | $E(Y_{ij}∣TX=1)−E(Y_{ij}∣TX=0)$ | -349.0 | -747.5 | -47.4 |

Ratio of the average outcome in a median cluster in the treatment and the control group | $E(Y_{ij}∣u_{i}=0,TX=0)E(Y_{ij}∣u_{i}=0,TX=1) $ | 0.5 | 0.3 | 0.9 |

Ratio of the average outcome in the treatment and the control group | $E(Y_{ij}∣TX=0)E(Y_{ij}∣TX=1) $ | 0.5 | 0.3 | 0.9 |

Ratio of the average outcome in the treatment and the control group | $exp(β_{1})$ | 0.5 | 0.3 | 0.9 |

### Using brms::fitted

Let’s compare our results to the predicted means we get with `brms::fitted`

and `brms::marginal_effects`

We see that this is exactly the same as the median outcome (cluster-specific outcome) in the control group. I’ve seen some people confused about this since the function is called `marginal_effects`

.

### Limiting inference to only the included clusters

We can also use `fitted`

to average over the included clusters, this is very similar to fitting the clusters as “fixed effects”. So let’s compare averaging over the included clusters in the multilevel model to fitting a fixed effects (no pooling) model.

Let’s look at the predicted mean for the control group using the fixed effects model.

Which is really similar to the control groups sample mean which is 636. Now let’s compare the posterior distribution from the fixed effects model, to using our multilevel model to average over only the included clusters (and not the estimated distribution of clusters).

We see that the results are highly similar. Although, the models behind the results do differ. If we look at the estimates for the specific clusters we can see the—in this model very weak—effect of partial pooling in the multilevel model.

## Intraclass correlations (ICC)

Since the variance components are on the log scale ICCs calculated using them will also be on the log scale. This is not always what we want, for instance, if we are calculating agreement, reliability, or heritability, it can make a lot of sense to calculate ICCs on the data scale. If I am calculating ICCs for family members’ reports on gambling losses, then I am interested in agreement on the data scale (USD) and not on the log scale.

ICCs on the data scale can be calculated using the same techniques we used for the marginalization of the outcomes. You can read more about this in the context of GLMMs in Villemereuil et al. (2016; and the related R package `QQglmm`

). Here is an example, first we calculate the marginal mean

then we use the marginal mean to calculate the expected variance between clusters on the data scale,

$σ_{B}=∫(e_{x}−μˉ _{i})_{2}f_{N}(x,μ_{i},σ_{u_{0}})dx$and lastly we calculate the expected variance within clusters on the data scale,

$σ_{W}=∫((exp(σ_{e})−1)exp(2x+σ_{e}))f_{N}(x,μ_{i},σ_{u_{0}})dx.$Where $(exp(σ_{e})−1)exp(2x+σ_{e})$ is the variance of the lognormal distribution evaluated at $x$.

The ICC on the response scale in then

$Cor(y_{ij},y_{ij_{′}})=σ_{B}+σ_{W}σ_{B} $Whereas, the log scale ICC is,

$Cor(log(y_{ij}),log(y_{ij_{′}}))=σ_{u}+σ_{e}σ_{u} $Since this is also a one-dimensional integral we can use `integrate`

,

If you find simulations more intuitive, the Monte Carlo version would be

Let’s see if the two methods agree.

Data scale (Integrate) | Data scale (Simulate) | Log scale | |
---|---|---|---|

ICC | 0.44 | 0.44 | 0.5 |

WI_sd | 387.71 | 387.69 | NA |

BW_sd | 342.15 | 342.22 | NA |

mean | 642.01 | 641.93 | NA |

Great! We also see that by calculating variances on the data scale the ICCs are lower, in this case, the difference is small, but if the log variance is large this difference can be *very* large. So when you see ICCs from lognormal models or GLMMs you should ask if they are on the transformed (latent) scale or on the observed (data) scale, and if the scale is appropriate for the research question.

## Simulation study

I began by promising that the methods in this post could make your *frequentist* life easier, and then continued to only fit Bayesian models. So let’s do a small simulation study to evaluate the frequentist properties of this model and all the transformations and marginalizations. I will try two different models, shown in the table below, each model will be evaluated using 5000 replications, and I will fit both the correct model using a lognormal response distribution and a standard LMM using the Gaussian response distribution.

Parameter | Sim1: less skew | Sim2: more skew |
---|---|---|

$β_{0}$ | log(500) | log(500) |

$β_{1}$ | log(0.5) | log(0.5) |

$σ_{u}$ | 0.5 | 1 |

$σ_{e}$ | 0.5 | 1 |

$n_{1}$ | 30 | 5 |

$n_{2}$ | 10 | 75 |

### Simulation results

In the figures below we see that the posterior median show mostly negligible bias for both the original parameters and the transformed marginal effects. The Gaussian model has the most trouble with the variance components, which show substantial bias.

If we look at the coverage probabilities we see that the lognormal model’s posterior intervals have nominal coverage rates for all parameters. The Gaussian model has slightly worse coverage for the treatment effects, but not that bad. However, the CI’s from the Gaussian model does a poor job of capturing the true ICC and variance components.

### Power

Lastly, let’s take a closer look at the marginalized treatment effect on the data scale. The figure below shows a sample of the confidence intervals for the difference in the average money lost gambling from the two conditions, from Model 2 with more skewed data. We can see that the, although, the normal model is quite robust and the estimated effect is unbiased, it is less precise which leads to reduced power and CIs with worse coverage compared to the true lognormal model.

## Summary

There is a lot of information in this post, so let’s summarize the key take-home messages:

- Both cluster-specific (conditional) and population-average (marginal) treatment effects are useful—they just answer different questions and we should be careful to not mixed them up.
- The multilevel model can be used to give both cluster-specific (conditional) and population-average effects on both the original and transformed scale while retaining all of the advantages of likelihood-based/Bayesian methods.
- There is no free lunch. We saw that the calculations of the marginal effects on the data scale use estimates of both the lognormal variance, as well as the random intercept. Thus, model misspecification will have a large impact on the appropriateness of the back-transformation. In that sense, directly modeling the population-average effects using e.g. GEE and applying nonparametric retransformations (e.g. smearing) is more robust in some aspects. However, once we add complexities like MNAR missing data in combination with weak adherence (both by patients and therapists…) to complex interventions, then it can be argued that a carefully specified generative model that combines both statistical and clinical expertise will be more likely to give useful answers regarding the treatment effect. In my experience, such models will often have multilevel and cluster-specific components.
- For outcomes that are highly meaningful on the original scale (such as expenditures), absolute effects on the data scale can be very meaningful.
- Using the default priors in brms resulted in frequentist CI’s with nominal coverage probabilities.
- It is useful to understand how the conditional and marginal effects relate to each other, to avoid misinterpretations of the default cluster-specific effects (very common in the clinical studies I read).

## Further reading

The issues covered in this post is dealt with in many articles, here is a selection of relevant articles:

- Gromping, U. (1996). A Note on Fitting a Marginal Model to Mixed Effects Log-Linear Regression Data via GEE. Biometrics, 52(1), 280–285. https://doi.org/10.2307/2533162
- Heagerty, P. J., & Zeger, S. L. (2000). Marginalized multilevel models and likelihood inference (with comments and a rejoinder by the authors). Statistical Science, 15(1), 1–26. https://doi.org/10.1214/ss/1009212671
- Hedeker, D., Toit, S. H. C. du, Demirtas, H., & Gibbons, R. D. (2018). A note on marginalization of regression parameters from mixed models of binary outcomes. Biometrics, 74(1), 354–361. https://doi.org/10.1111/biom.12707
- Villemereuil, P. de, Schielzeth, H., Nakagawa, S., & Morrissey, M. (2016). General Methods for Evolutionary Quantitative Genetic Inference from Generalized Mixed Models. Genetics, 204(3), 1281–1294. https://doi.org/10.1534/genetics.115.186536

## Simulation code

`run_sim.R`

: perform the simulation

`summarise_sim.R`

: Summarize results

`functions.R`

: Functions used

Written by **Kristoffer Magnusson**, a researcher in clinical psychology. You should follow him on Twitter and come hang out on the open science discord Git Gud Science.

Published August 05, 2018 (View on GitHub)

### Buy Me A Coffee

A huge thanks to the **79** supporters who've bought me a **179** coffees!

Jason Rinaldo bought ☕☕☕☕☕☕☕☕☕☕ (10) coffees

I've been looking for applets that show this for YEARS, for demonstrations for classes. Thank you so much! Students do not need to tolarate my whiteboard scrawl now. I'm sure they'd appreciate you, too.l

Someone bought ☕☕☕☕☕ (5) coffees

What a great site

@Daniel_Brad4d bought ☕☕☕☕☕ (5) coffees

Wonderful work!

David Loschelder bought ☕☕☕☕☕ (5) coffees

Terrific work. So very helpful. Thank you very much.

@neilmeigh bought ☕☕☕☕☕ (5) coffees

I am so grateful for your page and can't thank you enough!

@giladfeldman bought ☕☕☕☕☕ (5) coffees

Wonderful work, I use it every semester and it really helps the students (and me) understand things better. Keep going strong.

Dean Norris bought ☕☕☕☕☕ (5) coffees

Sal bought ☕☕☕☕☕ (5) coffees

Really super useful, especially for teaching. Thanks for this!

dde@paxis.org bought ☕☕☕☕☕ (5) coffees

Very helpful to helping teach teachers about the effects of the Good Behavior Game

@akreutzer82 bought ☕☕☕☕☕ (5) coffees

Amazing visualizations! Thank you!

@rdh_CLE bought ☕☕☕☕☕ (5) coffees

So good!

Someone bought ☕☕☕ (3) coffees

Ruslan Klymentiev bought ☕☕☕ (3) coffees

@lkizbok bought ☕☕☕ (3) coffees

Keep up the nice work, thank you!

@TELLlab bought ☕☕☕ (3) coffees

Thanks - this will help me to teach tomorrow!

SCCT/Psychology bought ☕☕☕ (3) coffees

Keep the visualizations coming!

@elena_bolt bought ☕☕☕ (3) coffees

Thank you so much for your work, Kristoffer. I use your visualizations to explain concepts to my tutoring students and they are a huge help.

A random user bought ☕☕☕ (3) coffees

Thank you for making such useful and pretty tools. It not only helped me understand more about power, effect size, etc, but also made my quanti-method class more engaging and interesting. Thank you and wish you a great 2021!

@hertzpodcast bought ☕☕☕ (3) coffees

We've mentioned your work a few times on our podcast and we recently sent a poster to a listener as prize so we wanted to buy you a few coffees. Thanks for the great work that you do!Dan Quintana and James Heathers - Co-hosts of Everything Hertz

Cameron Proctor bought ☕☕☕ (3) coffees

Used your vizualization in class today. Thanks!

eshulman@brocku.ca bought ☕☕☕ (3) coffees

My students love these visualizations and so do I! Thanks for helping me make stats more intuitive.

Someone bought ☕☕☕ (3) coffees

Adrian Helgå Vestøl bought ☕☕☕ (3) coffees

@misteryosupjoo bought ☕☕☕ (3) coffees

For a high school teacher of psychology, I would be lost without your visualizations. The ability to interact and manipulate allows students to get it in a very sticky manner. Thank you!!!

Chi bought ☕☕☕ (3) coffees

You Cohen's d post really helped me explaining the interpretation to people who don't know stats! Thank you!

Someone bought ☕☕☕ (3) coffees

You doing useful work !! thanks !!

@ArtisanalANN bought ☕☕☕ (3) coffees

Enjoy.

@jsholtes bought ☕☕☕ (3) coffees

Teaching stats to civil engineer undergrads (first time teaching for me, first time for most of them too) and grasping for some good explanations of hypothesis testing, power, and CI's. Love these interactive graphics!

@notawful bought ☕☕☕ (3) coffees

Thank you for using your stats and programming gifts in such a useful, generous manner. -Jess

Mateu Servera bought ☕☕☕ (3) coffees

A job that must have cost far more coffees than we can afford you ;-). Thank you.

@cdrawn bought ☕☕☕ (3) coffees

Thank you! Such a great resource for teaching these concepts, especially CI, Power, correlation.

Julia bought ☕☕☕ (3) coffees

Fantastic work with the visualizations!

@felixthoemmes bought ☕☕☕ (3) coffees

@dalejbarr bought ☕☕☕ (3) coffees

Your work is amazing! I use your visualizations often in my teaching. Thank you.

@PsychoMouse bought ☕☕☕ (3) coffees

Excellent! Well done! SOOOO Useful!😊 🐭

@whlevine bought ☕☕ (2) coffees

Thank you so much for these amazing visualizations. They're a great teaching tool and the allow me to show students things that it would take me weeks or months to program myself.

Someone bought ☕☕ (2) coffees

@notawful bought ☕☕ (2) coffees

Thank you for sharing your visualization skills with the rest of us! I use them frequently when teaching intro stats.

@inthelabagain bought ☕ (1) coffee

Really wonderful visuals, and such a fantastic and effective teaching tool. So many thanks!

Someone bought ☕ (1) coffee

Someone bought ☕ (1) coffee

Yashashree Panda bought ☕ (1) coffee

I really like your work.

Ben bought ☕ (1) coffee

You're awesome. I have students in my intro stats class say, "I get it now," after using your tool. Thanks for making my job easier.

Gabriel Recchia bought ☕ (1) coffee

Incredibly useful tool!

Shiseida Sade Kelly Aponte bought ☕ (1) coffee

Thanks for the assistance for RSCH 8210.

@Benedikt_Hell bought ☕ (1) coffee

Great tools! Thank you very much!

Amalia Alvarez bought ☕ (1) coffee

@noelnguyen16 bought ☕ (1) coffee

Hi Kristoffer, many thanks for making all this great stuff available to the community!

Eran Barzilai bought ☕ (1) coffee

These visualizations are awesome! thank you for creating it

Someone bought ☕ (1) coffee

Chris SG bought ☕ (1) coffee

Very nice.

Gray Church bought ☕ (1) coffee

Thank you for the visualizations. They are fun and informative.

Qamar bought ☕ (1) coffee

Tanya McGhee bought ☕ (1) coffee

@schultemi bought ☕ (1) coffee

Neilo bought ☕ (1) coffee

Really helpful visualisations, thanks!

Someone bought ☕ (1) coffee

This is amazing stuff. Very slick.

Someone bought ☕ (1) coffee

Sarko bought ☕ (1) coffee

Thanks so much for creating this! Really helpful for being able to explain effect size to a clinician I'm doing an analysis for.

@DominikaSlus bought ☕ (1) coffee

Thank you! This page is super useful. I'll spread the word.

Someone bought ☕ (1) coffee

Melinda Rice bought ☕ (1) coffee

Thank you so much for creating these tools! As we face the challenge of teaching statistical concepts online, this is an invaluable resource.

@tmoldwin bought ☕ (1) coffee

Fantastic resource. I think you would be well served to have one page indexing all your visualizations, that would make it more accessible for sharing as a common resource.

Someone bought ☕ (1) coffee

Fantastic Visualizations! Amazing way to to demonstrate how n/power/beta/alpha/effect size are all interrelated - especially for visual learners! Thank you for creating this?

@jackferd bought ☕ (1) coffee

Incredible visualizations and the best power analysis software on R.

Cameron Proctor bought ☕ (1) coffee

Great website!

Someone bought ☕ (1) coffee

Hanah Chapman bought ☕ (1) coffee

Thank you for this work!!

Someone bought ☕ (1) coffee

Jayme bought ☕ (1) coffee

Nice explanation and visual guide of Cohen's d

Bart Comly Boyce bought ☕ (1) coffee

thank you

Dr. Mitchell Earleywine bought ☕ (1) coffee

This site is superb!

Florent bought ☕ (1) coffee

Zampeta bought ☕ (1) coffee

thank you for sharing your work.

Mila bought ☕ (1) coffee

Thank you for the website, made me smile AND smarter :O enjoy your coffee! :)

Deb bought ☕ (1) coffee

Struggling with statistics and your interactive diagram made me smile to see that someone cares enough about us strugglers to make a visual to help us out!😍

Someone bought ☕ (1) coffee

@exerpsysing bought ☕ (1) coffee

Much thanks! Visualizations are key to my learning style!

Someone bought ☕ (1) coffee

## Sponsors

You can sponsor my open source work using GitHub Sponsors and have your name shown here.

Backers ✨❤️

#### Questions & Comments

Please use GitHub Discussions for any questions related to this post, or open an issue on GitHub if you've found a bug or wan't to make a feature request.

## Archived Comments (5)

Thank you for the great post!

One question. How would the following calculation of population-average effects change if there were several random effects, and/or random slopes?`exp(B0 + (u0^2 + sd_log^2)/2)`

i.e., if the model formula was, for example,`y ~ 1 + TX + (1 + TX | cluster)`

or`y ~ 1 + TX + (1 | cluster1) + (1 | cluster2)`

Great work. But is there any reference on why the marginal mean should be exp(mu+sigma^2/2) (why it is 2 in the denominator) and on the integration formula for expected value of y_ij given TX=0. Are they just commen sense in statistics?

Thanks! It's just the formula for the mean on the original scale, as a function of log(mean) and log(sd). See e.g. https://en.wikipedia.org/wi... under "Arithmetic moments".

Great post and a really superb graphics! Thanks

The timing of this series is impeccable as I'm currently trying to calculate ICCs for models with non-normal outcomes. Thank you.