Construct a Model Frame - Generic function

DESCRIPTION:
Returns a data frame representing the model.

This function is generic (see Methods); method functions can be written to handle specific classes of data. Classes which already have methods for this function include: aovlist, lm, loess, tree.


USAGE:
model.frame(formula, data, ...)

REQUIRED ARGUMENTS:
formula:
the formula or other object defining what terms should be included in the model frame. Besides being a formula object, this can be a fitted model of various kinds, in which case the formula used in fitting the model defines the terms.

OPTIONAL ARGUMENTS:
data:
data frame from which the model frame is to be constructed.
...:
other arguments to the model fitting functions, such as weights=, subset=, na.action= are passed on to model.frame.

Typically, model.frame is called less often by users than by functions that are either fitting a model or summarizing one. The default method for model.frame constructs the model frame from the terms (usually inferred from the formula), the data if any, and any special expressions such as subsets, weights, or whatever the particular fitting method needs.


VALUE:
a data frame representing all the terms in the model (precisely, all those terms of order 1; i.e., main effects), plus the response if any, and any special extra variables (such as weight arguments to fitting functions). One such argument is handled specially---namely, subset=. If this argument is present, it is used to compute a subset of the rows of the data. It is this subset that is returned. The returned data frame has an attribute terms containing the terms object defined by the formula.

DETAILS:
The response and any extra variables other than subset are stored in the data frame. They should be retrieved from the frame by using model.extract(fr, response) # for response model.extract(fr, weights) # for weights= and so on for whatever names were used in the arguments to model.frame. Other than subset, the names of such extras are arbitrary; they only need to evaluate to a legitimate variable for the data frame (e.g., a numeric vector, matrix, or factor). The names of such variables are specially coded in the model frame so as not to conflict with variable names occurring in the terms. You should always use model.extract, which shares the knowledge of the coded names with model.frame, rather than assuming a specific coding.

NOTE:
Model frames are more typically produced as a side-effect of fitting a model rather than directly by calling model.frame. Functions like lm take an option model=T, that produces the model frame as a component of the fit.

SEE ALSO:
model.extract , Methods .

EXAMPLES:
fuel.fit <- lm(Fuel ~ Weight + Disp., fuel.frame)
model.frame(fuel.fit)
model.frame(sqrt(skips) ~ ., solder)