Learn R Programming

lsmeans (version 2.12)

summary: Methods for ref.grid objects

Description

Use these methods to summarize, print, plot, or examine objects of class "ref.grid". They also apply to the class "lsmobj", which is an extension of "ref.grid".

Usage

## S3 method for class 'ref.grid':
summary(object, infer, level, adjust, by, type, df, ...)

## S3 method for class 'ref.grid':
predict(object, type, ...)

## S3 method for class 'ref.grid':
str(object, ...)

## S3 method for class 'ref.grid':
print(x, ...)
## S3 method for class 'summary.ref.grid':
print(x, ..., digits = NULL, quote = FALSE, right = TRUE)

## S3 method for class 'lsmobj':
plot(x, y, type, intervals = TRUE, comparisons = FALSE,
    alpha = 0.05, adjust = "tukey", int.adjust = "none", ...)
## S3 method for class 'summary.ref.grid':
plot(x, y, horizontal = TRUE, 
    xlab, ylab, layout, ...)

## S3 method for class 'ref.grid':
vcov(object, ...)

Arguments

object
An object of class "ref.grid".
infer
A vector of two logical values. The first determines whether confidence intervals are displayed, and the second determines whether t tests and P values are displayed. If only one value is provided, it is used for both.
level
Confidence level for confidence intervals, if infer[1] is TRUE.
adjust
Character value naming the method used to adjust $p$ values or confidence limits; or to adjust comparison arrows in plot. See Details.
by
Character name(s) of variables to use for grouping. This affects the family of tests considered in adjusted P values. The printed display of the summary is grouped by the by variables.
type
Type of prediction desired. This only has an effect if there is a known transformation or link function. "response" specifies that the inverse transformation be applied. Other valid values are "link", "lp", and
df
If non-missing a constant number of degrees of freedom to use in constructing confidence intervals and P values (NA specifies asymptotic results).
x
The object to be printed or plotted.
y
This argument is ignored.
horizontal
Determines orientatiion of plotted confidence intervals.
intervals
If TRUE, confidence intervals are plotted for each estimate
comparisons
If TRUE, comparison arrows are added to the plot, in such a way that the degree to which arrows overlap reflects as much as possible the significance of the comparison of the two estimates.
alpha, int.adjust
The alpha argument to use in constructing comparison arrows. int.adjust may be used to set the adjust argument for the confidence intervals (use adjust to set the adjust method for the comparison arrows)
..., digits, quote, right, xlab, ylab, layout
For summaries, these are additional arguments passed to other methods including print.data.frame, update, or do

Value

  • The summary method for "ref.grid" objects returns an object of class "summary.ref.grid", which extends "data.frame". plot returns an object of class "trellis". vcov returns the covariance matrix of the object's linfct slot.

Details

The misc slot in object contains default values for by, infer, level, adjust, and type. These defaults vary depending on the code that created the object. The update method may be used to change these defaults. In addition, any options set using lsm.options(summary=...) will trump those stored in the object's misc slot. With type="response", the transformation assumed can be found in object@misc$tran, and its label, for the summary is in object@misc$inv.lbl. At this time, tran must be one of the named transformations valid for make.link. Any $t$ or $z$ tests are still performed on the scale of the linear predictor, not the inverse-transformed one. Similarly, confidence intervals are computed on the linear-predictor scale, then inverse-transformed. As applied to $p$ values, adjust has the following effects: "tukey" computes $p$ values using the Studentized range distribution with the number of means in the family; "sidak" replaces each $p$ value by $1 - (1 - p)^c$, where $c$ is the number of contrasts; "scheffe" computes $p$ values from the $F$ distribution, according to the Scheffe criterion; "none" makes no adjustments to the $p$ values. In addition, the Bonferroni-inequality-based adjustment methods in p.adjust are available. Adjustments for confidence limits are available only for adjust equal to "tukey", "sidak", "bonferroni", and "none". For any other adjust, confidence limits are left unadjusted and a message is displayed to that effect. In some cases, confidence and $p$-value adjustments are only approximate -- especially when the degrees of freedom or standard errors vary greatly within the family of tests. For more accurate adjustments, use the glht method for multcomp. When the model is rank-deficient, each row x of object's linfct slot is each checked for estimability. If sum(x*bhat) is found to be non-estimable, then an NA is displayed for the estimate (as well as any associated statistics). This check is performed using the orthonormal basis N in the nbasis slot for the null space of the rows of the model matrix. Estimability fails when $||Nx||^2 / ||x||^2$ exceeds tol, which by default is 1e-8. You may change it via lsm.options by setting estble.tol to the desired value. The plot method for "lsmobj" or "summary.ref.grid" objects (but not "ref.grid" objects themselves) produces a plot displaying confidence intervals for the estimates. If any by variables are in force, the plot is divided into separate panels. These functions use the dotplot function, and thus require that the lattice package be installed. For "summary.ref.grid" objects, the ... arguments in plot are passed only to dotplot, whereas for "lsmobj" objects, the object is updated using ... before summarizing and plotting. In plots with comparisons = TRUE, the resulting arrows are only approximate, and in some cases may fail to accurately reflect the pairwise comparisons of the estimates -- especially when estimates having large and small standard errors are intermingled in just the wrong way.

See Also

Methods for the closely related "lsmobj" class can be found in contrast, cld, and glht.

Examples

Run this code
require(lsmeans)
warp.lm <- lm(breaks ~ wool * tension, data = warpbreaks)
warp.rg <- ref.grid(warp.lm)
str(warp.rg)

summary(warp.rg)

summary(warp.rg, by = "wool", 
        infer = c(TRUE, FALSE), level = .90, adjust = "sidak")

# Transformed response
sqwarp.rg <- ref.grid(update(warp.lm, sqrt(breaks) ~ .))
summary(sqwarp.rg)

# Back-transformed results - compare with summary of 'warp.rg'
summary(sqwarp.rg, type = "response")

# Logistic regression
# Reshape the Titanic data
Titan <- do.call("expand.grid", dimnames(Titanic)[-4])
Titan$Died <- matrix(Titanic, ncol=2)
Titan.glm <- glm(Died ~ (Class + Sex + Age)^2, 
    family = binomial, data = Titan)
Titan.lsm <- lsmeans(Titan.glm, ~ Class|Sex, at = list(Age="Adult"))
summary(Titan.lsm, type="response")
summary(pairs(Titan.lsm), type="response")

# Plot 90% CIs on the response scale
plot(Titan.lsm, type = "response", level = .90, 
     xlab = "Predicted probability of drowning")

Run the code above in your browser using DataLab