[ top | up ]
Construct design matrices
Usage
model.matrix(formula =, data =)
Arguments
formula
|
A model formula or terms object
|
data
|
A data frame created with model.frame
|
Description
Creates a design matrix from the description given in
terms(formula), using the data in data which must
contain columns with the same names as would be created by a call to
model.frame(formula) or, more precisely, by evaluating
attr(terms(formula), "variables"). There may be other columns
and the order is not important.
Value
The design matrix for a regression model with the specified formula
and data.
References
Chambers and Hastie: "Statistical Models in S"
See Also
model.frame, model.data.frame,
terms
Examples
data(trees)
ff <- log(Volume) ~ log(Height) + log(Girth)
m <- model.frame(ff, trees)
mat <- model.matrix(ff, m)