Skip to content
Prev 201987 / 398503 Next

What is the equivalent of column.prods() from S in R?

On Nov 29, 2009, at 12:20 AM, Peng Yu wrote:

            
It's a chapter on the internal representation of models. So, no, I  
agree, the colProds function does not do what column.prods did in S  
which was to represent interaction terms.  The terms.object help page  
says these are different than in S. I suspect that the function you  
want is model.matrix. An example with from its help page:

dd <- data.frame(a = gl(3,4), b = gl(4,1,12))# balanced 2-way
options("contrasts")
model.matrix( ~ a + b, dd)
# and then the "product" design matrix
model.matrix( ~ a * b, dd)