Matrix expression causes error “requires numeric/complex matrix/vector arguments”?

To get the matrix multiplication to work, you need to convert the data.frame (presumably that’s what da is) to a matrix:

t(da)%*%as.matrix(da)

But this gives a 7×7 matrix which can’t be added to the 3×3 identity matrix that you’re using. Do you mean something like:

ma=diag(7)+t(da)%*%as.matrix(da)

You may like to have a look at An Introduction to R if you don’t feel confident about the difference between a matrix and data.frame.

Leave a Comment