A related question was asked on this thread How to calculate percentage difference of geometric means with emmeans?, but I still need some help.

Instead of calculating the absolute difference between two groups, I would like to calcuate the percentage change between these groups from the model estimates. This is the model (I am using brms)

chla_full_model.brm = bf(Chl_a_avg_std ~ 1 + Stage*Treatment + Sample_date + Avg_length_std + (1|Mesocosm))

For each treatment I would like to calculate the percentage change of Chl_a_avg_std between stages. There are 4 stages (1,2,3,4), and I am only interested in the percentage change between stage 1 and 2, 2 and 3....an so forth. This my code currently

chla.emm <- emmeans(chla_full.model, ~ Stage|Treatment)
chla.cont = contrast(chla.emm, 
                 list('Stage1 vs. Stage2' = c(-1, 1, 0, 0),
                    'Stage2 vs. Stage3 ' = c(0, -1, 1, 0),
                    'Stage3 vs. Stage4 ' = c(0,0, -1, 1)))

The gives me the absolute difference between my contrasts, but I would like to obtain percentage change. My understanding from the previous thread is that I need to create a custom scale function through the 'tran' argument in the contrast function. There is an example given in a vignette associated with emmeans package, but my coding skills and understanding are rudimentary, and I havent been able to workout how to solve my problem. Any help would be much appreciated.

  • $\begingroup$ Welcome to cv, mrmic1! (1)Could you explain what you mean by percentage change (a number example, eg. Stage 1 = 80, stage 2 = 100 => 25%?) (2) And could you give a bit background: what does "chl_a_avg_std" represent, in real world terms? $\endgroup$
    – Ute
    Aug 22 at 5:42
  • $\begingroup$ Thanks @Ute. Data comes from a mesocosm study where we measured a range of community metrics at different different stages of the experiment. Chla_a_avg_std is chlorophyll a concentration and the variable has been standardized to help with model implementation. So basically, all I want to do is estimate the percentage change (increase or decrease) between sequential stages (1 v 2, 2 v 3 etc.). As in your example, the model predicted average of chl_a in Stage 1 might be 80, and stage 2 its 100, so there was a 25% increase. But I want to calcluate this using the model predictions and emmeans $\endgroup$
    – mrmic1
    Aug 25 at 0:51

1 Answer 1


Do this:

contrast(regrid(chla.emm, "log"), "consec", type = "response")

The regrid part transforms the estimates to the log scale. The "consec" spec is shorthand for what you specified, and type = "response" back-transforms the differences from the log scale to the response scale (difference of logs are logs of ratios).


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.