Supposing 'inmatrix' is a matrix with coloumn names 'x1', 'x2' and 'x3'; how about something like model.matrix(~ (x1 + x2 + x3)^2 + log(x1) + log(x2) + log(x3) + sqrt(x1) + sqrt(x2) + sqrt(x3) - 1, as.data.frame(inmatrix)) -- Bjørn-Helge Mevik