Learn R Programming

RVAideMemoire (version 0.9-45-2)

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", "inverse"), base = exp(1),
  add=0)

Arguments

lsm
object returned by lsmeans.
transform
transformation applied to the response variable before building the model on which lsm is based.
base
the base with respect to which the logarithm transformation was computed (if transform="log"). Defaults to e=exp(1).
add
value added to x before computing the transformation, if needed (e.g. 1 if the initial transformation was log(x+1)).

See Also

lsmeans

Examples

Run this code
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