ref.grid-class {lsmeans} | R Documentation

## Classes `"ref.grid"` and `"lsmobj"`

### Description

A reference grid encapsulates everything needed to compute least-squares means, independently of the underlying model object. The `"lsmobj"` class is a minor extension of `"ref.grid"` where the linear predictors for the reference grid are transformed in some linear way such as marginal averages or contrasts.

### Objects from the Classes

Objects of class `"ref.grid"` are most commonly created by calling the `ref.grid` function.

Objects of class `"lsmobj"` are created by calling `lsmeans` or a related function such as `contrast`.

### Slots

`model.info`:

  Object of class `"list"` containing the elements `call` (the call that produced the model), `terms` (its `terms` object), and `xlev` (factor-level information)

`roles`:

  Object of class `"list"` containing at least the elements `predictors`, `responses`, and `multresp`. These are character vectors of names of these variables.

`grid`:

  Object of class `"data.frame"` containing the combinations of the variables that define the reference grid. In addition, there is an auxiliary column named `".wgt."` holding the observed frequencies or weights for each factor combination (excluding covariates). If the model has one or more `offset()` calls, there is an another auxiliary column named `".offset."`. Auxiliary columns are not considered part of the reference grid. (However, any variables included in `offset` calls are in the reference grid.)

`levels`:

  Object of class `"list"` with each entry containing the distinct levels of variables in the reference grid. Note that `grid` is obtained by applying the function `expand.grid` to this list

`matlevs`:

  Object of class `"list"` Like `levels` but has the levels of any matrices in the original dataset. Matrix columns must always be reduced to a single value for purposes of the reference grid

`linfct`:

  Object of class `"matrix"` giving the linear functions of the regression coefficients for predicting each element of the reference grid. The rows of this matrix go in one-to-one correspondence with the rows of `grid`, and the columns with elements of `bhat`

`bhat`:

  Object of class `"numeric"` with the regression coefficients. If there is a multivariate response, this must be flattened to a single vector, and `linfct` and `V` redefined appropriately. Important: `bhat` must include any `NA` values produced by collinearity in the predictors. These are taken care of later in the estimability check.

`nbasis`:

  Object of class `"matrix"` with the basis for the non-estimable functions of the regression coefficients. Every LS mean will correspond to a linear combination of rows of `linfct`, and that result must be orthogonal to all the columns of `nbasis` in order to be estimable. This will be `NULL` if everything is estimable

`V`:

  Object of class `"matrix"`, the symmetric variance-covariance matrix of `bhat`

`dffun, dfargs:`

  Objects of class `"function"` and `"list"` respectively. `dffun(k,dfargs)` should return the degrees of freedom for the linear function `sum(k*bhat)`, or `NA` if unavailable

`misc`:

  A `list` containing additional information used by methods. These include at least the following: `estName` (the label for the estimates of linear functions), and the default values of `infer`, `level`, and `adjust` to be used in the `summary` method. Elements in this slot may be modified if desired using the `update` method.

`post.beta`:

  A `matrix` containing a sample from the posterior distribution of the regression coefficients; or a 1 x 1 matrix of `NA` if this is not available. When it is non-trivial, the `as.mcmc` method returns `post.beta` times `t(linfct)`, which is a sample from the posterior distribution of the LS means.

### Extends

`Class "lsmobj"` extends `Class "ref.grid"`, directly. There is hardly a difference between these classes except for how the slots `linfct` and `grid` are obtained, and their `show` methods.

### Methods

All methods for these objects are S3 methods except for `show`.

`show`:

  Prints the results of `str` for `ref.grid` objects, and `summary` for `lsmobj` objects.

`str`:

  Displays a brief listing of the variables and levels defining the grid.

`summary`:

  Displays a summary of estimates, standard errors, degrees of freedom, and optionally, tests and/or confidence intervals.

`lsmeans`:

  Computes least-squares means and creates an `"lsmobj"` object.

`confint`:

  Confidence intervals for lsmeans.

`test`:

  Hypothesis tests.

`cld`:

  Compact-letter display for tests of pairwise comparisons

`contrast`:

  Contrasts among lsmeans.

`pairs`:

  A special case of `contrasts` for pairwise comparisons.

`update`:

  Change defaults used primarily by `summary`, such as transformation, p-value adjustment, and confidence level.

### Author(s)

Russell V. Lenth

### See Also

`ref.grid`, `lsmeans`

### Examples

    showClass("ref.grid")
    showClass("lsmobj")

[Package lsmeans version 2.27-61 Index]