ref.grid object from a fitted model.recover.data(object, ...)
## S3 method for class 'call':
recover.data(object, trms, na.action, data, ...)
lsm.basis(object, trms, xlev, grid, ...)
nonest.basis(qrX)terms component of objectfactor call in the mdoel formula.data.frame containing predictor values at which predictions are needed.qr with LAPACK=FALSE). The latter is preferred if already available, as it saves computation.NULL if noneNULL. However, if non-null, this is used in place of the reconstructed dataset. It must have all of the predictors used in the model, and any factor levels must match those used in fitting the model.list with the following elements:grid, having the same number of rows as grid and the number of columns equal to the length of bhat.NAs that result from rank deficiencies.NA if there is no rank deficiency.bhat.(k, dfargs) that returns the degrees of freedom associated with sum(k * bhat).list containing additional arguments needed for dffun.ref.grid function needs to reconstruct the data used in fitting the model, and then obtain a matrix of linear functions of the regression coefficients for a given grid of predictor values. These tasks are performed by calls to recover.data and lsm.basis respectively.
To extend recover.data can be done by its method for class "call", providing the terms component and na.action data as additional arguments. Writing an lsm.basis method is more involved, but the existing methods (e.g., lsmeans:::lsm.basis.lm) can serve as models. See the ``Value'' section below for details on what it needs to return.
If the model has a multivariate response, bhat needs to be X and V must be constructed consistently.
In models where a non-full-rank result is possible (often you can tell by seeing if there is a singular.ok argument in the model-fitting function), summary and predict check the estimability of each prediction, and for this, a basis for the non-estimable functions is required. The nonest.basis function provides an easy way to obtain this.
The models already supported are detailed in models. Some packages may provide additional models, ref.grid, ref.grid-classrequire(lsmeans)
# Fit a 2-factor model with two empty cells
warpsing.lm <- lm(breaks ~ wool*tension,
data = warpbreaks, subset = -(16:40))
nonest.basis(warpsing.lm$qr)Run the code above in your browser using DataLab