Learn R Programming

RVAideMemoire (version 0.9-68)

back.lsmeans: Back-transformation of LSMeans

Description

Back-transforms LSMeans (produced by lsmeans) 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.

Usage

back.lsmeans(lsm, transform = c("log", "logit", "sqrt", "4rt", "inverse"), base = exp(1),
  add = 0, ord = FALSE, decreasing = TRUE)

Arguments

lsm

object returned by lsmeans.

transform

transformation applied to the response variable before building the model on which lsm is based ("4rt" is fourth-root).

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)).

ord

logical indicating if back-transformed LSMeans should be ordered.

decreasing

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

See Also

lsmeans

Examples

Run this code
# NOT RUN {
require(lsmeans)

set.seed(1149)
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)
LSM <- lsmeans(model,~fact)
back.lsmeans(LSM,transform="log",add=1)
# }

Run the code above in your browser using DataLab