Class of Objects for Terms in a Model

DESCRIPTION:
Objects of class "terms" represent the information about a structural model, as specified by a formula. A "terms" object is essentially a digested form of a formula that can be used by the model fitting functions.

GENERATION:
These objects are generated by the terms function.

METHODS:
Generic functions that have methods for "terms" objects include: formula, labels.

STRUCTURE:
The object itself is of mode "expression", with one element for each of the terms, after expansion and possible simplification, and not including the intercept. The object also has a number of attributes:
formula:
the formula.
variables:
a vector of mode "expression", whose elements include those in the terms.object itself, as well as the response variable.
factors:
a matrix of variables by terms, showing which variables occur in which terms. The entries are 0 if the variable does not occur, 1 if it appears and should be coded by contrasts, and 2 if it appears and should be coded by dummy variables for all levels. Row and column labels of this matrix correspond exactly to the relevant entries in term.labels, to permit cross-referencing.
order:
the order of the terms (1 for main effects, 2 for two-way interactions, etc.)
term.labels:
a character version of the terms expression, just to save converting later on.
intercept:
1 if there is an intercept, 0 otherwise.
response:
the variable number corresponding to the response (the expression on the left side of the formula).
specials:
if any of the specials actually appeared in the formula, this is a list with one component for each of the specials found. The value of this component is a vector of indices pointing to the variables attribute of the terms object, and says which of the variables were among the specials. (See the "Error" component in the example below.)

DETAILS:
These objects drive all the model-fitting and are returned as a component of the fitted object by the fitting functions lm, etc.

SEE ALSO:
formula.object , terms .

EXAMPLES:
terms(Y~Temp*Conc+Error(blocks), specials="Error")

# Produces the following output:

expression(Temp, Conc, Error(blocks), Temp:Conc) attr(, "formula"): Yield ~ Temp * Conc + Error(blocks) attr(, "factors"): [,1] [,2] [,3] [,4] [1,] 0 0 0 0 [2,] 1 0 0 1 [3,] 0 1 0 1 [4,] 0 0 1 0 attr(, "order"): [1] 1 1 1 2 attr(, "variables"): expression(Yield, Temp, Conc, Error(blocks)) attr(, "term.labels"): [1] "Temp" "Conc" "Error(blocks)" "Temp:Conc" attr(, "intercept"): [1] 1 attr(, "response"): [1] 1 attr(, "specials"): attr(, "specials")$Error: [1] 4

attr(, "class"): [1] "terms"