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.