Back-transformation in pairs function (lmer analysis)

I'm running lme4 and Im working with a dataset where the variables a,d,e are logtransformed. I wonder how to handle back-transformation concerning the "pairs" function. How do I get the contrast? it is set as a function because in reality there are many columns which I will loop over.

Also, if I logtransform the dataset before I run it in the lmer model, can I tell that the data was logtransformed, even if its not in the model as log(df[,i])? Many thanks!

a <- runif(21)
d <- runif(21)
e <- runif(21)
trt <- rep(LETTERS[1:3],7)
id <- rep(1:7, each=3)
df <- data.frame(id,trt,a,d,e)

func <- function(i){
dflmer <- lmer(formula= log(df[,i]) ~trt+(1|id), data=df)
emm <- emmeans(dflmer,"trt")
emm_df <- data.frame(emm)# I could get the data back-transformed like this
exp(emm[,c(2,5,6)])
contrast(regrid(e, type="log")) #?
}

func(3) # example


Try to add type=response in emmeans. The the problem it is cant read the type of transformation, log(df[,i]). It works if I do df@a, but in my big dataset I need to be able to do log(df[,i]). Any suggestions?

dflmer <- lmer(formula= log(df[,3]) ~trt+(1|id), data=df)
>   emm <- emmeans(dflmer,"trt", type="response")
>   emm
trt response    SE   df lower.CL upper.CL
A      -1.26 0.412 17.9    -2.13   -0.396
B      -1.22 0.412 17.9    -2.09   -0.358
C      -1.20 0.412 17.9    -2.06   -0.329

Degrees-of-freedom method: kenward-roger
Unknown transformation "log.[": no transformation done
Confidence level used: 0.95

• Could you please explain what you mean by "get the contrast"? – whuber Jan 19 at 20:56
• Put tupe = "response" in the emmeans() call. Look at the vignette on transformations in the emmeans package. – Russ Lenth Jan 19 at 23:51
• @Russ Lenth I have updated my example. any suggestion on how to solve this? Many thanks for your response! – user11916948 Jan 20 at 6:39
• @whuber I mean i want to know the difference between A-B, A-C and B-C – user11916948 Jan 20 at 6:40
• In what sense do you want to "know the difference" if not by subtracting pairs of values in -1.26, -1.22, and -1.20 (the "response" values for the classes in the output)? – whuber Jan 20 at 15:11