Description of Terms Objects
The object itself is simply the formula supplied to the call of
terms.formula. The object has a number of attributes
and they are used to construct the model frame:
listof the variables in the model.
term.labelsindicating the order of interaction for each term.
offsetterms there is an
offsetattribute indicating which variable(s) are offsets
specialsargument was given to
terms.formulathere is a
specialsattribute, a pairlist of vectors (one for each specified special function) giving numeric indices of the arguments of the list returned as the
variablesattribute which contain these special functions.
.MFclass) of the variables used in a fit.
These objects are different from those found in S. In particular
there is no
formula attribute: instead the object is itself a
formula. (Thus, the mode of a terms object is different.) Examples of the
specials argument can be seen in the
coxph functions, the
latter from package survival">https://CRAN.R-project.org/package=survival.
## use of specials (as used for gam() in packages mgcv and gam) (tf <- terms(y ~ x + x:z + s(x), specials = "s")) ## Note that the "factors" attribute has variables as row names ## and term labels as column names, both as character vectors. attr(tf, "specials") # index 's' variable(s) rownames(attr(tf, "factors"))[attr(tf, "specials")$s] ## we can keep the order by terms(y ~ x + x:z + s(x), specials = "s", keep.order = TRUE)