[R] How to get a gradient of a matrix

Bai bailhcn at gmail.com
Wed Jul 13 11:42:37 CEST 2011


Dear all,

I have a matrix like this, M<- array(runif(100,-1,1), dim=c(10,10));

I want to get the gradient of M in a new 10 by 10 matrix say Mgrad.

Seemingly, the command like numericDeriv(expr, theta, rho =
parent.frame(), dir = 1) does not work in such a case since I can not
give an "expr".


Thank,

Best,
Bai



More information about the R-help mailing list