back.emmeans: Back-transformation of EMMeans

View source: R/back.emmeans.R

back.emmeansR Documentation

Back-transformation of EMMeans

Description

Back-transforms EMMeans (produced by emmeans) when the model was built on a transformed response variable. This is typically the case when a LM(M) with log(x+1) as response variable gives a better fitting than a GLM(M) for count data, or when a beta regression takes as response a variable on the [0;1] interval that has been rescaled to the (0;1) interval using p.beta.

Usage

back.emmeans(emm, transform = c("log", "logit", "sqrt", "4rt", "inverse", "p.beta"),
  base = exp(1), add = 0, n = NULL, C = 2, ord = FALSE, decreasing = TRUE)

Arguments

emm

object returned by emmeans.

transform

transformation applied to the response variable before building the model on which emm is based ("4rt" is fourth-root). "p.beta" assumes that the model (beta regression) was built using a logit link function.

base

the base with respect to which the logarithm transformation was computed (if transform="log"). Defaults to e=exp(1).

add

value to be added to x before computing the transformation, if needed (e.g. 1 if the initial transformation was log(x+1)).

n

total number of observations in the initial data set. Only used with transform="p.beta", see p.beta.

C

number of categories from which initial continuous proportions were computed. Only used with transform="p.beta", see p.beta.

ord

logical indicating if back-transformed EMMeans should be ordered.

decreasing

logical indicating in which order back-transformed EMMeans should be ordered, if order=TRUE.

Author(s)

Maxime HERVE <maxime.herve@univ-rennes1.fr>

See Also

emmeans

Examples

require(emmeans)

set.seed(1149)
tab <- data.frame(
  response <- c(rpois(30,0),rpois(30,2),rpois(30,4)),
  fact <- gl(3,30,labels=LETTERS[1:3])
)

model <- lm(log(response+1)~fact,data=tab)
EMM <- emmeans(model,~fact)
back.emmeans(EMM,transform="log",add=1)

RVAideMemoire documentation built on Nov. 6, 2023, 5:07 p.m.