The emmGrid
class encapsulates linear functions of regression
parameters, defined over a grid of predictors. This includes reference
grids and grids of marginal means thereof (aka estimated marginal means).
Objects of class `emmGrid` may be used independently of the underlying model
object. Instances are created primarily by ref_grid
and
emmeans
, and several related functions.
Slots
model.info
list. Contains the elements
call
(the call that produced the model),terms
(itsterms
object), andxlev
(factor-level information)roles
list. Contains at least the elements
predictors
,responses
, andmultresp
. Each is a character vector of names of these variables.grid
data.frame. Contains 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 moreoffset()
calls, there is an another auxiliary column named".offset."
. Auxiliary columns are not considered part of the reference grid. (However, any variables included inoffset
calls are in the reference grid.)levels
list. Each entry is a character vector with the distinct levels of each variable in the reference grid. Note that
grid
is obtained by applying the functionexpand.grid
to this listmatlevs
list. Like
levels
but has the levels of any matrices in the original dataset. Matrix columns are always concatenated and treated as a single variable for purposes of the reference gridlinfct
matrix. Each row consists of the linear function of the regression coefficients for predicting its corresponding 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 ofbhat
.bhat
numeric. The regression coefficients. If there is a multivariate response, the matrix of coefficients is flattened to a single vector, and
linfct
andV
redefined appropriately. Important:bhat
must include anyNA
values produced as a result of collinearity in the predictors. These are taken care of later in the estimability check.nbasis
matrix. The basis for the non-estimable functions of the regression coefficients. Every EMM will correspond to a linear combination of rows of
linfct
, and that result must be orthogonal to all the columns ofnbasis
in order to be estimable. If everything is estimable,nbasis
should be a 1 x 1 matrix ofNA
.V
matrix. The symmetric variance-covariance matrix of
bhat
dffun
function having two arguments.
dffun(k, dfargs)
should return the degrees of freedom for the linear functionsum(k*bhat)
, orNA
if unavailabledfargs
list. Used to hold any additional information needed by
dffun
.misc
list. Additional information used by methods. These include at least the following:
estName
(the label for the estimates of linear functions), and the default values ofinfer
,level
, andadjust
to be used in thesummary.emmGrid
method. Elements in this slot may be modified if desired using theupdate.emmGrid
method.post.beta
matrix. A sample from the posterior distribution of the regression coefficients, if MCMC methods were used; or a 1 x 1 matrix of
NA
otherwise. When it is non-trivial, theas.mcmc.emmGrid
method returnspost.beta %*% t(linfct)
, which is a sample from the posterior distribution of the EMMs.
Methods
All methods for these objects are S3 methods except for show
.
They include [.emmGrid
, as.glht.emmGrid
,
as.mcmc.emmGrid
, as.mcmc.list.emmGrid
(see coda),
cld.emmGrid
(see multcomp),
coef.emmGrid
, confint.emmGrid
,
contrast.emmGrid
, pairs.emmGrid
,
plot.emmGrid
, predict.emmGrid
, print.emmGrid
,
rbind.emmGrid
, show.emmGrid
, str.emmGrid
,
summary.emmGrid
, test.emmGrid
,
update.emmGrid
, vcov.emmGrid
, and
xtable.emmGrid