Learn R Programming

ClinReport (version 0.9.1.12)

report.lsmeans: 'LS Means' statistics reporting

Description

Creates a desc object for "LS Means" statistics reporting.

Usage

report.lsmeans(lsm, x1 = "treatment", x2 = NULL, x3 = NULL, data,
  variable.name = "Statistics", at.row = NULL, infer = c(T, T),
  type = "link", contrast = F, contrast.name = "contrast",
  x1.name = "treatment", x2.name = NULL, x3.name = NULL)

Arguments

lsm

emmGrid object (result of a emmeans call)

x1

Character Mandatory. Indicating a factor in the data (can be an intercept: see example). Levels will be displayed in columns

x2

Character indicating a factor in the data. Levels will be displayed in rows

x3

Character indicating a factor in the data. Levels will be displayed in rows

data

Data.frame object from which the Least Square means are coming from

variable.name

Character. The label of the column which indicates the statistics reported.

at.row

Character. Passed to spacetable function. Used to space the results per levels of the mentioned variable

infer

A vector of one or two logical values. Passed to summary.emmGrid function.

type

Character. Type of prediction desired. Passed to summary.emmGrid function. Can be "link" or "response"

contrast

Logical. Specify if the contrast function has been used after the emmeans function (see examples)

contrast.name

Character. Corresponds to the label of the column in which the contrasts are specified (see example). Default value is 'contrast'.

x1.name

Character. Deprecated (replaced by x1)

x2.name

Character. Deprecated (replaced by x2)

x3.name

Character Deprecated (replaced by x3)

Value

A desc object that can be used by the report.doc function.

Details

You can produce formatted Least Square Means table for up to 3 factors. It doesn't work for quantitative covariates.

See examples below.

See Also

report.quali emmeans report.doc desc

Examples

Run this code
# NOT RUN {
library(emmeans)
library(lme4)

data(data)

#Simple lm model

mod=lm(Petal.Width~Species,data=iris)
raw.lsm=emmeans(mod,~Species)
report.lsmeans(raw.lsm,"Species",data=iris)

# In case of just one intercept you must use a workaround...
iris$int=1
mod=glm(Species~int,data=iris,family=binomial)
raw.lsm=emmeans(mod,~int)
iris$int=as.factor(iris$int)
report.lsmeans(raw.lsm,"int",data=iris)

#Mixed model example using lme4

mod=lmer(y_numeric~GROUP+TIMEPOINT+GROUP*TIMEPOINT+(1|SUBJID),data=data) 
raw.lsm=emmeans(mod,~GROUP|TIMEPOINT)
report.lsmeans(lsm=raw.lsm,x1="GROUP",x2="TIMEPOINT",at.row="TIMEPOINT",data=data)


# GLM model with specific contrast

warp.lm <- lm(breaks ~ wool+tension+wool:tension, data = warpbreaks)
warp.emm <- emmeans(warp.lm, ~ tension | wool)
contr=contrast(warp.emm, "trt.vs.ctrl", ref = "M")
report.lsmeans(lsm=contr,x1="wool",data=warpbreaks,contrast=TRUE,at.row="contrast")

# }

Run the code above in your browser using DataLab