An object of class `terms`

holds information about a
model. Usually the model was specified in terms of a
`formula`

and that formula was used to determine the terms
object.

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:

`factors` |
A matrix of variables by terms showing which variables
appear in which terms. The entries are 0 if the variable does not
occur in the term, 1 if it does occur and should be coded by
contrasts, and 2 if it occurs and should be coded via dummy
variables for all levels (as when a lower-order term
is missing). Note that variables in main effects always receive 1,
even if the intercept is missing (in which case the first one
should be coded with dummy variables).
If there are no terms other than an intercept and offsets,
this is |

`term.labels` |
A character vector containing the labels for each of the terms in the model, except for offsets. Note that these are after possible re-ordering of terms. Non-syntactic names will be quoted by backticks: this makes it easier to re-construct the formula from the term labels. |

`variables` |
A call to |

`intercept` |
Either 0, indicating no intercept is to be fit, or 1 indicating that an intercept is to be fit. |

`order` |
A vector of the same length as |

`response` |
The index of the variable (in variables) of the response (the left hand side of the formula). Zero, if there is no response. |

`offset` |
If the model contains |

`specials` |
If a |

`dataClasses` |
optional. A named character vector giving the classes
(as given by |

`predvars` |
optional. An expression to help in computing
predictions at new covariate values; see |

The object has class `c("terms", "formula")`

.

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
`aov`

and `coxph`

functions, the
latter from package survival.

`terms`

, `formula`

.

1 2 3 4 5 6 7 8 9 | ```
## 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)
``` |

What can we improve?

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.

Close