terms object as obtained either with function terms or strip.terms.
data
A data set in which terms are defined.
xlev
a named list of character vectors giving the full set of levels to be assumed for the factors.
Can have less elements, in which case the other levels are learned from the data.
dropIntercept
If TRUE drop intercept term from the design
matrix
maxOrder
An error is produced if special variables are
involved in interaction terms of order higher than max.order.
unspecialsDesign
A logical value: if TRUE apply
model.matrix to unspecial covariates. If
FALSE extract unspecial covariates from data.
specialsFactor
A character vector containing special
variables which should be coerced into a single factor. If
TRUE all specials are treated in this way, if FALSE
none of the specials is treated in this way.
specialsDesign
A character vector containing special
variables which should be transformed into a design matrix via
model.matrix. If TRUE all specials are
treated in this way.
Details
The function separates special terms from the unspecial terms and returns
a list of design matrices, one for unspecial terms and one for each special.
Some special specials cannot or should not be evaluated in
data. E.g., y~a+dummy(x)+strata(v) the function strata can and should be evaluated,
but in order to have model.frame also evaluate dummy(x) one would be to define
and export the function dummy. Still the term dummy(x) can be used
to identify a special treatment of the variable x. To deal with this case,
one can specify stripSpecials="dummy". In addition, the data
should include variables strata(z) and x, not dummy(x).
See examples.
The function untangle.specials of the survival function does a similar job.
Value
A list which contains
- the design matrix with the levels of the variables stored in attribute 'levels'
- separate data.frames which contain the values of the special variables.