Skip to content
Prev 52468 / 63421 Next

suggested addition to model.matrix

Dear Spencer,

I don't think that the problem of "converting a data frame into a model matrix" is well-defined, because there isn't a unique mapping from one to the other. 

In your example, you build  the model matrix for the additive formula ~ a + b from the data frame matrix containing a and b, using "treatment" contrasts, but there are other possible formulas (e.g., ~ a*b) and contrasts [e.g., model.matrix(~ a + b, dd, contrasts=list(a=contr.sum, b=contr.helmert)].

So I think that the current approach is sensible -- to require both a data frame and a formula.

Best,
 John