R: emmeans back-transformation when using a constant value in the response formula I am fitting a linear mixed model
LM.fit=lmer(sqrt(18-FAB)~Group*visit_num+Age+sexe+(1|num_sujet),data)

em<-emmeans(LM.fit,~Group,type="response")

Group response    SE  df lower.CL upper.CL
 G1       0.532 0.116 280    0.328    0.785
 G2       1.072 0.192 295    0.727    1.483
 G3       1.134 0.105 278    0.936    1.350

Results are averaged over the levels of: visit_num, sexe 
Degrees-of-freedom method: kenward-roger 
Confidence level used: 0.95 
Intervals are back-transformed from the sqrt scale 

pairs(regrid(em),adjust="bonferroni")

 contrast  estimate    SE  df t.ratio p.value
 G1- G2    -0.5741 0.223 277  -2.570  0.0321
 G1- G3    -0.5852 0.153 275  -3.837  0.0005
 G2- G3    -0.0111 0.211 275  -0.053  1.0000

Results are averaged over the levels of: visit_num, sexe 
Degrees-of-freedom method: inherited from kenward-roger when re-gridding 
P value adjustment: bonferroni method for 3 tests 

When I look at the estimates it's very clear that something went wrong during the back-transformation.
How Can I back transform using emmeans to have the estimate in the "FAB" scale and not in the "sqrt(18-FAB)" scale ?
 A: The detection of response transformations is pretty primitive, and it just gets interpreted as the square root, as illustrated with a similar example below:
> foo.lm = lm(sqrt(35 - mpg) ~ factor(cyl), data = mtcars)
> foo.emm = emmeans(foo.lm, "cyl")
> foo.emm
 cyl emmean    SE df lower.CL upper.CL
   4   2.76 0.171 29     2.41     3.11
   6   3.90 0.214 29     3.46     4.34
   8   4.45 0.152 29     4.14     4.76

Results are given on the sqrt (not the response) scale. 
Confidence level used: 0.95 

So if you use type = "response", you get estimates on the 35 - mpg` scale:
> confint(foo.emm, type = "response")
 cyl response    SE df lower.CL upper.CL
   4      7.6 0.944 29     5.79     9.65
   6     15.2 1.674 29    12.00    18.84
   8     19.8 1.351 29    17.16    22.68

Confidence level used: 0.95 
Intervals are back-transformed from the sqrt scale 

It is possible to translate this to the mpg scale using the contrast function with arguments offset and scale. We also add an infer argument to update the result so its default summary has confidence intervals.
> bar.emm = contrast(regrid(foo.emm), "identity", 
+     offset = 35, scale = -1, infer = c(TRUE, FALSE))
> bar.emm
 contrast estimate    SE df lower.CL upper.CL
 cyl4         27.4 0.944 29     25.5     29.3
 cyl6         19.8 1.674 29     16.3     23.2
 cyl8         15.2 1.351 29     12.4     17.9

Confidence level used: 0.95 

